Skip to content

Commit a7a45a5

Browse files
authored
Merge pull request #18 from silinternational/feature/select-story
Select story
2 parents 762c793 + 4061033 commit a7a45a5

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
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 and List so they can accept global classes
13+
- $$props.class to Fab, TextArea, Select, Checkbox and List so they can accept global classes
1414
- README: Theming, Drawer example and Storybook url.
1515
- Storybook for showcasing components at https://silinternational.github.io/ui-components/
1616

components/mdc/Checkbox/Checkbox.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ onMount(() => {
3030
const handleChange = () => dispatch(checkbox.checked ? 'checked' : 'unchecked')
3131
</script>
3232

33-
<div class="mdc-form-field" bind:this={formFieldElement}>
33+
<div class="mdc-form-field {$$props.class}" bind:this={formFieldElement}>
3434
<div class="mdc-checkbox" bind:this={checkboxElement}>
3535
<input type="checkbox" {disabled} on:change={handleChange} class="mdc-checkbox__native-control" id={inputID} />
3636
<div class="mdc-checkbox__background">

components/mdc/Select/Select.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ afterUpdate(() => {
4040
})
4141
</script>
4242

43-
<div class="mdc-select mdc-select--outlined" bind:this={element} style="width: {width}">
43+
<div class="mdc-select mdc-select--outlined {$$props.class}" bind:this={element} style="width: {width}">
4444
<div class="mdc-select__anchor"
4545
role="button"
4646
aria-haspopup="listbox"

stories/Checkbox.stories.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
const args = {
77
label: "Checkbox",
8+
class: '', //only works for global classes
89
}
910
</script>
1011

stories/Select.stories.svelte

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { Select } from "../components/mdc"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
options: [
8+
{name: 'choice 1', id: '0'},
9+
{name: 'choice 2', id: '1'},
10+
{name: 'choice 3', id: '2'},
11+
{name: 'choice 4', id: '3'},
12+
{name: 'choice 5', id: '4'},
13+
{name: 'choice 6', id: '5'}
14+
],
15+
onChange: e => console.log(e.detail),
16+
class: '', //only works for global classes
17+
}
18+
</script>
19+
20+
<Meta
21+
title="Atoms/Select"
22+
component={Select}
23+
/>
24+
25+
<Template let:args>
26+
<Select {...args} on:change={args.onChange}/>
27+
</Template>
28+
29+
<Story
30+
name="Default"
31+
{args}
32+
/>
33+
34+
<Story
35+
name="Label"
36+
args={
37+
copyAndModifyArgs(args, {label: 'Label'})
38+
}
39+
/>
40+
41+
<Story
42+
name="Width"
43+
args={
44+
copyAndModifyArgs(args, {width: '560px'})
45+
}
46+
/>
47+
48+
<Story
49+
name="Disabled"
50+
args={
51+
copyAndModifyArgs(args, {disabled: true})
52+
}
53+
/>

0 commit comments

Comments
 (0)