-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade storybook and vite (#651)
Co-authored-by: Jake Laderman <[email protected]>
- Loading branch information
1 parent
a308e8d
commit 9314941
Showing
11 changed files
with
1,132 additions
and
4,117 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 |
---|---|---|
@@ -1,13 +1,22 @@ | ||
import { type StorybookConfig } from '@storybook/react-vite' | ||
|
||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
export default { | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
|
||
addons: [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-interactions', | ||
], | ||
|
||
core: { | ||
builder: '@storybook/builder-vite', | ||
}, | ||
|
||
framework: '@storybook/react-vite', | ||
} | ||
|
||
export default config | ||
// TODO: Enable if we need autodocs. Causes a CJS warning in vite | ||
// typescript: { | ||
// reactDocgen: 'react-docgen-typescript', | ||
// }, | ||
} as StorybookConfig |
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 |
---|---|---|
@@ -1,45 +1,73 @@ | ||
import * as jest from 'jest-mock' | ||
|
||
import { type Preview } from '@storybook/react' | ||
import { fn } from '@storybook/test' | ||
import { themes } from '@storybook/theming' | ||
|
||
import { DEFAULT_COLOR_MODE } from '../src/theme' | ||
import themeDecorator from '../src/ThemeDecorator' | ||
import { COLOR_MODES, DEFAULT_COLOR_MODE } from '../src/theme' | ||
|
||
// @ts-expect-error | ||
window.jest = jest | ||
// Copied from https://github.com/storybookjs/storybook/blob/v8.2.5/code/core/src/theming/utils.ts | ||
const { window: globalWindow } = global | ||
|
||
export const getPreferredColorScheme = () => { | ||
if (!globalWindow || !globalWindow.matchMedia) return 'light' | ||
|
||
const isDarkThemePreferred = globalWindow.matchMedia( | ||
'(prefers-color-scheme: dark)' | ||
).matches | ||
|
||
if (isDarkThemePreferred) return 'dark' | ||
|
||
return 'light' | ||
} | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
layout: 'fullscreen', | ||
actions: { argTypesRegex: '^on[A-Z].*' }, | ||
actions: { onClick: fn }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/, | ||
}, | ||
}, | ||
docs: { | ||
theme: themes.dark, | ||
}, | ||
options: { | ||
storySort: { | ||
order: ['Semantic System', '*'], | ||
}, | ||
}, | ||
}, | ||
|
||
globalTypes: { | ||
theme: { | ||
name: 'Toggle theme', | ||
description: 'Global theme for components', | ||
defaultValue: DEFAULT_COLOR_MODE, | ||
toolbar: { | ||
// The label to show for this toolbar item | ||
title: 'Theme', | ||
icon: 'circlehollow', | ||
// Array of plain string values or MenuItem shape (see below) | ||
items: COLOR_MODES, | ||
items: [ | ||
{ value: 'light', icon: 'circlehollow', title: 'Light' }, | ||
{ value: 'dark', icon: 'circle', title: 'Dark' }, | ||
], | ||
// Change title based on selected value | ||
dynamicTitle: true, | ||
showName: true, | ||
}, | ||
}, | ||
}, | ||
|
||
initialGlobals: { | ||
theme: DEFAULT_COLOR_MODE, | ||
}, | ||
|
||
decorators: [themeDecorator], | ||
|
||
// TODO: Enable if we need autodocs | ||
// tags: ['autodocs'], | ||
} | ||
|
||
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
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 |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
"version": "0.1.0", | ||
"description": "Pluralsh Design System", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"files": [ | ||
"dist/**/*", | ||
"src/**/*" | ||
], | ||
"scripts": { | ||
"start": "storybook dev -p 6006 -s public", | ||
"build:storybook": "yarn clean && storybook build -s public && yarn build:fix:storybook", | ||
"start": "storybook dev -p 6006", | ||
"build:storybook": "yarn clean && storybook build && yarn build:fix:storybook", | ||
"build:fix:storybook": "perl -pi -w -e 's/%40/@/g;' storybook-static/index.html", | ||
"storybook:serve-static": "yarn build:storybook && http-server storybook-static", | ||
"build": "npx tsc --declaration", | ||
|
@@ -75,17 +76,16 @@ | |
"@emotion/styled": "11.11.0", | ||
"@pluralsh/eslint-config-typescript": "2.5.147", | ||
"@react-types/shared": "3.22.0", | ||
"@storybook/addon-actions": "7.6.5", | ||
"@storybook/addon-docs": "7.6.5", | ||
"@storybook/addon-essentials": "7.6.5", | ||
"@storybook/addon-interactions": "7.6.5", | ||
"@storybook/addon-links": "7.6.5", | ||
"@storybook/addons": "7.6.17", | ||
"@storybook/builder-vite": "7.6.5", | ||
"@storybook/node-logger": "7.6.5", | ||
"@storybook/react": "7.6.5", | ||
"@storybook/react-vite": "7.6.5", | ||
"@storybook/testing-library": "0.2.2", | ||
"@storybook/addon-actions": "8.3.5", | ||
"@storybook/addon-docs": "8.3.5", | ||
"@storybook/addon-essentials": "8.3.5", | ||
"@storybook/addon-interactions": "8.3.5", | ||
"@storybook/addon-links": "8.3.5", | ||
"@storybook/builder-vite": "8.3.5", | ||
"@storybook/node-logger": "8.3.5", | ||
"@storybook/react": "8.3.5", | ||
"@storybook/react-vite": "8.3.5", | ||
"@storybook/theming": "8.3.5", | ||
"@testing-library/jest-dom": "5.17.0", | ||
"@types/chroma-js": "2.4.3", | ||
"@types/lodash-es": "4.17.12", | ||
|
@@ -94,6 +94,7 @@ | |
"@types/react-transition-group": "4.4.10", | ||
"@typescript-eslint/eslint-plugin": "6.14.0", | ||
"@typescript-eslint/parser": "6.14.0", | ||
"@vitejs/plugin-react": "4.3.2", | ||
"@vitest/coverage-v8": "1.0.4", | ||
"@vitest/ui": "1.0.4", | ||
"babel-loader": "9.1.3", | ||
|
@@ -103,7 +104,7 @@ | |
"eslint-plugin-import": "2.29.1", | ||
"eslint-plugin-import-newlines": "1.3.4", | ||
"eslint-plugin-jsx-a11y": "6.8.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"eslint-plugin-react": "7.33.2", | ||
"eslint-plugin-react-hooks": "4.6.0", | ||
"eslint-plugin-storybook": "0.6.15", | ||
|
@@ -118,15 +119,15 @@ | |
"lint-staged": "15.2.0", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "3.0.3", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1", | ||
"react-transition-group": "4.4.5", | ||
"rimraf": "5.0.5", | ||
"storybook": "7.6.5", | ||
"storybook": "8.3.5", | ||
"styled-components": "6.1.13", | ||
"typescript": "5.6.2", | ||
"vite": "5.0.10", | ||
"vitest": "1.0.4" | ||
"vite": "5.4.8", | ||
"vitest": "2.1.2" | ||
}, | ||
"peerDependencies": { | ||
"@emotion/react": ">=11.11.0", | ||
|
@@ -136,7 +137,7 @@ | |
"react": ">=18.3.1", | ||
"react-dom": ">=18.3.1", | ||
"react-transition-group": ">=4.4.5", | ||
"styled-components": ">=5.3.11" | ||
"styled-components": ">=6.1.13" | ||
}, | ||
"packageManager": "[email protected]", | ||
"resolutions": { | ||
|
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
Oops, something went wrong.