-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 #360 from omnivore-app/OMN-SB
[OMN-SB]: Setup storybook
- Loading branch information
Showing
6 changed files
with
149 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require('path') | ||
|
||
module.exports = { | ||
stories: [ | ||
"../stories/**/*.stories.mdx", | ||
"../stories/**/*.stories.@(js|jsx|ts|tsx)" | ||
], | ||
addons: [ | ||
"@storybook/addon-links", | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-interactions", | ||
"storybook-addon-next-router" | ||
], | ||
framework: "@storybook/react", | ||
core: { | ||
builder: "webpack5" | ||
}, | ||
typescript: { | ||
reactDocgen: false | ||
}, | ||
webpackFinal: async (config, { configType }) => { | ||
config.resolve.roots = [ | ||
path.resolve(__dirname, '../public'), | ||
'node_modules', | ||
]; | ||
|
||
// Return the altered config | ||
return 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,42 @@ | ||
import { RouterContext } from 'next/dist/shared/lib/router-context'; | ||
import * as NextImage from 'next/image'; | ||
import { getCssText } from '../components/tokens/stitches.config'; | ||
import "../styles/globals.css"; | ||
|
||
const OriginalNextImage = NextImage.default; | ||
|
||
Object.defineProperty(NextImage, 'default', { | ||
configurable: true, | ||
value: props => <OriginalNextImage {...props} unoptimized /> | ||
}) | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
nextRouter: { | ||
Provider: RouterContext.Provider | ||
} | ||
} | ||
|
||
export const decorators = [ | ||
(Story, context) => { | ||
return ( | ||
<> | ||
<style | ||
id="stitches" | ||
dangerouslySetInnerHTML={{ | ||
__html: getCssText(), | ||
}} | ||
/> | ||
<div className='Gray'> | ||
<Story {...context} /> | ||
</div> | ||
</> | ||
); | ||
} | ||
] |
Empty file.
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,53 @@ | ||
import { ComponentStory, ComponentMeta } from '@storybook/react' | ||
import { Toaster, ToastPosition } from 'react-hot-toast' | ||
import { showErrorToast, showSuccessToast } from '../lib/toastHelpers' | ||
import { Button } from '../components/elements/Button' | ||
|
||
export default { | ||
title: 'Components/Snackbar', | ||
component: Toaster, | ||
argTypes: { | ||
position: { | ||
description: 'The position of the snackbar', | ||
options: [ | ||
'top-left', | ||
'top-center', | ||
'top-right', | ||
'bottom-right', | ||
'bottom-center', | ||
'bottom-left', | ||
], | ||
control: { type: 'select' }, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof Toaster> | ||
|
||
const Template = ({ showToast, position }: { showToast: () => void; position?: ToastPosition }) => ( | ||
<div> | ||
<Toaster position={position} /> | ||
<div | ||
style={{ | ||
height: '15rem', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<Button style='ctaGray' onClick={showToast}> | ||
Show Toast | ||
</Button> | ||
</div> | ||
</div> | ||
) | ||
|
||
export const SuccessSnackbar: ComponentStory<typeof Toaster> = (args: any) => { | ||
return ( | ||
<Template {...args} showToast={() => showSuccessToast('Success Message')} /> | ||
) | ||
} | ||
|
||
export const ErrorSnackbar: ComponentStory<typeof Toaster> = (args: any) => { | ||
return ( | ||
<Template {...args} showToast={() => showErrorToast('Error Message!')} /> | ||
) | ||
} |
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
04708ad
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:
omnivore-demo – ./
web-demo.omnivore.app
omnivore-demo.vercel.app
omnivore-demo-omnivore.vercel.app
omnivore-demo-git-main-omnivore.vercel.app
demo.omnivore.app
04708ad
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:
omnivore-prod – ./
omnivore-prod-git-main-omnivore.vercel.app
omnivore-prod-omnivore.vercel.app
omnivore-web-mu.vercel.app
omnivore.app
web-prod.omnivore.app
web-dev.omnivore.app