-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19987 from storybookjs/jeppe/fix-svelte-decorator…
…s-slots Svelte: Fix decorators with slots
- Loading branch information
Showing
10 changed files
with
139 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
code/renderers/svelte/template/stories/slot-decorators.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import ButtonView from './views/ButtonView.svelte'; | ||
import BorderDecoratorRed from './views/BorderDecoratorRed.svelte'; | ||
import BorderDecoratorBlue from './views/BorderDecoratorBlue.svelte'; | ||
import BorderDecoratorProps from './views/BorderDecoratorProps.svelte'; | ||
|
||
export default { | ||
component: ButtonView, | ||
decorators: [() => BorderDecoratorRed], | ||
args: { | ||
primary: true, | ||
}, | ||
}; | ||
|
||
export const WithDefaultRedBorder = {}; | ||
export const WithBareBlueBorder = { | ||
decorators: [() => BorderDecoratorBlue], | ||
}; | ||
export const WithPreparedBlueBorder = { | ||
decorators: [ | ||
() => ({ | ||
Component: BorderDecoratorBlue, | ||
}), | ||
], | ||
}; | ||
export const WithPropsBasedBorder = { | ||
decorators: [ | ||
() => ({ | ||
Component: BorderDecoratorProps, | ||
props: { color: 'green' }, | ||
}), | ||
], | ||
}; | ||
export const WithArgsBasedBorderUnset = { | ||
argTypes: { | ||
color: { control: 'color' }, | ||
}, | ||
decorators: [(_, { args }) => ({ Component: BorderDecoratorProps, props: args })], | ||
}; | ||
export const WithArgsBasedBorder = { | ||
...WithArgsBasedBorderUnset, | ||
args: { color: 'lightblue' }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
code/renderers/svelte/template/stories/views/BorderDecoratorBlue.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div style="border: 3px solid blue; padding: 10px; margin: 10px;"> | ||
<slot /> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
code/renderers/svelte/template/stories/views/BorderDecoratorProps.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
export let color = 'violet'; | ||
</script> | ||
|
||
<div style="border: 3px solid {color}; padding: 10px; margin: 10px;"> | ||
<slot /> | ||
</div> |
3 changes: 3 additions & 0 deletions
3
code/renderers/svelte/template/stories/views/BorderDecoratorRed.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div style="border: 3px solid red; padding: 10px; margin: 10px;"> | ||
<slot /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters