Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(react): update storybook to re-enable theming panels #5332

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions packages/react/.storybook/addon-carbon-theme/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import addons from '@storybook/addons';
import { addons, types } from '@storybook/addons';
import { CarbonThemesPanel, CarbonTypePanel } from './components/Panel';
import {
CARBON_THEMES_ADDON_ID,
Expand All @@ -15,20 +15,22 @@ import {
CARBON_TYPE_PANEL_ID,
} from './shared';

addons.register(CARBON_THEMES_ADDON_ID, api => {
addons.addPanel(CARBON_THEME_PANEL_ID, {
title: 'Carbon theme',
render: ({ active, key }) => (
<CarbonThemesPanel api={api} key={key} active={active} />
),
if (process.env.CARBON_REACT_STORYBOOK_USE_CUSTOM_PROPERTIES === 'true') {
addons.register(CARBON_THEMES_ADDON_ID, api => {
addons.addPanel(CARBON_THEME_PANEL_ID, {
title: 'Carbon theme',
render: ({ active, key }) => (
<CarbonThemesPanel api={api} key={key} active={active} />
),
});
});
});

addons.register(CARBON_TYPE_ADDON_ID, api => {
addons.addPanel(CARBON_TYPE_PANEL_ID, {
title: 'Carbon type',
render: ({ active, key }) => (
<CarbonTypePanel api={api} key={key} active={active} />
),
addons.register(CARBON_TYPE_ADDON_ID, api => {
addons.addPanel(CARBON_TYPE_PANEL_ID, {
title: 'Carbon type',
render: ({ active, key }) => (
<CarbonTypePanel api={api} key={key} active={active} />
),
});
});
});
}
7 changes: 2 additions & 5 deletions packages/react/.storybook/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import '@storybook/addon-a11y/register';
// Community addons
import 'storybook-readme/register';

if (process.env.CARBON_REACT_STORYBOOK_USE_CUSTOM_PROPERTIES === 'true') {
import('./addon-carbon-theme/register').catch(error => {
console.error(error);
});
}
// Custom addons
import './addon-carbon-theme/register';

// These options used by storybook often conflict with developer tools,
// conditional panels, or other things that get in the way of our workflow
Expand Down