-
-
Notifications
You must be signed in to change notification settings - Fork 750
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: storybook setup, chromatic setup and typography stories #3015
Changes from all commits
b918193
a111d63
9d73b60
08f4cfd
1fca89c
06683d8
fbd3fac
5d1eeb6
2dd1848
397b277
b819469
1ca5032
b4b240c
4d71250
96e466f
ae10eb7
4aa483e
1ded72b
91a3c5b
828d4bb
e1e5a2f
36766ed
4373a18
fa87688
0d29b55
aee9ad8
3cf06f8
e8c54e1
569dc20
9359a2d
50c7ee6
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { StorybookConfig } from "@storybook/nextjs"; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
"../components/**/*.stories.@(js|jsx|mjs|ts|tsx)", | ||
], | ||
addons: [ | ||
"@storybook/addon-onboarding", | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
], | ||
docs: { | ||
defaultName: 'Documentation', | ||
}, | ||
framework: { | ||
name: "@storybook/nextjs", | ||
options: {}, | ||
}, | ||
staticDirs: ["../public"], | ||
}; | ||
export default config; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import "../styles/globals.css"; | ||
import type { Preview } from "@storybook/react"; | ||
import { | ||
Title, | ||
Subtitle, | ||
Description, | ||
Primary, | ||
Controls, | ||
Stories, | ||
} from '@storybook/blocks'; | ||
|
||
const preview: Preview = { | ||
tags: ['autodocs'], | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
docs: { | ||
toc: { | ||
title: 'Table of contents', | ||
}, | ||
page: () => ( | ||
<> | ||
<Title /> | ||
<Subtitle /> | ||
<Description /> | ||
<Primary /> | ||
<Controls /> | ||
<Stories /> | ||
</> | ||
) | ||
} | ||
} | ||
}; | ||
|
||
export default preview; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { HeadingLevel, HeadingTypeStyle } from '@/types/typography/Heading'; | ||
|
||
import Heading from './Heading'; | ||
|
||
const meta: Meta<typeof Heading> = { | ||
title: 'Typography/Heading', | ||
component: Heading, | ||
argTypes: { | ||
level: { | ||
options: Object.values(HeadingLevel), | ||
control: { type: 'select' } | ||
}, | ||
typeStyle: { | ||
options: Object.values(HeadingTypeStyle), | ||
control: { type: 'select' } | ||
}, | ||
children: { | ||
control: { type: 'text' } | ||
}, | ||
className: { | ||
control: { type: 'text' } | ||
}, | ||
textColor: { | ||
table: { | ||
disable: true | ||
} | ||
}, | ||
id: { | ||
table: { | ||
disable: true | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Heading>; | ||
|
||
export const Headings: Story = { | ||
args: { | ||
level: HeadingLevel.h1, | ||
typeStyle: HeadingTypeStyle.lg, | ||
children: 'Quick brown fox jumps over the lazy dog' | ||
} | ||
}; | ||
|
||
export const HeadingsLevel = () => ( | ||
<> | ||
<Heading level={HeadingLevel.h1}>Heading 1</Heading> | ||
<Heading level={HeadingLevel.h2}>Heading 2</Heading> | ||
<Heading level={HeadingLevel.h3}>Heading 3</Heading> | ||
<Heading level={HeadingLevel.h4}>Heading 4</Heading> | ||
<Heading level={HeadingLevel.h5}>Heading 5</Heading> | ||
<Heading level={HeadingLevel.h6}>Heading 6</Heading> | ||
</> | ||
); | ||
|
||
export const HeadingsTypeStyle = () => ( | ||
<> | ||
<Heading typeStyle={HeadingTypeStyle.xl}>Heading XL</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.lg}>Heading LG</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.md}>Heading MD</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.mdSemibold}>Heading MD Semibold</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.sm}>Heading SM</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.smSemibold}>Heading SM Semibold</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.xs}>Heading XS</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.xsSemibold}>Heading XS Semibold</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.bodyLg}>Body LG</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.bodyMd}>Body MD</Heading> | ||
<Heading typeStyle={HeadingTypeStyle.bodySm}>Body SM</Heading> | ||
</> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { ParagraphTypeStyle } from '@/types/typography/Paragraph'; | ||
|
||
import Paragraph from './Paragraph'; | ||
|
||
const meta: Meta<typeof Paragraph> = { | ||
title: 'Typography/Paragraph', | ||
component: Paragraph, | ||
argTypes: { | ||
typeStyle: { | ||
options: Object.values(ParagraphTypeStyle), | ||
control: { type: 'select' } | ||
}, | ||
textColor: { | ||
control: { type: 'text' } | ||
}, | ||
fontWeight: { | ||
control: { type: 'text' } | ||
}, | ||
children: { | ||
control: { type: 'text' } | ||
}, | ||
className: { | ||
control: { type: 'text' } | ||
} | ||
} | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Paragraph>; | ||
|
||
export const Paragraphs: Story = { | ||
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. Are we using these objects/functions anywhere else? If not, then why are we exporting it? 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. No, we aren't using it manually. But storybook needs to have stories exported (Resource 1 | Resource 2). If we don't have stories exported they won't show up in the storybook. |
||
args: { | ||
typeStyle: ParagraphTypeStyle.lg, | ||
textColor: 'text-gray-700', | ||
fontWeight: '', | ||
children: 'Quick brown fox jumps over the lazy dog' | ||
} | ||
}; |
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.
Why there are no warnings for ESLint in these files for adding Jsdoc comments?
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 didn't get this point, I haven't added any JSDoc in this file.