diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bbd575ef..a0bf95877 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: cache: pnpm node-version: lts/* - run: pnpm install - - run: pnpm ts:check + - run: pnpm typecheck - run: pnpm build lint: @@ -78,7 +78,7 @@ jobs: - uses: cypress-io/github-action@v6 with: build: pnpm workshop:build - start: pnpm workshop:start + start: pnpm workshop:preview wait-on: http://localhost:1337 env: NODE_OPTIONS: "--no-experimental-require-module --no-experimental-detect-module" diff --git a/.gitignore b/.gitignore index f0f23da9b..f3c4db550 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.log *.tgz .DS_Store diff --git a/.prettierignore b/.prettierignore index f036e9100..a90d9ba31 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,5 @@ +.next .workshop dist pnpm-lock.yaml +storybook-static diff --git a/.storybook/decorators/withSanityTheme.decorator.tsx b/.storybook/decorators/withSanityTheme.decorator.tsx deleted file mode 100644 index fe4de744c..000000000 --- a/.storybook/decorators/withSanityTheme.decorator.tsx +++ /dev/null @@ -1,42 +0,0 @@ -/* eslint-disable react-refresh/only-export-components */ - -import {Card, studioTheme, ThemeProvider} from '@sanity/ui' -import {DecoratorHelpers} from '@storybook/addon-themes' -import {StoryFn} from '@storybook/react' -import {createGlobalStyle} from 'styled-components' - -const {initializeThemeState, pluckThemeFromContext, useThemeParameters} = DecoratorHelpers - -export const GlobalStyle = createGlobalStyle` - body, - .docs-story { - background-color: ${({theme}) => theme.sanity.color.base.bg}; - } -` - -/** - * Story decorator which wraps all stories in a Sanity and passes the current theme - * value defined in Story. - * - * Stories are also wrapped in a 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 ( - - - - - - - ) - } -} diff --git a/.storybook/main.ts b/.storybook/main.ts deleted file mode 100644 index 928eeaa60..000000000 --- a/.storybook/main.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type {StorybookConfig} from '@storybook/react-vite' -import viteReact from '@vitejs/plugin-react' -import {mergeConfig} from 'vite' -import tsconfigPaths from 'vite-tsconfig-paths' - -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', - '@storybook/addon-mdx-gfm', - ], - framework: { - name: '@storybook/react-vite', - options: {}, - }, - docs: { - autodocs: 'tag', - }, - viteFinal(config) { - return mergeConfig(config, { - plugins: [ - viteReact({ - babel: {plugins: [['babel-plugin-react-compiler', {target: '19'}]]}, - }), - tsconfigPaths(), - ], - }) - }, -} -export default config diff --git a/.storybook/manager-head.html b/.storybook/manager-head.html deleted file mode 100644 index 1cc63fd04..000000000 --- a/.storybook/manager-head.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - diff --git a/.storybook/manager.ts b/.storybook/manager.ts deleted file mode 100644 index 4c7d8fcfc..000000000 --- a/.storybook/manager.ts +++ /dev/null @@ -1,11 +0,0 @@ -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', - }, -}) diff --git a/.storybook/preview-head.html b/.storybook/preview-head.html deleted file mode 100644 index 38a962c09..000000000 --- a/.storybook/preview-head.html +++ /dev/null @@ -1,73 +0,0 @@ - diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx deleted file mode 100644 index 3171e269a..000000000 --- a/.storybook/preview.tsx +++ /dev/null @@ -1,37 +0,0 @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..25fa6215f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/README.md b/README.md index 3c0ff928f..82d0a0199 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Sanity UI components. npm install @sanity/ui # Install peer dependencies -npm install react react-dom styled-components +npm install react react-dom react-is ``` [![npm version](https://img.shields.io/npm/v/@sanity/ui.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/ui) @@ -14,17 +14,15 @@ npm install react react-dom styled-components ## Usage ```jsx -import {Button, ThemeProvider} from '@sanity/ui' -import {buildTheme} from '@sanity/ui/theme' -import {createRoot} from 'react-dom/client' +import '@sanity/ui/css/index.css' -const root = createRoot(document.getElementById('root')) -const theme = buildTheme() +import {Button, Root} from '@sanity/ui' +import {createRoot} from 'react-dom/client' -root.render( - +createRoot(document).render( + - ))} - - - {tones.map(([title, tone]) => ( - - ))} - + + {BUTTON_MODES.map((mode) => ( + + {ELEMENT_TONES.map((tone) => ( + + ))} + + ))} ) diff --git a/src/core/primitives/button/__workshop__/customIcons.tsx b/src/core/primitives/button/__workshop__/customIcons.tsx index 29105c8d4..bfedee2fc 100644 --- a/src/core/primitives/button/__workshop__/customIcons.tsx +++ b/src/core/primitives/button/__workshop__/customIcons.tsx @@ -1,12 +1,12 @@ import {RocketIcon} from '@sanity/icons' import {Button, Flex, Inline} from '@sanity/ui' -export default function CustomIconsStory() { +export default function CustomIconsStory(): React.JSX.Element { return ( - -