Skip to content

Commit 965a69d

Browse files
authored
[Storybook] Use native theme switcher (#215443)
## Summary Closes #213294 This PR replaces the custom theme switcher in favor of the native toolbar customization SB has integrated. Also removed `@storybook/icons` which was only used in the theme switcher component. ## How to test 1. Run `yarn storybook <plugin>` 2. You should be able to change between themes on the toolbar.
1 parent 17ecc6a commit 965a69d

File tree

6 files changed

+42
-127
lines changed

6 files changed

+42
-127
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,6 @@
15721572
"@storybook/components": "^8.6.3",
15731573
"@storybook/core-events": "^8.6.3",
15741574
"@storybook/core-server": "^8.6.3",
1575-
"@storybook/icons": "^1.3.2",
15761575
"@storybook/manager-api": "^8.6.3",
15771576
"@storybook/preview-api": "^8.6.3",
15781577
"@storybook/react": "^8.6.3",

src/platform/packages/shared/kbn-storybook/src/lib/preview.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,53 @@
1010
import type { Preview } from '@storybook/react';
1111
import * as jest from 'jest-mock';
1212
import { decorators } from './decorators';
13+
import {
14+
AMSTERDAM_DARK,
15+
AMSTERDAM_LIGHT,
16+
BOREALIS_DARK,
17+
BOREALIS_LIGHT,
18+
DEFAULT_THEME,
19+
THEME_TITLES,
20+
} from './themes';
1321

1422
// @ts-expect-error
1523
window.jest = jest;
1624

1725
const preview: Preview = {
1826
decorators,
19-
initialGlobals: { euiTheme: 'v8.light' },
27+
initialGlobals: { euiTheme: DEFAULT_THEME },
28+
globalTypes: {
29+
euiTheme: {
30+
description: 'Change the EUI theme',
31+
toolbar: {
32+
title: 'Theme',
33+
icon: 'paintbrush',
34+
dynamicTitle: true,
35+
items: [
36+
{
37+
value: BOREALIS_LIGHT,
38+
icon: 'hearthollow',
39+
title: THEME_TITLES[BOREALIS_LIGHT],
40+
},
41+
{
42+
value: BOREALIS_DARK,
43+
icon: 'heart',
44+
title: THEME_TITLES[BOREALIS_DARK],
45+
},
46+
{
47+
value: AMSTERDAM_LIGHT,
48+
icon: 'hearthollow',
49+
title: THEME_TITLES[AMSTERDAM_LIGHT],
50+
},
51+
{
52+
value: AMSTERDAM_DARK,
53+
icon: 'heart',
54+
title: THEME_TITLES[AMSTERDAM_DARK],
55+
},
56+
],
57+
},
58+
},
59+
},
2060
};
2161

2262
// eslint-disable-next-line import/no-default-export

src/platform/packages/shared/kbn-storybook/src/lib/register.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import { addons } from '@storybook/manager-api';
1111
import { create } from '@storybook/theming';
12-
import { registerThemeSwitcherAddon } from './register_theme_switcher_addon';
1312

1413
// This configures the "Manager", or main outer view of Storybook. It is an
1514
// addon that's loaded by the `managerEntries` part of the preset in ../preset.js.
@@ -25,5 +24,3 @@ addons.setConfig({
2524
panelPosition: 'bottom',
2625
showToolbar: true,
2726
});
28-
29-
registerThemeSwitcherAddon();

src/platform/packages/shared/kbn-storybook/src/lib/register_theme_switcher_addon.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/platform/packages/shared/kbn-storybook/src/lib/theme_switcher.tsx

Lines changed: 0 additions & 82 deletions
This file was deleted.

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10292,7 +10292,7 @@
1029210292
resolved "https://registry.yarnpkg.com/@storybook/global/-/global-5.0.0.tgz#b793d34b94f572c1d7d9e0f44fac4e0dbc9572ed"
1029310293
integrity sha512-FcOqPAXACP0I3oJ/ws6/rrPT9WGhu915Cg8D02a9YxLo0DE9zI+a9A5gRGvmQ09fiWPukqI8ZAEoQEdWUKMQdQ==
1029410294

10295-
"@storybook/icons@^1.2.12", "@storybook/icons@^1.3.2":
10295+
"@storybook/icons@^1.2.12":
1029610296
version "1.3.2"
1029710297
resolved "https://registry.yarnpkg.com/@storybook/icons/-/icons-1.3.2.tgz#e9b92c35ca789ff79f9d0b3848829dd6490ca628"
1029810298
integrity sha512-t3xcbCKkPvqyef8urBM0j/nP6sKtnlRkVgC+8JTbTAZQjaTmOjes3byEgzs89p4B/K6cJsg9wLW2k3SknLtYJw==

0 commit comments

Comments
 (0)