-
Notifications
You must be signed in to change notification settings - Fork 176
📚 Add comprehensive Storybook stories for UI library components #3671
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8650c8
📚 Add comprehensive Storybook stories for UI library components
junkisai dcb19ac
🧹 Remove unnecessary biome-ignore comments from Select component
junkisai e5cd016
Remove unnecessary mobile story
MH4GF 597ecf5
fix: remove button-in-button nesting in Modal stories
github-actions[bot] 5b62b85
♿ Enhance Switch component story with accessibility and styling
junkisai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
frontend/packages/ui/src/components/Avatar/Avatar.stories.tsx
This file contains hidden or 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,135 @@ | ||
import type { Meta, StoryObj } from '@storybook/nextjs' | ||
import { Avatar } from './Avatar' | ||
|
||
const meta = { | ||
component: Avatar, | ||
argTypes: { | ||
initial: { | ||
control: 'text', | ||
description: 'Initial character displayed in avatar', | ||
}, | ||
size: { | ||
control: 'select', | ||
options: ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'], | ||
description: 'Size of the avatar', | ||
}, | ||
user: { | ||
control: 'select', | ||
options: [ | ||
'you', | ||
'collaborator-1', | ||
'collaborator-2', | ||
'collaborator-3', | ||
'collaborator-4', | ||
'collaborator-5', | ||
'collaborator-6', | ||
'collaborator-7', | ||
'collaborator-8', | ||
'collaborator-9', | ||
'collaborator-10', | ||
'collaborator-11', | ||
'jack', | ||
], | ||
description: 'User type to determine background color', | ||
}, | ||
color: { | ||
control: 'color', | ||
description: 'Custom background color', | ||
}, | ||
}, | ||
} satisfies Meta<typeof Avatar> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Avatar> | ||
|
||
export const Default: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'md', | ||
user: 'you', | ||
}, | ||
} | ||
|
||
export const ExtraExtraSmall: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'xxs', | ||
}, | ||
} | ||
|
||
export const ExtraSmall: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'xs', | ||
}, | ||
} | ||
|
||
export const Small: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'sm', | ||
}, | ||
} | ||
|
||
export const Medium: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'md', | ||
}, | ||
} | ||
|
||
export const Large: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'lg', | ||
}, | ||
} | ||
|
||
export const ExtraLarge: Story = { | ||
args: { | ||
initial: 'A', | ||
size: 'xl', | ||
}, | ||
} | ||
|
||
export const TwoExtraLarge: Story = { | ||
args: { | ||
initial: 'A', | ||
size: '2xl', | ||
}, | ||
} | ||
|
||
export const Collaborator1: Story = { | ||
args: { | ||
initial: 'B', | ||
user: 'collaborator-1', | ||
}, | ||
} | ||
|
||
export const Collaborator2: Story = { | ||
args: { | ||
initial: 'C', | ||
user: 'collaborator-2', | ||
}, | ||
} | ||
|
||
export const Collaborator3: Story = { | ||
args: { | ||
initial: 'D', | ||
user: 'collaborator-3', | ||
}, | ||
} | ||
|
||
export const Jack: Story = { | ||
args: { | ||
initial: 'J', | ||
user: 'jack', | ||
}, | ||
} | ||
|
||
export const CustomColor: Story = { | ||
args: { | ||
initial: 'X', | ||
color: '#ff6b6b', | ||
}, | ||
} |
68 changes: 68 additions & 0 deletions
68
frontend/packages/ui/src/components/Callout/Callout.stories.tsx
junkisai marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,68 @@ | ||
import type { Meta, StoryObj } from '@storybook/nextjs' | ||
import { Callout } from './Callout' | ||
|
||
const meta = { | ||
component: Callout, | ||
argTypes: { | ||
variant: { | ||
control: 'select', | ||
options: ['default', 'danger', 'success', 'info', 'warning'], | ||
description: 'The visual style of the callout', | ||
}, | ||
device: { | ||
control: 'select', | ||
options: ['default', 'mobile'], | ||
description: 'Device-specific styling', | ||
}, | ||
children: { | ||
control: 'text', | ||
description: 'Content to display in the callout', | ||
}, | ||
}, | ||
} satisfies Meta<typeof Callout> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof Callout> | ||
|
||
export const Default: Story = { | ||
args: { | ||
variant: 'default', | ||
children: 'This is a default callout message.', | ||
}, | ||
} | ||
|
||
export const Danger: Story = { | ||
args: { | ||
variant: 'danger', | ||
children: 'This is a danger callout message.', | ||
}, | ||
} | ||
|
||
export const Success: Story = { | ||
args: { | ||
variant: 'success', | ||
children: 'This is a success callout message.', | ||
}, | ||
} | ||
|
||
export const Info: Story = { | ||
args: { | ||
variant: 'info', | ||
children: 'This is an info callout message.', | ||
}, | ||
} | ||
|
||
export const Warning: Story = { | ||
args: { | ||
variant: 'warning', | ||
children: 'This is a warning callout message.', | ||
}, | ||
} | ||
|
||
export const LongContent: Story = { | ||
args: { | ||
variant: 'info', | ||
children: | ||
'This is a callout with a longer message to demonstrate how the component handles multiple lines of text. The content should wrap properly and maintain good readability.', | ||
}, | ||
} |
47 changes: 47 additions & 0 deletions
47
frontend/packages/ui/src/components/Collapsible/Collapsible.stories.tsx
junkisai marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,47 @@ | ||
import type { Meta, StoryObj } from '@storybook/nextjs' | ||
import { useState } from 'react' | ||
import { Button } from '../Button' | ||
import { | ||
CollapsibleContent, | ||
CollapsibleRoot, | ||
CollapsibleTrigger, | ||
} from './Collapsible' | ||
|
||
const CollapsibleExample = () => { | ||
const [open, setOpen] = useState(false) | ||
|
||
return ( | ||
<CollapsibleRoot open={open} onOpenChange={setOpen}> | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}> | ||
<CollapsibleTrigger asChild> | ||
<Button>{open ? 'Hide' : 'Show'} Details</Button> | ||
</CollapsibleTrigger> | ||
<CollapsibleContent> | ||
<div style={{ padding: '16px', background: '#f0f0f0' }}> | ||
This is the collapsible content. It can contain any React elements. | ||
You can add more content here as needed. | ||
</div> | ||
</CollapsibleContent> | ||
</div> | ||
</CollapsibleRoot> | ||
) | ||
} | ||
|
||
const meta = { | ||
component: CollapsibleRoot, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'A Radix UI Collapsible wrapper. Use CollapsibleRoot, CollapsibleTrigger, and CollapsibleContent together to create collapsible sections.', | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof CollapsibleRoot> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof CollapsibleRoot> | ||
|
||
export const Default: Story = { | ||
render: () => <CollapsibleExample />, | ||
} |
60 changes: 60 additions & 0 deletions
60
frontend/packages/ui/src/components/ContextMenu/ContextMenu.stories.tsx
junkisai marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,60 @@ | ||
import type { Meta, StoryObj } from '@storybook/nextjs' | ||
import { ContextMenu } from './ContextMenu' | ||
|
||
const meta = { | ||
component: ContextMenu, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'Right-click on the trigger element to open the context menu.', | ||
}, | ||
}, | ||
}, | ||
} satisfies Meta<typeof ContextMenu> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof ContextMenu> | ||
|
||
export const Default: Story = { | ||
args: { | ||
TriggerElement: ( | ||
<div | ||
style={{ | ||
border: '1px solid #ccc', | ||
padding: '20px', | ||
borderRadius: '4px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
Right-click here | ||
</div> | ||
), | ||
ContextMenuElement: <span>Menu Item</span>, | ||
onClick: () => {}, | ||
}, | ||
} | ||
|
||
export const WithIcon: Story = { | ||
args: { | ||
TriggerElement: ( | ||
<div | ||
style={{ | ||
border: '1px solid #ccc', | ||
padding: '20px', | ||
borderRadius: '4px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
Right-click to see icon menu | ||
</div> | ||
), | ||
ContextMenuElement: ( | ||
<div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}> | ||
<span>🔧</span> | ||
<span>Settings</span> | ||
</div> | ||
), | ||
onClick: () => {}, | ||
}, | ||
} |
31 changes: 31 additions & 0 deletions
31
frontend/packages/ui/src/components/CookieConsent/CookieConsent.stories.tsx
junkisai marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,31 @@ | ||
import type { Meta, StoryObj } from '@storybook/nextjs' | ||
import { CookieConsent } from './CookieConsent' | ||
|
||
const meta = { | ||
component: CookieConsent, | ||
argTypes: { | ||
open: { | ||
control: 'boolean', | ||
description: 'Whether the cookie consent banner is visible', | ||
}, | ||
}, | ||
} satisfies Meta<typeof CookieConsent> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof CookieConsent> | ||
|
||
export const Open: Story = { | ||
args: { | ||
open: true, | ||
onClickAccept: () => {}, | ||
onClickDeny: () => {}, | ||
}, | ||
} | ||
|
||
export const Closed: Story = { | ||
args: { | ||
open: false, | ||
onClickAccept: () => {}, | ||
onClickDeny: () => {}, | ||
}, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.