-
Notifications
You must be signed in to change notification settings - Fork 0
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 #90 from bleu/joao/add-storybook
chore: add minimal storybook config
- Loading branch information
Showing
28 changed files
with
5,921 additions
and
217 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,5 @@ yalc.lock | |
.swc/ | ||
|
||
stats.html | ||
|
||
*storybook.log |
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,61 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
const path = require("path"); | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-webpack5-compiler-swc", | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@chromatic-com/storybook", | ||
"@storybook/addon-interactions", | ||
"@storybook/addon-styling-webpack", | ||
"@storybook/addon-themes", | ||
{ | ||
name: "@storybook/addon-styling-webpack", | ||
|
||
options: { | ||
rules: [ | ||
{ | ||
test: /\.css$/, | ||
sideEffects: true, | ||
use: [ | ||
require.resolve("style-loader"), | ||
{ | ||
loader: require.resolve("css-loader"), | ||
options: { | ||
importLoaders: 1, | ||
}, | ||
}, | ||
{ | ||
loader: require.resolve("postcss-loader"), | ||
options: { | ||
implementation: require.resolve("postcss"), | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: {}, | ||
}, | ||
webpackFinal: async (config, { configType }) => { | ||
config.resolve.alias = { | ||
...config.resolve.alias, | ||
"#/components": path.resolve(__dirname, "../src/components"), | ||
"#/lib": path.resolve(__dirname, "../src/lib"), | ||
"#/hooks": path.resolve(__dirname, "../src/hooks"), | ||
"#/locales": path.resolve(__dirname, "../src/locales"), | ||
"#/types": path.resolve(__dirname, "../src/types"), | ||
}; | ||
|
||
return config; | ||
}, | ||
}; | ||
|
||
export default config; |
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,51 @@ | ||
import type { Preview } from "@storybook/react"; | ||
import "../src/storybook.css"; | ||
import "tailwindcss/tailwind.css"; | ||
import { withThemeByClassName } from "@storybook/addon-themes"; | ||
import { ThemeProvider } from "../src/components/ThemeToggle"; | ||
import { Toaster } from "../src/components/ui/Toaster"; | ||
import React from "react"; | ||
import { themes } from "@storybook/theming"; | ||
import { darkUIStorybook, lightUIStorybook, commonTheme } from "./themes"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
darkMode: { | ||
classTarget: "html", | ||
stylePreview: true, | ||
darkClass: "dark", | ||
lightClass: "light", | ||
dark: { ...themes.dark, ...darkUIStorybook, ...commonTheme }, | ||
light: { ...themes.normal, ...lightUIStorybook, ...commonTheme }, | ||
current: "light", | ||
}, | ||
|
||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const decorators = [ | ||
(Story: React.FC) => ( | ||
<ThemeProvider> | ||
<div className="max-h-screen"> | ||
<Toaster /> | ||
<Story /> | ||
</div> | ||
</ThemeProvider> | ||
), | ||
withThemeByClassName({ | ||
themes: { | ||
light: "light", | ||
dark: "dark", | ||
}, | ||
defaultTheme: "light", | ||
}), | ||
]; | ||
|
||
export default preview; |
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,26 @@ | ||
export const darkUIStorybook = { | ||
colorPrimary: "hsl(210 40% 98%)", | ||
colorSecondary: "hsl(217.2 32.6% 17.5%)", | ||
appBg: "hsl(222.2 84% 4.9%)", | ||
appContentBg: "hsl(222.2 84% 4.9%)", | ||
appBorderColor: "hsl(217.2 32.6% 17.5%)", | ||
appBorderRadius: ".4rem", | ||
textColor: "hsl(210 40% 98%)", | ||
textInverseColor: "hsl(217.2 32.6% 17.5%)", | ||
barTextColor: "hsl(210 40% 98%)", | ||
barSelectedColor: "hsl(210 40% 98%)", | ||
barBg: "hsl(222.2 84% 4.9%)", | ||
inputBg: "hsl(217.2 32.6% 17.5%)", | ||
inputBorder: "hsl(217.2 32.6% 17.5%)", | ||
inputTextColor: "hsl(210 40% 98%)", | ||
inputBorderRadius: "0.4rem", | ||
}; | ||
|
||
export const lightUIStorybook = {}; | ||
|
||
export const commonTheme = { | ||
brandTitle: "Bleu UI", | ||
brandUrl: "https://bleu.builders", | ||
brandTarget: "_blank", | ||
brandImage: "https://github.com/bleu.png", | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import React from "react"; | ||
import { Avatar, AvatarFallback, AvatarImage } from "../components/ui/Avatar"; | ||
|
||
// meta | ||
const meta = { | ||
title: "Components/Avatar", | ||
render: () => ( | ||
<Avatar> | ||
<AvatarImage src="https://github.com/bleu.png" alt="avatar" /> | ||
<AvatarFallback>Bleu Builders</AvatarFallback> | ||
</Avatar> | ||
), | ||
tags: ["autodocs"], | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
} satisfies Meta<{}>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const AvatarWithImage: Story = { | ||
args: {}, | ||
render: () => ( | ||
<Avatar> | ||
<AvatarImage src="https://github.com/bleu.png" alt="avatar" /> | ||
<AvatarFallback>Avatar</AvatarFallback> | ||
</Avatar> | ||
), | ||
}; | ||
export const AvatarWithFallback: Story = { | ||
args: {}, | ||
render: () => ( | ||
<Avatar> | ||
<AvatarImage src="" alt="avatar" /> | ||
<AvatarFallback>bleu</AvatarFallback> | ||
</Avatar> | ||
), | ||
}; |
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,105 @@ | ||
import React from "react"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { Badge, BadgeProps } from "../components/ui/Badge"; | ||
// meta | ||
const meta = { | ||
title: "Components/Badge", | ||
render: (args) => <Badge {...args}>{args.children}</Badge>, | ||
tags: ["autodocs"], | ||
args: { | ||
color: "primary", | ||
outline: "none", | ||
size: "md", | ||
children: "text", | ||
}, | ||
argTypes: { | ||
color: { | ||
control: { type: "select" }, | ||
options: ["primary", "secondary", "success", "destructive", "pending"], | ||
}, | ||
outline: { | ||
control: { type: "select" }, | ||
options: ["none", "outline"], | ||
}, | ||
size: { | ||
control: { type: "select" }, | ||
options: ["xs", "sm", "md", "lg"], | ||
}, | ||
}, | ||
|
||
parameters: { | ||
layout: "centered", | ||
}, | ||
} satisfies Meta<BadgeProps>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
// colors | ||
export const Default: Story = { | ||
args: { | ||
color: "primary", | ||
}, | ||
}; | ||
export const Secondary: Story = { | ||
args: { | ||
color: "secondary", | ||
}, | ||
}; | ||
|
||
export const Destructive: Story = { | ||
args: { | ||
color: "destructive", | ||
}, | ||
}; | ||
|
||
export const Pending: Story = { | ||
args: { | ||
color: "pending", | ||
}, | ||
}; | ||
|
||
// sizes | ||
|
||
export const Xs: Story = { | ||
args: { | ||
size: "xs", | ||
}, | ||
}; | ||
|
||
export const Sm: Story = { | ||
args: { | ||
size: "sm", | ||
}, | ||
}; | ||
|
||
export const Md: Story = { | ||
args: { | ||
size: "md", | ||
}, | ||
}; | ||
|
||
export const Lg: Story = { | ||
args: { | ||
size: "lg", | ||
}, | ||
}; | ||
|
||
// outline | ||
|
||
export const OutlineBadge: Story = { | ||
args: { | ||
outline: "outline", | ||
}, | ||
}; | ||
|
||
// link | ||
|
||
export const LinkWithStyleBadge: Story = { | ||
render: ({ color, outline, size, children }) => ( | ||
<Badge color={color} outline={outline} size={size}> | ||
{children} | ||
</Badge> | ||
), | ||
}; |
Oops, something went wrong.