-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add storybook * chore: add tooltip story with play function (#1139) * chore: add tooltip story with play function * fixup! chore: add tooltip story with play function * chore(storybook): add primitive stories, README, clean up storybook config, bump storybook deps * fixup! chore(storybook): add primitive stories, README, clean up storybook config, bump storybook deps * chore(storybook): update argType control overrides --------- Co-authored-by: Pedro Bonamin <[email protected]>
- Loading branch information
1 parent
877e678
commit 10aeb4a
Showing
34 changed files
with
5,775 additions
and
336 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,41 @@ | ||
import {DecoratorHelpers} from '@storybook/addon-themes' | ||
import {StoryFn} from '@storybook/react' | ||
import React from 'react' | ||
import {createGlobalStyle} from 'styled-components' | ||
import {Card} from '../../src/primitives' | ||
import {studioTheme, ThemeProvider} from '../../src/theme' | ||
|
||
const {initializeThemeState, pluckThemeFromContext, useThemeParameters} = DecoratorHelpers | ||
|
||
export const GlobalStyle = createGlobalStyle` | ||
body { | ||
background-color: ${({theme}) => theme.sanity.color.base.bg}; | ||
} | ||
` | ||
|
||
/** | ||
* Story decorator which wraps all stories in a Sanity <ThemeProvider> and passes the current theme | ||
* value defined in Story. | ||
* | ||
* Stories are also wrapped in a <Card> for layout. | ||
*/ | ||
|
||
export const withSanityTheme = ({themes, defaultTheme}) => { | ||
initializeThemeState(Object.keys(themes), defaultTheme) | ||
|
||
return (Story: StoryFn, context) => { | ||
const selectedTheme = pluckThemeFromContext(context) | ||
const {themeOverride} = useThemeParameters() | ||
|
||
const selected = themeOverride || selectedTheme || defaultTheme | ||
|
||
return ( | ||
<ThemeProvider scheme={selected} theme={studioTheme}> | ||
<GlobalStyle /> | ||
<Card padding={4}> | ||
<Story /> | ||
</Card> | ||
</ThemeProvider> | ||
) | ||
} | ||
} |
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,21 @@ | ||
import type {StorybookConfig} from '@storybook/react-vite' | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
addons: [ | ||
'@storybook/addon-a11y', | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-interactions', | ||
'@storybook/addon-storysource', | ||
'@storybook/addon-themes', | ||
], | ||
framework: { | ||
name: '@storybook/react-vite', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: 'tag', | ||
}, | ||
} | ||
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,30 @@ | ||
<style> | ||
@font-face { | ||
font-family: 'Inter'; | ||
font-style: normal; | ||
font-weight: 100 900; | ||
font-display: swap; | ||
src: url('https://rsms.me/inter/font-files/Inter-roman.var.woff2?v=3.19') format('woff2'); | ||
font-named-instance: 'Regular'; | ||
} | ||
@font-face { | ||
font-family: 'Inter'; | ||
font-style: italic; | ||
font-weight: 100 900; | ||
font-display: swap; | ||
src: url('https://rsms.me/inter/font-files/Inter-italic.var.woff2?v=3.19') format('woff2'); | ||
font-named-instance: 'Italic'; | ||
} | ||
html { | ||
-webkit-text-size-adjust: 100%; | ||
text-size-adjust: 100%; | ||
-webkit-tap-highlight-color: transparent; | ||
-webkit-font-smoothing: antialiased; | ||
} | ||
.sidebar-subheading { | ||
font-size: 13px !important; | ||
font-weight: 500 !important; | ||
letter-spacing: normal !important; | ||
text-transform: capitalize !important; | ||
} | ||
</style> |
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,11 @@ | ||
import {addons} from '@storybook/manager-api' | ||
import {themes} from '@storybook/theming' | ||
|
||
addons.setConfig({ | ||
theme: { | ||
...themes.dark, | ||
brandTitle: 'Sanity UI', | ||
fontBase: | ||
'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif', | ||
}, | ||
}) |
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,24 @@ | ||
<style> | ||
@font-face { | ||
font-family: 'Inter'; | ||
font-style: normal; | ||
font-weight: 100 900; | ||
font-display: swap; | ||
src: url('https://rsms.me/inter/font-files/Inter-roman.var.woff2?v=3.19') format('woff2'); | ||
font-named-instance: 'Regular'; | ||
} | ||
@font-face { | ||
font-family: 'Inter'; | ||
font-style: italic; | ||
font-weight: 100 900; | ||
font-display: swap; | ||
src: url('https://rsms.me/inter/font-files/Inter-italic.var.woff2?v=3.19') format('woff2'); | ||
font-named-instance: 'Italic'; | ||
} | ||
html { | ||
-webkit-text-size-adjust: 100%; | ||
text-size-adjust: 100%; | ||
-webkit-tap-highlight-color: transparent; | ||
-webkit-font-smoothing: antialiased; | ||
} | ||
</style> |
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,36 @@ | ||
import type {Preview} from '@storybook/react' | ||
import {themes} from '@storybook/theming' | ||
import {withSanityTheme} from './decorators/withSanityTheme.decorator' | ||
|
||
const preview: Preview = { | ||
decorators: [ | ||
withSanityTheme({ | ||
themes: {light: 'light', dark: 'dark'}, | ||
defaultTheme: 'dark', | ||
}), | ||
], | ||
parameters: { | ||
actions: {argTypesRegex: '^on[A-Z].*'}, | ||
backgrounds: {disable: true}, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
docs: { | ||
theme: { | ||
...themes.dark, | ||
fontBase: 'Inter, sans-serif', | ||
}, | ||
}, | ||
layout: 'fullscreen', | ||
options: { | ||
storySort: { | ||
order: ['primitives', 'components', '*'], | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
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
Oops, something went wrong.