-
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 #2 from julio-salas03/jcs/add-storybook
Add storybook
- Loading branch information
Showing
7 changed files
with
119 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
node_modules | ||
|
||
# build | ||
dist | ||
dist | ||
*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,20 @@ | ||
import type { StorybookConfig } from '@storybook/react-vite'; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
'../stories/**/*.mdx', | ||
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)', | ||
], | ||
addons: [ | ||
'@storybook/addon-onboarding', | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@chromatic-com/storybook', | ||
'@storybook/addon-interactions', | ||
], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: {}, | ||
}, | ||
}; | ||
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,14 @@ | ||
import type { Preview } from '@storybook/react'; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { SplitText, SplitTextProps } from './../src/index'; | ||
import { Resizable } from 'react-resizable/'; | ||
import 'react-resizable/css/styles.css'; | ||
|
||
const meta: Meta<typeof SplitText> = { | ||
component: SplitText, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof SplitText>; | ||
|
||
const Component = ({ children, ...rest }: SplitTextProps) => { | ||
const [size, setSize] = React.useState({ width: 300, height: 400 }); | ||
return ( | ||
<> | ||
<Resizable | ||
height={size.height} | ||
width={size.width} | ||
onResize={(_, { size }) => setSize(size)} | ||
> | ||
<div | ||
className="box" | ||
style={{ | ||
width: size.width + 'px', | ||
height: size.height + 'px', | ||
border: 'solid red 4px', | ||
padding: '10px', | ||
}} | ||
> | ||
<SplitText {...rest}>{children}</SplitText> | ||
</div> | ||
</Resizable> | ||
</> | ||
); | ||
}; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
children: | ||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac urna hendrerit, aliquet quam eget, faucibus lectus.', | ||
}, | ||
render: props => <Component {...props} />, | ||
}; |
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