-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Svelte: Fix union types generating invalid labels in argTypes #31980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
5de7c3e
f532b91
cea8ce1
6b63b02
4c4a30b
f27837d
3c9376d
73f030d
b7d3a49
477ca9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,12 @@ | |
| import './button.css'; | ||
|
|
||
| interface Props { | ||
| /** Is this the principal call to action on the page? */ | ||
| primary?: boolean; | ||
| /** | ||
| * The variant of the button | ||
| * | ||
| * @default primary | ||
| */ | ||
| variant?: 'primary' | 'secondary' | 'flat'; | ||
|
||
| /** What background color to use */ | ||
| backgroundColor?: string; | ||
| /** How large should the button be? */ | ||
|
|
@@ -14,9 +18,22 @@ | |
| onclick?: () => void; | ||
| } | ||
|
|
||
| const { primary = false, backgroundColor, size = 'medium', label, ...props }: Props = $props(); | ||
|
|
||
| let mode = $derived(primary ? 'storybook-button--primary' : 'storybook-button--secondary'); | ||
| const { | ||
| variant = 'primary', | ||
| backgroundColor, | ||
| size = 'medium', | ||
| label, | ||
| ...props | ||
| }: Props = $props(); | ||
|
|
||
| const variantToClass = { | ||
| primary: 'storybook-button--primary', | ||
| secondary: 'storybook-button--secondary', | ||
| // Flat only exists to verify type inference for the control creation works | ||
| flat: '', | ||
|
||
| }; | ||
|
|
||
| let mode = $derived(variantToClass[variant]); | ||
| let style = $derived(backgroundColor ? `background-color: ${backgroundColor}` : ''); | ||
| </script> | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Verify that Button.svelte component accepts 'variant' prop, as this was changed from 'primary' without corresponding component changes visible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were component changes. Try not to hallucinate please.