Skip to content

Commit

Permalink
improve theme docs by showing parent group in theme json (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvice authored Jan 12, 2023
1 parent a5db3df commit eea0a82
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .storybook/components/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ export function Theme({
component: string
items?: string[]
}): ReactElement {
const theme = items
? Object.fromEntries(
// eslint-disable-next-line
// @ts-ignore
items.map((item) => [item, defaultTheme?.[component]?.[item]])
)
: defaultTheme?.[component]
const theme = {
[component]: items
? Object.fromEntries(
// eslint-disable-next-line
// @ts-ignore
items.map((item) => [item, defaultTheme?.[component]?.[item]])
)
: defaultTheme?.[component],
}

return (
<>
<Description
markdown={`This component uses the following defaults from the \`${component}\` theme:`}
markdown={`This component uses the following theme defaults:`}
/>
<Source code={JSON.stringify(theme, null, 2)} language="json" />
</>
Expand Down

0 comments on commit eea0a82

Please sign in to comment.