-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce component storybooks (#73)
* feat: basic button story * feat: basic checkbox story * feat: basic input story * chore: update settings.json source.fixAll.eslint with latest vscode version * chore: reduce stories layer * chore: use render instead of decorator * fix: next/font in storybook * chore: remove default addons included in essentials * chore: set default story sorting to alphabetical * chore: tsconfig ignore .next * chore: upgrade storybook to latest * refactor: button storybook remove unused vars * refactor: checkbox story add default args * feat: command story * feat: corelayout story * feat: heading story * feat: input story * feat: lockctaoverlay story * feat: logo story * feat: mobileheader story * feat: modal story * feat: popover story * feat: ratingsection story * feat: reviewitem story * feat: sidebar story * feat: sidebaritem story * feat: statitem story * feat: tag story * feat: reviews combobox story * chore: yarn clean up * chore: add chromatic ci action for storybooks * chore: chromatic action with env vars * chore: update chromatic ci action options * refactor: import used as type only * chore: remove layout stories * chore: remove unused comments --------- Co-authored-by: Zachery Ng <zachery.ng@gmail.com>
- Loading branch information
Showing
27 changed files
with
9,631 additions
and
1,175 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,34 @@ | ||
name: "Chromatic" | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
chromatic: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: copy .env file | ||
run: cp .env.example .env | ||
|
||
- name: Install dependencies | ||
run: yarn install --immutable --immutable-cache --check-cache | ||
|
||
- name: Publish to Chromatic | ||
uses: chromaui/action@latest | ||
with: | ||
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | ||
onlyChanged: true | ||
exitOnceUploaded: true | ||
autoAcceptChanges: main | ||
fromCI: true | ||
# Skip running Chromatic on dependabot PRs | ||
skip: dependabot/** |
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,20 @@ | ||
import type { StorybookConfig } from "@storybook/nextjs"; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: ["@storybook/addon-essentials", "@storybook/addon-themes"], | ||
framework: { | ||
name: "@storybook/nextjs", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: true, | ||
}, | ||
staticDirs: [ | ||
{ | ||
from: "../public", | ||
to: "public", | ||
}, | ||
], | ||
}; | ||
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,55 @@ | ||
import type { Preview, StoryFn } from "@storybook/react"; | ||
import { withThemeByClassName } from "@storybook/addon-themes"; | ||
import "../src/common/styles/globals.scss"; | ||
import { inter, poppins } from "../src/common/fonts"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
// actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
layout: "fullscreen", | ||
options: { | ||
storySort: { | ||
method: "alphabetical", | ||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(Story: StoryFn) => ( | ||
<> | ||
{/* @ts-ignore */} | ||
<style global jsx>{` | ||
:root { | ||
--font-inter: ${inter.style.fontFamily}; | ||
--font-poppins: ${poppins.style.fontFamily}; | ||
} | ||
`}</style> | ||
<div | ||
style={{ | ||
padding: "3rem", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
}} | ||
className={`bg-bg-base`} | ||
> | ||
<Story /> | ||
</div> | ||
</> | ||
), | ||
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
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,167 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Button } from "./Button"; | ||
import { StarLineAltIcon } from "@/common/components/CustomIcon"; | ||
|
||
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export | ||
const meta = { | ||
title: "Common/Button", | ||
component: Button, | ||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs | ||
tags: ["autodocs"], | ||
// More on argTypes: https://storybook.js.org/docs/api/argtypes | ||
argTypes: { | ||
fullWidth: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
loading: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
rounded: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
}, | ||
args: { | ||
variant: "primary", | ||
size: "md", | ||
children: "primary", | ||
as: "a", | ||
href: "https://example.com", | ||
external: true, | ||
loading: false, | ||
isResponsive: false, | ||
fullWidth: false, | ||
rounded: false, | ||
}, | ||
} satisfies Meta<typeof Button>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; | ||
|
||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args | ||
const VariantsOfButtonTemplate: Story = { | ||
render: ({ variant }) => ( | ||
<div className="flex max-w-[320px] flex-wrap gap-3"> | ||
<Button variant={variant}>{variant as string}</Button> | ||
<Button variant={variant} size="sm" iconLeft={<StarLineAltIcon />}> | ||
Small | ||
</Button> | ||
<Button | ||
variant={variant} | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
/> | ||
<Button | ||
variant={variant} | ||
size="sm" | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
/> | ||
<Button variant={variant} loading> | ||
{variant as string} | ||
</Button> | ||
<Button | ||
variant={variant} | ||
size="sm" | ||
iconLeft={<StarLineAltIcon />} | ||
loading | ||
> | ||
Small | ||
</Button> | ||
<Button | ||
variant={variant} | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
loading | ||
/> | ||
<Button | ||
variant={variant} | ||
size="sm" | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
loading | ||
/> | ||
<Button variant={variant} disabled> | ||
{variant as string} | ||
</Button> | ||
<Button | ||
variant={variant} | ||
size="sm" | ||
iconLeft={<StarLineAltIcon />} | ||
disabled | ||
> | ||
Small | ||
</Button> | ||
<Button | ||
variant={variant} | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
disabled | ||
/> | ||
<Button | ||
variant={variant} | ||
size="sm" | ||
aria-label="star" | ||
iconLeft={<StarLineAltIcon />} | ||
disabled | ||
/> | ||
</div> | ||
), | ||
}; | ||
|
||
export const VariantsOfPrimary: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "primary", | ||
}, | ||
}; | ||
|
||
export const VariantsOfSecondary: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "secondary", | ||
}, | ||
}; | ||
|
||
export const VariantsOfTertiary: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "tertiary", | ||
}, | ||
}; | ||
|
||
export const VariantsOfSuccess: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "success", | ||
}, | ||
}; | ||
|
||
export const VariantsOfDanger: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "danger", | ||
}, | ||
}; | ||
|
||
export const VariantsOfGhost: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "ghost", | ||
}, | ||
}; | ||
|
||
export const VariantsOfLink: Story = { | ||
...VariantsOfButtonTemplate, | ||
args: { | ||
variant: "link", | ||
}, | ||
}; |
Oops, something went wrong.