Skip to content

Commit acb535a

Browse files
authored
Merge pull request #29 from silinternational/feature/more-stories
More stories, Tour bugfix
2 parents 052764f + 41ac931 commit acb535a

File tree

12 files changed

+193
-8
lines changed

12 files changed

+193
-8
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
### Changed
9+
- README - Instructions for running Storybook locally
10+
11+
### Added
12+
- $$props.class to Badge, Form, CustomCard, Tour and StaticChip so they can accept global classes
13+
- Badge, CustomCard, Form, StaticChip and Tour stories to Storybook
14+
15+
### Fixed
16+
- Tour was failing to replace key with value of data prop in steps content.
17+
718
## [1.1.0](https://github.com/silinternational/ui-components/releases/tag/v1.1.0) - 2021-05-26
819
### Changed
920
- package.json version to 1.1.0

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ An example of using Drawer:
180180

181181
### storybook
182182
Try out our components at https://silinternational.github.io/ui-components/
183+
or run storybook locally. Just copy this repo to your machine and run `npm install` then `npm run dev.` Storybook should open a browser window when it finishes building.
183184

184185
### CSS utility classes
185186
Classes from [global.css](https://github.com/silinternational/ui-components/blob/develop/components/global.css) can be applied to all components and even components and elements from your app.

components/Badge.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
}
1515
</style>
1616

17-
<span class="dib align-center white fs-16 br-50 background" style="--theme-color: {color}" ><slot /></span>
17+
<span class="dib align-center white fs-16 br-50 background {$$props.class}" style="--theme-color: {color}" ><slot /></span>

components/CustomCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626
</style>
2727

28-
<Card class="h-100 py-1">
28+
<Card class="h-100 py-1 {$$props.class}">
2929
<div class="flex justify-center">
3030
<img class="w-100" {src} {alt} class:disabled/>
3131
</div>

components/Form.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
}
55
</style>
66

7-
<form class="w-100" on:submit|preventDefault autocomplete="off">
7+
<form class="w-100 {$$props.class}" on:submit|preventDefault autocomplete="off">
88
<slot />
99
</form>

components/StaticChip.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
</style>
1212

13-
<div class="chip black flex justify-center aligned mb-1 mr-2 fs-14 br-16px">
13+
<div class="chip black flex justify-center aligned mb-1 mr-2 fs-14 br-16px {$$props.class}">
1414
<div class="chip-content flex aligned">
1515
<slot></slot>
1616
</div>

components/Tour.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
tourTitle = thisStep.title || ''
5757
target = thisStep.target || ''
5858
for (const [key, value] of Object.entries(data)) {
59-
tourMessage = tourMessage.replace(`{${key}}`, value)
60-
tourTitle = tourTitle.replace(`{${key}}`, value)
61-
target = target.replace(`{${key}}`, value)
59+
tourMessage = tourMessage.replace(key, value)
60+
tourTitle = tourTitle.replace(key, value)
61+
target = target.replace(key, value)
6262
}
6363
6464
buttons = [
@@ -68,4 +68,4 @@
6868
}
6969
</script>
7070

71-
<Dialog.Alert title={tourTitle} on:chosen={event => alertChosen(event.detail)} open={openDialog} {buttons}>{@html tourMessage}</Dialog.Alert>
71+
<Dialog.Alert class="{$$props.class}" title={tourTitle} on:chosen={event => alertChosen(event.detail)} open={openDialog} {buttons}>{@html tourMessage}</Dialog.Alert>

stories/Badge.stories.svelte

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { Badge } from "../"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
class: '', //only works for global classes
8+
color: 'gray'
9+
}
10+
</script>
11+
12+
<Meta
13+
title="Atoms/Badge"
14+
component={Badge}
15+
/>
16+
17+
<Template let:args>
18+
<Badge {...args}>S</Badge>
19+
</Template>
20+
21+
<Story
22+
name="Default"
23+
{args}
24+
/>
25+
26+
<Story
27+
name="Blue"
28+
args={copyAndModifyArgs(args, {color: 'blue'})}
29+
/>

stories/CustomCard.stories.svelte

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { CustomCard } from "../"
4+
import { copyAndModifyArgs } from "./helpers.js"
5+
6+
const args = {
7+
class: '', //only works for global classes
8+
}
9+
</script>
10+
11+
<Meta
12+
title="Molecule/CustomCard"
13+
component={CustomCard}
14+
/>
15+
16+
<Template let:args>
17+
<CustomCard {...args}></CustomCard>
18+
</Template>
19+
20+
<Story
21+
name="Default"
22+
{args}
23+
/>
24+
25+
<Story
26+
name="FooterText"
27+
args={copyAndModifyArgs(args, {footerText: 'Here is some footertext'})}
28+
/>
29+
30+
<Story
31+
name="Icon"
32+
args={copyAndModifyArgs(args, {icon: 'face'})}
33+
/>
34+
35+
<Story
36+
name="Buttons"
37+
args={copyAndModifyArgs(args, {buttons: [{label: 'return to root', url: './'}]})}
38+
/>
39+
40+
<Story
41+
name="Disabled"
42+
args={copyAndModifyArgs(args, {disabled: true})}
43+
/>

stories/Form.stories.svelte

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script>
2+
import { Meta, Template, Story } from "@storybook/addon-svelte-csf"
3+
import { Form, TextField } from "../"
4+
5+
const args = {
6+
class: '', //only works for global classes
7+
onSubmit: () => {}
8+
}
9+
</script>
10+
11+
<Meta
12+
title="Molecule/Form"
13+
component={Form}
14+
/>
15+
16+
<Template let:args>
17+
<Form on:submit={args.onSubmit} {...args}>
18+
<TextField></TextField>
19+
</Form>
20+
</Template>
21+
22+
<Story
23+
name="Default"
24+
{args}
25+
/>

0 commit comments

Comments
 (0)