generated from agustinusnathaniel/nextarter-chakra
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(storybook): setup storybook (#49)
* chore: init storybook * chore(storybook): configure storybook Ref: - storybookjs/storybook#13486 (comment) - emotion-js/emotion#971 * chore: update packages * chore: add ts config for sb, use webpack5 - https://storybook.js.org/docs/react/configure/typescript#mainjs-configuration - https://storybook.js.org/blog/storybook-for-webpack-5/ - https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade - storybookjs/storybook#15336 (comment) * chore: add shared components stories
- Loading branch information
1 parent
7704e2b
commit 805f082
Showing
16 changed files
with
9,229 additions
and
2,317 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const { TsconfigPathsPlugin } = require("tsconfig-paths-webpack-plugin"); | ||
|
||
const path = require("path"); | ||
const toPath = (_path) => path.join(process.cwd(), _path); | ||
|
||
/** @type {import('@storybook/react/types').StorybookConfig} */ | ||
module.exports = { | ||
core: { | ||
builder: "webpack5", | ||
}, | ||
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-toolbars", | ||
"@storybook/addon-a11y", | ||
"@storybook/addon-storysource", | ||
"storybook-addon-performance/register", | ||
], | ||
framework: "@storybook/react", | ||
webpackFinal: async (config) => { | ||
return { | ||
...config, | ||
resolve: { | ||
...config.resolve, | ||
alias: { | ||
...config.resolve.alias, | ||
"@emotion/core": toPath("node_modules/@emotion/react"), | ||
"emotion-theming": toPath("node_modules/@emotion/react"), | ||
}, | ||
plugins: [...(config.resolve.plugins ?? []), new TsconfigPathsPlugin()], | ||
}, | ||
}; | ||
}, | ||
typescript: { | ||
check: false, | ||
checkOptions: {}, | ||
reactDocgen: false, | ||
reactDocgenTypescriptOptions: { | ||
shouldExtractLiteralValuesFromEnum: true, | ||
propFilter: (prop) => | ||
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true, | ||
}, | ||
}, | ||
}; |
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 @@ | ||
import { create } from "@storybook/theming"; | ||
|
||
export default create({ | ||
base: "dark", | ||
brandTitle: "Spoker Storybook", | ||
brandURL: "https://storybook.spoker.sznm.dev", | ||
}); |
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 @@ | ||
import { addons } from "@storybook/addons"; | ||
|
||
import mainTheme from "./mainTheme"; | ||
|
||
addons.setConfig({ | ||
theme: mainTheme, | ||
}); |
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,77 @@ | ||
import { | ||
ChakraProvider, | ||
Flex, | ||
IconButton, | ||
useColorMode, | ||
useColorModeValue, | ||
} from "@chakra-ui/react"; | ||
import { Parameters, StoryContext } from "@storybook/react"; | ||
import * as React from "react"; | ||
import { FaMoon, FaSun } from "react-icons/fa"; | ||
import { withPerformance } from "storybook-addon-performance"; | ||
import "@fontsource/outfit/latin.css"; | ||
|
||
import customTheme from "../src/lib/styles/theme"; | ||
|
||
/** | ||
* Add global context for RTL-LTR switching | ||
*/ | ||
export const globalTypes = { | ||
direction: { | ||
name: "Direction", | ||
description: "Direction for layout", | ||
defaultValue: "LTR", | ||
toolbar: { | ||
icon: "globe", | ||
items: ["LTR", "RTL"], | ||
}, | ||
}, | ||
}; | ||
|
||
const ColorModeToggleBar = () => { | ||
const { toggleColorMode } = useColorMode(); | ||
const SwitchIcon = useColorModeValue(FaMoon, FaSun); | ||
const nextMode = useColorModeValue("dark", "light"); | ||
|
||
return ( | ||
<Flex justify="flex-end" mb={4}> | ||
<IconButton | ||
size="md" | ||
fontSize="lg" | ||
aria-label={`Switch to ${nextMode} mode`} | ||
variant="ghost" | ||
color="current" | ||
marginLeft="2" | ||
onClick={toggleColorMode} | ||
icon={<SwitchIcon />} | ||
/> | ||
</Flex> | ||
); | ||
}; | ||
|
||
const withChakra = (StoryFn: Function, context: StoryContext) => { | ||
const { direction } = context.globals; | ||
const dir = direction.toLowerCase(); | ||
|
||
return ( | ||
<ChakraProvider theme={customTheme}> | ||
<div dir={dir} id="story-wrapper" style={{ minHeight: "100vh" }}> | ||
<ColorModeToggleBar /> | ||
<StoryFn /> | ||
</div> | ||
</ChakraProvider> | ||
); | ||
}; | ||
|
||
export const parameters: Parameters = { | ||
options: { | ||
storySort: (a, b) => | ||
a[1].kind === b[1].kind | ||
? 0 | ||
: a[1].id.localeCompare(b[1].id, undefined, { numeric: true }), | ||
}, | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { expanded: true }, | ||
}; | ||
|
||
export const decorators = [withChakra, withPerformance]; |
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
19 changes: 19 additions & 0 deletions
19
src/lib/components/shared/SpokerButton/SpokerButton.stories.tsx
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,19 @@ | ||
import type { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
import SpokerButton from "./index"; | ||
|
||
export default { | ||
title: "shared/Button", | ||
component: SpokerButton, | ||
} as ComponentMeta<typeof SpokerButton>; | ||
|
||
const Template: ComponentStory<typeof SpokerButton> = (props) => ( | ||
<SpokerButton {...props} /> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
children: "Button", | ||
colorScheme: "blue", | ||
variant: "solid", | ||
}; |
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
src/lib/components/shared/SpokerInput/SpokerInput.stories.tsx
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,18 @@ | ||
import type { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
import SpokerInput from "./index"; | ||
|
||
export default { | ||
title: "shared/Input", | ||
component: SpokerInput, | ||
} as ComponentMeta<typeof SpokerInput>; | ||
|
||
const Template: ComponentStory<typeof SpokerInput> = (props) => ( | ||
<SpokerInput {...props} /> | ||
); | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
label: "Label", | ||
variant: "filled", | ||
}; |
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
src/lib/components/shared/SpokerLoading/SpokerLoading.stories.tsx
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,12 @@ | ||
import type { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
import SpokerLoading from "./index"; | ||
|
||
export default { | ||
title: "shared/LoadingScreen", | ||
component: SpokerLoading, | ||
} as ComponentMeta<typeof SpokerLoading>; | ||
|
||
const Template: ComponentStory<typeof SpokerLoading> = () => <SpokerLoading />; | ||
|
||
export const Default = Template.bind({}); |
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
src/lib/components/shared/SpokerRadioBox/SpokerRadioBox.stories.tsx
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,14 @@ | ||
import type { ComponentMeta, ComponentStory } from "@storybook/react"; | ||
|
||
import SpokerRadioBox from "./index"; | ||
|
||
export default { | ||
title: "shared/RadioBox", | ||
component: SpokerRadioBox, | ||
} as ComponentMeta<typeof SpokerRadioBox>; | ||
|
||
const Template: ComponentStory<typeof SpokerRadioBox> = (props) => ( | ||
<SpokerRadioBox {...props} /> | ||
); | ||
|
||
export const Default = Template.bind({}); |
File renamed without changes.
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,5 @@ | ||
import { Meta } from '@storybook/addon-docs'; | ||
|
||
<Meta title="Introduction" /> | ||
|
||
# Welcome to `Spoker` Storybook |
Oops, something went wrong.
805f082
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.
Successfully deployed to the following URLs:
spoker – ./
spoker.sznm.dev
spoker-git-main-sozonome.vercel.app
spoker.vercel.app
scrumpoker.sznm.dev
spoker-sozonome.vercel.app
805f082
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.
Successfully deployed to the following URLs:
spoker-storybook – ./
spoker-storybook-sozonome.vercel.app
spoker-storybook-git-main-sozonome.vercel.app
spoker-storybook.vercel.app