-
Notifications
You must be signed in to change notification settings - Fork 148
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
feat: add Storybook #765
feat: add Storybook #765
Changes from all commits
ceb9a3c
b714102
798f72a
2cef312
de9d028
529a7fb
2d79832
d73cf05
428137f
2016012
4267d02
682b34c
d989d62
7b4f3b0
8bfdd9e
ddab7ad
12c9a5a
17fdee7
c20e38c
7be8e51
4f01a1d
a0e8460
eaccd39
d09cf8f
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 |
---|---|---|
|
@@ -57,3 +57,6 @@ package-lock.json | |
# VitePress | ||
docs/.vitepress/cache | ||
docs/.vitepress/dist | ||
|
||
*storybook.log | ||
storybook-static/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { StorybookConfig } from '@storybook/react-vite'; | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'], | ||
addons: [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@chromatic-com/storybook', | ||
'@storybook/addon-interactions', | ||
'@storybook/addon-a11y', | ||
], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: {}, | ||
}, | ||
}; | ||
|
||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Preview } from '@storybook/react'; | ||
import '../src/styles.css'; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
layout: 'centered', | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
"coverage", | ||
"esm", | ||
"framegear", | ||
"dist", | ||
"site/docs/dist/" | ||
] | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Address } from './Address'; | ||
|
||
const meta = { | ||
title: 'Identity/Address', | ||
component: Address, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
args: { | ||
address: '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1', | ||
}, | ||
} satisfies Meta<typeof Address>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { Avatar } from './Avatar'; | ||
import { Badge } from './Badge'; | ||
import { OnchainKitProvider } from '../../OnchainKitProvider'; | ||
import { base } from 'viem/chains'; | ||
|
||
const meta = { | ||
title: 'Identity/Avatar', | ||
component: Avatar, | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<QueryClientProvider client={new QueryClient()}> | ||
<Story /> | ||
</QueryClientProvider> | ||
); | ||
}, | ||
], | ||
tags: ['autodocs'], | ||
args: { | ||
address: '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1', | ||
}, | ||
} satisfies Meta<typeof Avatar>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; | ||
|
||
export const Loading: Story = { | ||
args: { | ||
loadingComponent: <div>...</div>, | ||
}, | ||
}; | ||
|
||
export const Fallback: Story = { | ||
args: { | ||
address: '0x1234567891234567881234567891234567891234', | ||
defaultComponent: ( | ||
<div | ||
style={{ | ||
width: '32px', | ||
height: '32px', | ||
border: '3px solid red', | ||
borderRadius: '50%', | ||
}} | ||
/> | ||
), | ||
}, | ||
}; | ||
|
||
export const WithBadge: Story = { | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<QueryClientProvider client={new QueryClient()}> | ||
<OnchainKitProvider | ||
chain={base} | ||
schemaId="0xf8b05c79f090979bf4a80270aba232dff11a10d9ca55c4f88de95317970f0de9" | ||
> | ||
<Story /> | ||
</OnchainKitProvider> | ||
</QueryClientProvider> | ||
); | ||
}, | ||
], | ||
args: { | ||
children: <Badge />, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Badge } from './Badge'; | ||
|
||
const meta = { | ||
title: 'Identity/Badge', | ||
component: Badge, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof Badge>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { EthBalance } from './EthBalance'; | ||
import { WagmiProvider, createConfig, http } from 'wagmi'; | ||
import { baseSepolia } from 'viem/chains'; | ||
|
||
const wagmiConfig = createConfig({ | ||
chains: [baseSepolia], | ||
transports: { | ||
[baseSepolia.id]: http(), | ||
}, | ||
}); | ||
|
||
const meta = { | ||
title: 'Identity/EthBalance', | ||
component: EthBalance, | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={new QueryClient()}> | ||
<Story /> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
); | ||
}, | ||
], | ||
tags: ['autodocs'], | ||
args: { | ||
address: '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1', | ||
}, | ||
} satisfies Meta<typeof EthBalance>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { Name } from './Name'; | ||
|
||
const meta = { | ||
title: 'Identity/Name', | ||
component: Name, | ||
decorators: [ | ||
(Story) => { | ||
return ( | ||
<QueryClientProvider client={new QueryClient()}> | ||
<Story /> | ||
</QueryClientProvider> | ||
); | ||
}, | ||
], | ||
tags: ['autodocs'], | ||
args: { | ||
address: '0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1', | ||
sliced: false, | ||
}, | ||
} satisfies Meta<typeof Name>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; | ||
|
||
export const Sliced: Story = { | ||
args: { | ||
address: '0x1234567891234567881234567891234567891234', | ||
sliced: true, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ | |
} | ||
|
||
@tailwind utilities; | ||
@tailwind components; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this? @roushou We have not see the need to have those in a Tailwind application. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right it's not needed here. I added it because I'm used to have it and I often define custom classes in |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { SwapProvider } from './SwapProvider'; | ||
import { WagmiProvider, createConfig, http } from 'wagmi'; | ||
import { baseSepolia } from 'viem/chains'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { SwapButton } from './SwapButton'; | ||
import { fn } from '@storybook/test'; | ||
|
||
const wagmiConfig = createConfig({ | ||
chains: [baseSepolia], | ||
transports: { | ||
[baseSepolia.id]: http(), | ||
}, | ||
}); | ||
|
||
const meta = { | ||
title: 'Swap/Button', | ||
decorators: [ | ||
(Story) => ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={new QueryClient()}> | ||
<SwapProvider address="0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1"> | ||
<Story /> | ||
</SwapProvider> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
), | ||
], | ||
component: SwapButton, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
className: { | ||
control: 'text', | ||
}, | ||
}, | ||
args: { | ||
disabled: true, | ||
onSubmit: fn(), | ||
}, | ||
} satisfies Meta<typeof SwapButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { SwapToggleButton } from './SwapToggleButton'; | ||
import { SwapProvider } from './SwapProvider'; | ||
import { WagmiProvider, createConfig, http } from 'wagmi'; | ||
import { baseSepolia } from 'viem/chains'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
||
const wagmiConfig = createConfig({ | ||
chains: [baseSepolia], | ||
transports: { | ||
[baseSepolia.id]: http(), | ||
}, | ||
}); | ||
|
||
const meta = { | ||
title: 'Swap/ToggleButton', | ||
decorators: [ | ||
(Story) => ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={new QueryClient()}> | ||
<SwapProvider address="0x02feeb0AdE57b6adEEdE5A4EEea6Cf8c21BeB6B1"> | ||
<Story /> | ||
</SwapProvider> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
), | ||
], | ||
component: SwapToggleButton, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof SwapToggleButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { fn } from '@storybook/test'; | ||
import { SearchIcon } from './SearchIcon'; | ||
|
||
const meta = { | ||
title: 'Token/SearchIcon', | ||
component: SearchIcon, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
args: { onClick: fn() }, | ||
} satisfies Meta<typeof SearchIcon>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Basic: Story = {}; |
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.
Should we move this to preview.ts as well?
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.
I'd favor explicitness because:
QueryClientProvider
More verbose but it's clear what's needed when reading stories.