Skip to content

Commit

Permalink
feat: enhance Storybook setup with custom DocsContainer and global st…
Browse files Browse the repository at this point in the history
…yles for theme colors
  • Loading branch information
d-beezee committed Dec 17, 2024
1 parent ff2f7b6 commit 840cd43
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 288 deletions.
11 changes: 11 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DocsContainer } from "@storybook/blocks";
import { ThemeProvider } from "@zendeskgarden/react-theming";
import React from "react";
import { GlobalStyle } from "../src/stories/shared/globalStyle";
Expand All @@ -12,6 +13,14 @@ export const decorators = [
),
];

const CustomDocsContainer = ({ children, context }) => {
return (
<ThemeProvider theme={theme}>
<GlobalStyle />
<DocsContainer context={context}>{children}</DocsContainer>
</ThemeProvider>
);
};
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
Expand All @@ -22,6 +31,8 @@ export const parameters = {
},
docs: {
inlineStories: true,

container: CustomDocsContainer,
},
options: {
storySort: {
Expand Down
12 changes: 12 additions & 0 deletions src/stories/shared/globalStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createGlobalStyle } from "styled-components";
import "@zendeskgarden/css-bedrock"; //This package provides a mostly reasonable CSS reset layered on top of modern-normalize.

import { theme } from "../theme";
import { getColor } from "../theme/utils";

const GlobalStyle = createGlobalStyle`
::-webkit-scrollbar-track:hover {
Expand All @@ -25,6 +26,17 @@ const GlobalStyle = createGlobalStyle`
border-radius: 25px;
}
:root {
--zd-palette-primary: ${getColor(theme.colors.primaryHue, 600)};
--zd-palette-danger: ${getColor(theme.colors.dangerHue, 600)};
--zd-palette-warning: ${getColor(theme.colors.warningHue, 600)};
--zd-palette-success: ${getColor(theme.colors.successHue, 600)};
--zd-palette-neutral: ${getColor(theme.colors.neutralHue, 600)};
--zd-palette-info: ${getColor(theme.colors.infoHue, 600)};
--zd-palette-chrome: ${getColor(theme.colors.chromeHue, 600)};
--zd-palette-accent: ${getColor(theme.colors.accentHue, 600)};
}
/* This stuff is for Firefox */
* {
scrollbar-color: ${theme.palette.blue["200"]} #FFFFFF;
Expand Down
25 changes: 25 additions & 0 deletions src/stories/theme/colors.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
ColorItem,
ColorPalette,
DocsContainer,
Meta,
} from "@storybook/blocks";
import { colors } from "./colors";
import { palette } from "./palette";

<Meta title="Theme/Colors" />

<ColorPalette>
{Object.keys(palette).map((k) => {
return (
<>
<ColorItem
title={`zd.colors.${k}`}
colors={
typeof palette[k] === "string" ? { [k]: palette[k] } : palette[k]
}
/>
</>
);
})}
</ColorPalette>
117 changes: 0 additions & 117 deletions src/stories/theme/colors.stories.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions src/stories/theme/palette.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
ColorItem,
ColorPalette,
DocsContainer,
Meta,
Story,
} from "@storybook/blocks";
import { colors } from "./colors";

import PaletteComponent from "./paletteComponent";

<Meta title="Theme/Palette" />
<PaletteComponent />
171 changes: 0 additions & 171 deletions src/stories/theme/palette.stories.tsx

This file was deleted.

Loading

0 comments on commit 840cd43

Please sign in to comment.