Commit dd40c7e
committed
🤖 fix(storybook): add forcedTheme prop to respect Chromatic mode variants
Added a `forcedTheme` prop to ThemeProvider that overrides the
persisted localStorage theme. This ensures Chromatic's mode variants
(dark/light) are correctly applied during visual snapshots.
Without this, ThemeProvider would read from localStorage and ignore
the mode set by Chromatic, causing all snapshots to appear in the
same theme (the persisted one).
Changes:
- ThemeProvider now accepts optional `forcedTheme` prop
- Storybook decorator passes `context.globals.theme` as forcedTheme
- When forcedTheme is set, it overrides the persisted theme
- When forcedTheme is undefined (local dev), uses normal persistence
This restores the original PR intent where Chromatic's dark/light
modes produce correctly themed snapshots.1 parent 54699a4 commit dd40c7e
2 files changed
+9
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
59 | 62 | | |
60 | | - | |
61 | | - | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
| 72 | + | |
70 | 73 | | |
71 | 74 | | |
72 | 75 | | |
73 | | - | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
0 commit comments