-
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.
- Loading branch information
Showing
30 changed files
with
4,753 additions
and
348 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,18 @@ | ||
import {Controls, Description, Primary, Subtitle, Title} from '@storybook/blocks' | ||
import React from 'react' | ||
|
||
/** | ||
* Customised docs page with `<Stories>` removed. | ||
* https://storybook.js.org/docs/react/writing-docs/autodocs#customize-the-docs-container | ||
*/ | ||
export const DocsPage = () => { | ||
return ( | ||
<> | ||
<Title /> | ||
<Subtitle /> | ||
<Description /> | ||
<Primary /> | ||
<Controls /> | ||
</> | ||
) | ||
} |
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,44 @@ | ||
import {DecoratorHelpers} from '@storybook/addon-themes' | ||
import {StoryFn} from '@storybook/react' | ||
import {themes as storybookThemes} from '@storybook/theming' | ||
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}; | ||
/* Optionally use storybook's dark mode background color */ | ||
/* background-color: ${storybookThemes.dark.appBg}; */ | ||
} | ||
` | ||
|
||
/** | ||
* 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,33 @@ | ||
import type {Preview} from '@storybook/react' | ||
import {themes} from '@storybook/theming' | ||
import {DocsPage} from './components/DocsPage' | ||
import {withSanityTheme} from './components/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: { | ||
page: DocsPage, | ||
theme: { | ||
...themes.dark, | ||
fontBase: 'Inter, sans-serif', | ||
}, | ||
}, | ||
layout: 'fullscreen', | ||
}, | ||
} | ||
|
||
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.