Skip to content

Commit 91ad543

Browse files
authored
Merge pull request #22 from silinternational/feature/Dialog-story
Dialog story
2 parents 735a164 + a61fc13 commit 91ad543

File tree

6 files changed

+112
-4
lines changed

6 files changed

+112
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
### Added
1212
- actions, isAboveMobile, isAboveTablet, setNotice to index.js so they can be imported directly
13-
- $$props.class to Fab, TextArea, Select, Checkbox and List so they can accept global classes
13+
- $$props.class to Fab, TextArea, Select, Checkbox, Datatable, Dialog.Simple, Dialog.Alert and List so they can accept global classes
1414
- barColorProvided to Progress.Linear to allow bypass of bar-color class when no color is provided
1515
- bgColorIsVariant to TopAppBar to allow bypass of bg-color-variant if no color is provided
1616
- README: Theming, Drawer example, CSS utility classes and Storybook url.

components/mdc/Datatable/Datatable.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ onMount(() => {
2222
})
2323
</script>
2424

25-
<div class="mdc-data-table w-100" bind:this={element}>
25+
<div class="mdc-data-table w-100 {$$props.class}" bind:this={element}>
2626
<div class="mdc-data-table__table-container">
2727
<table class="mdc-data-table__table" aria-label={label}>
2828
<slot />

components/mdc/Dialog/Alert.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ onMount(() => {
4343
})
4444
</script>
4545

46-
<div class="mdc-dialog" bind:this={element}>
46+
<div class="mdc-dialog {$$props.class}" bind:this={element}>
4747
<div class="mdc-dialog__container">
4848
<div class="mdc-dialog__surface"
4949
role="alertdialog"

components/mdc/Dialog/Simple.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const toAction = json => JSON.stringify(json)
3535
const fromAction = s => JSON.parse(s)
3636
</script>
3737

38-
<div class="mdc-dialog" bind:this={element}>
38+
<div class="mdc-dialog {$$props.class}" bind:this={element}>
3939
<div class="mdc-dialog__container">
4040
<div class="mdc-dialog__surface" role="alertdialog" aria-modal="true" aria-labelledby="dialog-title" aria-describedby="dialog-content">
4141
<!--(notes from docs) Title cannot contain leading whitespace due to mdc-typography-baseline-top() -->

stories/Alert.stories.svelte

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { Dialog } from "../components/mdc"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
onChosen: e => console.log(e.detail),
8+
onClosed: () => {},
9+
open: true,
10+
class: '', //only works for global classes
11+
}
12+
</script>
13+
14+
<Meta
15+
title="Atoms/Dialog.Alert"
16+
component={Dialog.Alert}
17+
/>
18+
19+
<Template let:args>
20+
<Dialog.Alert {...args} on:chosen={args.onChosen} on:closed={args.onClosed}>Main slot here</Dialog.Alert>
21+
</Template>
22+
23+
<Story
24+
name="Default"
25+
{args}
26+
/>
27+
28+
<Story
29+
name="Title"
30+
args={
31+
copyAndModifyArgs(args, {title: 'title'})
32+
}
33+
/>
34+
35+
<Story
36+
name="Default action"
37+
args={
38+
copyAndModifyArgs(args, {defaultAction: 'cancel'})
39+
}
40+
/>
41+
42+
<Story
43+
name="Buttons"
44+
args={
45+
copyAndModifyArgs(args, {
46+
buttons: [
47+
{
48+
label: 'quit',
49+
action: 'quit',
50+
class: 'mdc-dialog__button'
51+
},
52+
{
53+
label: 'discard',
54+
action: 'discard',
55+
class: 'mdc-dialog__button'
56+
}
57+
]
58+
})
59+
}
60+
/>

stories/Simple.stories.svelte

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { Dialog } from "../components/mdc"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
onChosen: e => console.log(e.detail),
8+
open: true,
9+
items: [
10+
{id: '1', name: 'item1 name'},
11+
{id: '2', name: 'item2 name'}
12+
],
13+
class: '', //only works for global classes
14+
}
15+
</script>
16+
17+
<Meta
18+
title="Atoms/Dialog.Simple"
19+
component={Dialog.Simple}
20+
/>
21+
22+
<Template let:args>
23+
<Dialog.Simple {...args} on:chosen={args.onChosen}/>
24+
</Template>
25+
26+
<Story
27+
name="Default"
28+
{args}
29+
/>
30+
31+
<Story
32+
name="Title"
33+
args={
34+
copyAndModifyArgs(args, {title: 'title'})
35+
}
36+
/>
37+
38+
<Story
39+
name="Items"
40+
args={
41+
copyAndModifyArgs(args, {items: [
42+
{id: '1', name: 'item1 name'},
43+
{id: '2', name: 'item2 name'},
44+
{id: '3', name: 'item3 name'},
45+
{id: '4', name: 'item4 name'}
46+
]})
47+
}
48+
/>

0 commit comments

Comments
 (0)