-
-
Notifications
You must be signed in to change notification settings - Fork 285
/
_OverFullscreen.svelte
113 lines (106 loc) · 2.81 KB
/
_OverFullscreen.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<Dialog
bind:open
fullscreen
aria-labelledby="over-fullscreen-title"
aria-describedby="over-fullscreen-content"
on:SMUIDialog:closed={closeHandler}
>
<Header>
<Title id="over-fullscreen-title">Terms and Conditions</Title>
<IconButton action="close" class="material-icons">close</IconButton>
</Header>
<Content id="over-fullscreen-content">
<Button on:click={() => (subOpen = true)}>
<Label>Open Confirmation Dialog</Label>
</Button>
{#each Array(3) as _item}
<LoremIpsum />
{/each}
</Content>
<Actions>
<Button action="reject">
<Label>Reject</Label>
</Button>
<Button action="accept" defaultAction>
<Label>Accept</Label>
</Button>
</Actions>
<Dialog
bind:open={subOpen}
slot="over"
selection
aria-labelledby="over-fullscreen-confirmation-title"
aria-describedby="over-fullscreen-confirmation-content"
on:SMUIDialog:closed={confirmationCloseHandler}
>
<Header>
<Title id="over-fullscreen-confirmation-title">Confirmation</Title>
</Header>
<Content id="over-fullscreen-confirmation-content">
<List radioList>
<Item use={[InitialFocus]}>
<Graphic>
<Radio bind:group={selection} value="One" />
</Graphic>
<Text>Choice 1</Text>
</Item>
<Item>
<Graphic>
<Radio bind:group={selection} value="Two" />
</Graphic>
<Text>Choice 2</Text>
</Item>
</List>
</Content>
<Actions>
<Button>
<Label>Cancel</Label>
</Button>
<Button action="accept">
<Label>Accept</Label>
</Button>
</Actions>
</Dialog>
</Dialog>
<Button on:click={() => (open = true)}>
<Label>Open Dialog</Label>
</Button>
<pre class="status">Response: {response}, Selected: {selected}</pre>
<script lang="ts">
import Dialog, {
Header,
Title,
Content,
Actions,
InitialFocus,
} from '@smui/dialog';
import IconButton from '@smui/icon-button';
import Button, { Label } from '@smui/button';
import List, { Item, Graphic, Text } from '@smui/list';
import Radio from '@smui/radio';
import LoremIpsum from '$lib/LoremIpsum.svelte';
let open = false;
let subOpen = false;
let selection = 'Radishes';
let selected = 'Nothing yet.';
let response = 'Nothing yet.';
function confirmationCloseHandler(e: CustomEvent<{ action: string }>) {
if (e.detail.action === 'accept') {
selected = selection;
}
selection = 'Radishes';
}
function closeHandler(e: CustomEvent<{ action: string }>) {
switch (e.detail.action) {
case 'close':
response = 'Closed without response.';
break;
case 'reject':
response = 'Rejected.';
break;
case 'accept':
response = 'Accepted.';
break;
}
}
</script>