Skip to content

Commit 7de1a63

Browse files
committed
docs: add demo showing dialog button that doesn't close dialog
Closes #692
1 parent a9a5bc8 commit 7de1a63

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

packages/site/src/routes/demo/dialog/+page.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
Dialog with sliders
3838
</Demo>
3939

40+
<Demo component={NonCloseButton} file="dialog/_NonCloseButton.svelte">
41+
Dialog with button that doesn't close
42+
</Demo>
43+
4044
<Demo component={LargeScroll} file="dialog/_LargeScroll.svelte">
4145
Large, scrollable dialog
4246
</Demo>
@@ -86,6 +90,7 @@
8690
import List from './_List.svelte';
8791
import Selection from './_Selection.svelte';
8892
import Sliders from './_Sliders.svelte';
93+
import NonCloseButton from './_NonCloseButton.svelte';
8994
import LargeScroll from './_LargeScroll.svelte';
9095
import Fullscreen from './_Fullscreen.svelte';
9196
import OverFullscreen from './_OverFullscreen.svelte';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<Dialog
2+
bind:open
3+
aria-labelledby="nonclose-title"
4+
aria-describedby="nonclose-content"
5+
>
6+
<!-- Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->
7+
<Title id="nonclose-title">Easiest Riddle</Title>
8+
<Content id="nonclose-content"
9+
>Only one of these buttons will close the dialog. Can you guess which one?</Content
10+
>
11+
<Actions>
12+
<!--
13+
The `action=""` here will cause the dialog to stay open. The default
14+
action is "close".
15+
-->
16+
<Button action="" onclick={() => (clicked = "It didn't close, did it?")}>
17+
<Label>It's the Other One</Label>
18+
</Button>
19+
<Button onclick={() => (clicked = 'I told you.')}>
20+
<Label>It's This One</Label>
21+
</Button>
22+
</Actions>
23+
</Dialog>
24+
25+
<Button onclick={() => (open = true)}>
26+
<Label>Open Dialog</Label>
27+
</Button>
28+
29+
<pre class="status">Clicked: {clicked}</pre>
30+
31+
<script lang="ts">
32+
import Dialog, { Title, Content, Actions } from '@smui/dialog';
33+
import Button, { Label } from '@smui/button';
34+
35+
let open = $state(false);
36+
let clicked = $state('Nothing yet.');
37+
</script>

0 commit comments

Comments
 (0)