-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathfeedback.svelte
60 lines (56 loc) · 1.99 KB
/
feedback.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script lang="ts">
import { Button, Form } from '$lib/elements/forms';
import {
feedback,
selectedFeedback,
feedbackOptions,
feedbackData
} from '$lib/stores/feedback';
import { addNotification } from '$lib/stores/notifications';
$: $selectedFeedback = feedbackOptions.find((option) => option.type === $feedback.type);
async function submit() {
try {
await feedback.submitFeedback(
`feedback-${$feedback.type}`,
$feedbackData.message,
$feedbackData.name,
$feedbackData.email
);
addNotification({
type: 'success',
message: 'Thank you for your feedback'
});
feedback.toggleFeedback();
feedbackData.reset();
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
</script>
<section class="drop-section u-padding-24">
<header class="u-flex u-main-space-between u-gap-16">
<h4 class="label u-bold" style:font-size="var(--font-size-1)">{$selectedFeedback.title}</h4>
<button
type="button"
class="button is-text is-only-icon u-margin-inline-start-auto"
style="--button-size:1.5rem;"
aria-label="Close feedback"
title="Close feedback"
on:click={() => feedback.toggleFeedback()}>
<span class="icon-x" aria-hidden="true" />
</button>
</header>
<div class="u-margin-block-start-8 u-line-height-1-5">
{$selectedFeedback.desc}
</div>
<Form onSubmit={submit}>
<svelte:component this={$selectedFeedback.component} />
<div class="u-flex u-main-end u-gap-16 u-margin-block-start-24">
<Button text on:click={() => feedback.toggleFeedback()}>Cancel</Button>
<Button secondary submit>Submit</Button>
</div>
</Form>
</section>