Skip to content

Commit 39ca566

Browse files
authored
Merge branch 'next' into bug/32603
2 parents 4d1922e + 9d5bec1 commit 39ca566

File tree

9 files changed

+70
-20
lines changed

9 files changed

+70
-20
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 10.0.3
2+
3+
- Core: Better handling for TypeScript satisfies/as syntaxes - [#32891](https://github.com/storybookjs/storybook/pull/32891), thanks @yannbf!
4+
- Core: Fix wrong import to fix Yarn PnP support - [#32928](https://github.com/storybookjs/storybook/pull/32928), thanks @yannbf!
5+
- ESlint: Update `@storybook/experimental-nextjs-vite` in `no-renderer-packages` rule - [#32909](https://github.com/storybookjs/storybook/pull/32909), thanks @ndelangen!
6+
- React Native: Update withStorybook setup instructions - [#32919](https://github.com/storybookjs/storybook/pull/32919), thanks @dannyhw!
7+
18
## 10.0.2
29

310
- CLI: Fix glob string formatting in csf-factories codemod - [#32880](https://github.com/storybookjs/storybook/pull/32880), thanks @yannbf!

code/core/src/component-testing/components/StatusBadge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22

3-
import { type Color, styled, typography } from 'storybook/theming';
3+
import { TooltipNote, WithTooltip } from 'storybook/internal/components';
44

5-
import { TooltipNote, WithTooltip } from '../../components';
5+
import { type Color, styled, typography } from 'storybook/theming';
66

77
export type PlayStatus = 'rendering' | 'playing' | 'completed' | 'errored' | 'aborted';
88

code/core/src/manager/globals/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export default {
370370
'css',
371371
'darken',
372372
'ensure',
373+
'getPreferredColorScheme',
373374
'ignoreSsrWarning',
374375
'isPropValid',
375376
'jsx',

code/core/src/theming/create.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@ import lightThemeVars from './themes/light';
44
import type { ThemeVars, ThemeVarsPartial } from './types';
55
import { getPreferredColorScheme } from './utils';
66

7-
export const themes: { light: ThemeVars; dark: ThemeVars; normal: ThemeVars } = {
7+
interface Themes {
8+
light: ThemeVars;
9+
dark: ThemeVars;
10+
normal: ThemeVars;
11+
}
12+
13+
const themesBase: Omit<Themes, 'normal'> = {
814
light: lightThemeVars,
915
dark: darkThemeVars,
10-
normal: lightThemeVars,
16+
};
17+
18+
const preferredColorScheme = getPreferredColorScheme();
19+
20+
export const themes: Themes = {
21+
...themesBase,
22+
normal: themesBase[preferredColorScheme],
1123
};
1224

1325
interface Rest {
1426
[key: string]: any;
1527
}
1628

17-
const preferredColorScheme = getPreferredColorScheme();
18-
1929
export const create = (
2030
vars: ThemeVarsPartial = { base: preferredColorScheme },
2131
rest?: Rest

code/core/src/theming/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export * from './create';
4040
export * from './convert';
4141
export * from './ensure';
4242

43-
export { lightenColor as lighten, darkenColor as darken } from './utils';
43+
export { lightenColor as lighten, darkenColor as darken, getPreferredColorScheme } from './utils';
4444

4545
export const ignoreSsrWarning =
4646
'/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */';

code/core/src/theming/tests/create.test.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { describe, expect, it } from 'vitest';
1+
import { beforeEach, describe, expect, it, vi } from 'vitest';
22

33
import { create } from '../create';
4+
import { getPreferredColorScheme } from './../utils';
5+
6+
vi.mock('./../utils', () => ({
7+
getPreferredColorScheme: vi.fn().mockReturnValue('light'),
8+
}));
49

510
describe('create base', () => {
611
it('should create a theme with minimal viable theme', () => {
@@ -142,3 +147,25 @@ describe('create extend', () => {
142147
expect(result.base).toEqual('light');
143148
});
144149
});
150+
151+
describe('themes', () => {
152+
beforeEach(() => {
153+
vi.resetModules();
154+
});
155+
156+
it('should set `normal` to `light` theme when user preference is `light`', async () => {
157+
getPreferredColorScheme.mockReturnValue('light');
158+
159+
const { themes } = await import('./../create');
160+
161+
expect(themes.normal).toBe(themes.light);
162+
});
163+
164+
it('should set `normal` to `dark` theme when user preference is `dark`', async () => {
165+
getPreferredColorScheme.mockReturnValue('dark');
166+
167+
const { themes } = await import('./../create');
168+
169+
expect(themes.normal).toBe(themes.dark);
170+
});
171+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```shell renderer="common" language="js"
2-
STORYBOOK_DISABLE_TELEMETRY=1 yarn storybook
2+
STORYBOOK_DISABLE_TELEMETRY=true yarn storybook
33
```

docs/addons/addon-migration-guide.mdx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default defineConfig(async (options) => {
104104
+ const packageJson = (
105105
+ await import("./package.json", { with: { type: "json" } })
106106
+ ).default;
107-
+
107+
+
108108
const {
109109
bundler: {
110110
- exportEntries = [],
@@ -131,7 +131,7 @@ export default defineConfig(async (options) => {
131131
};
132132

133133
const configs: Options[] = [];
134-
-
134+
-
135135
- // export entries are entries meant to be manually imported by the user
136136
- // they are not meant to be loaded by the manager or preview
137137
- // they'll be usable in both node and browser environments, depending on which features and modules they depend on
@@ -225,13 +225,18 @@ Update `tsconfig.json`.
225225
```diff title="tsconfig.json"
226226
{
227227
"compilerOptions": {
228-
// ...
229-
- "target": "es2023",
228+
// …
229+
+ "moduleResolution": "bundler",
230+
// …
231+
- "module": "commonjs",
232+
+ "module": "preserve",
233+
// …
234+
- "target": "ES2020",
230235
+ "target": "esnext",
231-
// ...
232-
- "lib": ["es2023", "dom", "dom.iterable"],
236+
//
237+
- "lib": ["es2020", "dom", "dom.iterable"],
233238
+ "lib": ["esnext", "dom", "dom.iterable"],
234-
// ...
239+
//
235240
- "rootDir": "./src",
236241
+ "rootDir": ".",
237242
},
@@ -292,7 +297,7 @@ With CSF Factories, users can chain their preview configuration and benefit from
292297
- export default {};
293298
+ import { definePreviewAddon } from "storybook/internal/csf";
294299
+ import addonAnnotations from "./preview";
295-
+
300+
+
296301
+ export default () => definePreviewAddon(addonAnnotations);
297302
```
298303

@@ -356,7 +361,7 @@ For a full list of changes, please visit the [Migration.md](https://github.com/s
356361

357362
## Migration example
358363

359-
For a complete example of an addon updated to support Storybook 10.0, refer to the [Addon Kit migration PR](https://github.com/storybookjs/addon-kit/pull/82).
364+
For a complete example of an addon updated to support Storybook 10.0, refer to the [Addon Kit migration PR](https://github.com/storybookjs/addon-kit/pull/82).
360365
Once merged, it will demonstrate all the necessary and recommended changes for Storybook 10.
361366

362367
## Releasing

docs/configure/user-interface/theming.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Storybook is theme-able using a lightweight theming API.
1111

1212
It's possible to theme Storybook globally.
1313

14-
Storybook includes two themes that look good out of the box: "light" and "dark". Unless you've set your preferred color scheme as dark, Storybook will use the light theme as default.
14+
Storybook includes a set of built-in themes that you can use to customize the appearance of your Storybook UI. The built-in themes are light, dark, and the "normal" theme that matches your preferred color scheme. Unless you specify otherwise, Storybook uses the normal theme by default.
1515

1616
As an example, you can tell Storybook to use the "dark" theme by modifying [`.storybook/manager.js`](./features-and-behavior.mdx):
1717

@@ -25,7 +25,7 @@ When setting a theme, set a complete theme object. The theme is replaced, not co
2525

2626
## Theming docs
2727

28-
[Storybook Docs](../../writing-docs/index.mdx) uses the same theme system as Storybook’s UI but is themed independently from the main UI.
28+
[Storybook Docs](../../writing-docs/index.mdx) uses the same theme system as Storybook’s UI but is themed independently from the main UI. The default theme for Docs is always the "light" theme, regardless of the main UI theme.
2929

3030
Supposing you have a Storybook theme defined for the main UI in [`.storybook/manager.js`](./features-and-behavior.mdx):
3131

0 commit comments

Comments
 (0)