File tree Expand file tree Collapse file tree 5 files changed +47
-29
lines changed
Expand file tree Collapse file tree 5 files changed +47
-29
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const config: StorybookConfig = {
99 "@storybook/addon-interactions" ,
1010 "@storybook/addon-a11y" ,
1111 "@storybook/addon-themes" ,
12+ "@storybook/theming" ,
1213 ] ,
1314 framework : {
1415 name : "@storybook/react-vite" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import "../src/index.css" ;
2+ import React from "react" ;
3+ import { withThemeByClassName } from "@storybook/addon-themes" ;
4+ import { DocsContainer } from "@storybook/blocks" ;
5+ import { themes } from "@storybook/theming" ;
6+ import type { Preview , ReactRenderer } from "@storybook/react" ;
7+ import type { DocsContainerProps } from "@storybook/blocks" ;
8+
9+ const preview : Preview = {
10+ parameters : {
11+ controls : {
12+ matchers : {
13+ color : / ( b a c k g r o u n d | c o l o r ) $ / i,
14+ date : / D a t e $ / i,
15+ } ,
16+ } ,
17+ docs : {
18+ toc : true ,
19+ container : ( props : DocsContainerProps < ReactRenderer > ) => {
20+ try {
21+ const { getStoryContext, storyById } = props . context ;
22+
23+ const globals = getStoryContext ( storyById ( ) ) . globals ;
24+ const theme = globals . theme === "dark" ? themes . dark : themes . light ;
25+ return < DocsContainer { ...props } theme = { theme } /> ;
26+ } catch {
27+ return < DocsContainer { ...props } /> ;
28+ }
29+ } ,
30+ } ,
31+ } ,
32+ decorators : [
33+ withThemeByClassName < ReactRenderer > ( {
34+ themes : {
35+ light : "" ,
36+ dark : "dark" ,
37+ } ,
38+ defaultTheme : "light" ,
39+ } ) ,
40+ ] ,
41+ tags : [ "autodocs" ] ,
42+ } ;
43+
44+ export default preview ;
Original file line number Diff line number Diff line change 4747 "@storybook/react-vite" : " ^8.6.12" ,
4848 "@storybook/test" : " ^8.6.12" ,
4949 "@storybook/test-runner" : " ^0.22.0" ,
50+ "@storybook/theming" : " ^8.6.11" ,
5051 "@testing-library/jest-dom" : " ^6.6.3" ,
5152 "@testing-library/react" : " ^16.2.0" ,
5253 "@testing-library/user-event" : " ^14.6.1" ,
You canโt perform that action at this time.
0 commit comments