forked from Uniswap/interface
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(storybook): first pass at storybook integration
- Loading branch information
1 parent
db88693
commit 619c7c2
Showing
8 changed files
with
4,901 additions
and
68 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 @@ | ||
lts/* |
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,16 @@ | ||
const { dirname, join, parse, resolve } = require('path') | ||
const { existsSync } = require('fs') | ||
|
||
module.exports = { | ||
stories: ['../src/**/*.stories.@(ts|tsx)'], | ||
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/preset-create-react-app'], | ||
typescript: { | ||
check: true, | ||
checkOptions: {}, | ||
reactDocgen: 'react-docgen-typescript', | ||
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,4 @@ | ||
import { addons } from '@storybook/addons' | ||
import { light } from './theme' | ||
|
||
addons.setConfig({ theme: light }) |
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 { ThemeProvider as SCThemeProvider } from 'styled-components' | ||
import { Story } from '@storybook/react/types-6-0' | ||
import React from 'react' | ||
import { FixedGlobalStyle, theme, ThemedGlobalStyle } from '../src/theme' | ||
import * as storybookThemes from './theme' | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
dependencies: { | ||
withStoriesOnly: true, | ||
hideEmpty: true | ||
}, | ||
docs: { | ||
theme: storybookThemes.light | ||
}, | ||
viewport: { | ||
viewports: { | ||
mobile: { | ||
name: 'iPhone X', | ||
styles: { | ||
width: '375px', | ||
height: '812px' | ||
} | ||
}, | ||
tablet: { | ||
name: 'iPad', | ||
styles: { | ||
width: '768px', | ||
height: '1024px' | ||
} | ||
}, | ||
laptop: { | ||
name: 'Laptop', | ||
styles: { | ||
width: '1024px', | ||
height: '768px' | ||
} | ||
}, | ||
desktop: { | ||
name: 'Desktop', | ||
styles: { | ||
width: '1440px', | ||
height: '1024px' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const globalTypes = { | ||
theme: { | ||
name: 'Theme', | ||
description: 'Global theme for components', | ||
defaultValue: 'light', | ||
toolbar: { | ||
icon: 'circlehollow', | ||
items: ['light', 'dark'] | ||
} | ||
} | ||
} | ||
|
||
const withProviders = (Component: Story, context: Record<string, any>) => { | ||
const THEME = theme(context.globals.theme === 'dark') | ||
return ( | ||
<> | ||
<FixedGlobalStyle /> | ||
<SCThemeProvider theme={THEME}> | ||
<ThemedGlobalStyle /> | ||
<main> | ||
<Component /> | ||
</main> | ||
</SCThemeProvider> | ||
</> | ||
) | ||
} | ||
|
||
export const decorators = [withProviders] |
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,17 @@ | ||
import { create } from '@storybook/theming' | ||
|
||
// this themes the storybook UI | ||
const uniswapBaseTheme = { | ||
brandTitle: 'Uniswap Design', | ||
brandUrl: 'https://uniswap.org', | ||
brandImage: 'https://ipfs.io/ipfs/QmNa8mQkrNKp1WEEeGjFezDmDeodkWRevGFN8JCV7b4Xir' | ||
} | ||
export const light = create({ | ||
base: 'light', | ||
...uniswapBaseTheme | ||
}) | ||
|
||
// export const dark = create({ | ||
// base: 'dark', | ||
// ...uniswapBaseTheme, | ||
// }) |
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,153 @@ | ||
import { Story } from '@storybook/react/types-6-0' | ||
import styled from 'styled-components' | ||
import React from 'react' | ||
import { | ||
ButtonConfirmed, | ||
ButtonDropdown, | ||
ButtonDropdownGrey, | ||
ButtonDropdownLight, | ||
ButtonEmpty, | ||
ButtonError, | ||
ButtonGray, | ||
ButtonLight, | ||
ButtonOutlined, | ||
ButtonPink, | ||
ButtonPrimary, | ||
ButtonRadio, | ||
ButtonSecondary, | ||
ButtonUNIGradient, | ||
ButtonWhite | ||
} from './index' | ||
|
||
const wrapperCss = styled.main` | ||
font-size: 2em; | ||
margin: 3em; | ||
max-width: 300px; | ||
` | ||
|
||
export default { | ||
title: 'Buttons', | ||
argTypes: { | ||
disabled: { control: { type: 'boolean' } }, | ||
onClick: { action: 'clicked' } | ||
}, | ||
decorators: [ | ||
(Component: Story) => ( | ||
<div css={wrapperCss}> | ||
<Component /> | ||
</div> | ||
) | ||
] | ||
} | ||
|
||
const Unicorn = () => ( | ||
<span role="img" aria-label="unicorn"> | ||
🦄 | ||
</span> | ||
) | ||
|
||
export const Radio = () => ( | ||
<ButtonRadio> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonRadio> | ||
) | ||
export const DropdownLight = () => ( | ||
<ButtonDropdownLight> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonDropdownLight> | ||
) | ||
export const DropdownGrey = () => ( | ||
<ButtonDropdownGrey> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonDropdownGrey> | ||
) | ||
export const Dropdown = () => ( | ||
<ButtonDropdown> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonDropdown> | ||
) | ||
export const Error = () => ( | ||
<ButtonError> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonError> | ||
) | ||
export const Confirmed = () => ( | ||
<ButtonConfirmed> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonConfirmed> | ||
) | ||
export const White = () => ( | ||
<ButtonWhite> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonWhite> | ||
) | ||
export const Empty = () => ( | ||
<ButtonEmpty> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonEmpty> | ||
) | ||
export const Outlined = () => ( | ||
<ButtonOutlined> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonOutlined> | ||
) | ||
export const UNIGradient = () => ( | ||
<ButtonUNIGradient> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonUNIGradient> | ||
) | ||
export const Pink = () => ( | ||
<ButtonPink> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonPink> | ||
) | ||
export const Secondary = () => ( | ||
<ButtonSecondary> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonSecondary> | ||
) | ||
export const Gray = () => ( | ||
<ButtonGray> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonGray> | ||
) | ||
export const Light = () => ( | ||
<ButtonLight> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonLight> | ||
) | ||
export const Primary = () => ( | ||
<ButtonPrimary> | ||
<Unicorn /> | ||
UNISWAP | ||
<Unicorn /> | ||
</ButtonPrimary> | ||
) |
Oops, something went wrong.