Skip to content

Commit 686b102

Browse files
committed
feat: sync light/dark mode with theme
1 parent 1a656bc commit 686b102

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

code/addons/docs/src/manager.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33
import { AddonPanel, type SyntaxHighlighterFormatTypes } from 'storybook/internal/components';
44
import { ADDON_ID, PANEL_ID, PARAM_KEY, SNIPPET_RENDERED } from 'storybook/internal/docs-tools';
55
import { addons, types, useChannel, useParameter } from 'storybook/internal/manager-api';
6-
import { ignoreSsrWarning, styled } from 'storybook/internal/theming';
6+
import { ignoreSsrWarning, styled, useTheme } from 'storybook/internal/theming';
77

88
import { Source, type SourceParameters } from '@storybook/blocks';
99

@@ -30,6 +30,7 @@ addons.register(ADDON_ID, (api) => {
3030
render: ({ active }) => {
3131
const parameter = useParameter(PARAM_KEY, {
3232
source: { code: '' } as SourceParameters,
33+
theme: 'dark',
3334
});
3435

3536
const [codeSnippet, setSourceCode] = React.useState<{
@@ -43,14 +44,17 @@ addons.register(ADDON_ID, (api) => {
4344
},
4445
});
4546

47+
const theme = useTheme();
48+
const isDark = theme.base !== 'light';
49+
4650
return (
4751
<AddonPanel active={!!active}>
4852
<SourceStyles>
4953
<Source
5054
{...parameter.source}
5155
code={parameter.source.code || codeSnippet.source}
5256
format={parameter.source.format || codeSnippet.format}
53-
dark
57+
dark={isDark}
5458
/>
5559
</SourceStyles>
5660
</AddonPanel>

code/addons/docs/template/stories/codePanel/index.stories.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ export default {
33
tags: ['autodocs'],
44
parameters: {
55
chromatic: { disable: true },
6+
docs: {
7+
codePanel: true,
8+
},
69
},
710
};
811

0 commit comments

Comments
 (0)