Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: dark mode support to storybook (#5964)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-mba authored Apr 10, 2023
1 parent 46e1c17 commit bb849fe
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 11 deletions.
1 change: 1 addition & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const config = {
"@storybook/addon-essentials",
"@storybook/addon-a11y",
"@tomfreudenberg/next-auth-mock/storybook",
"storybook-dark-mode",
{
name: '@storybook/addon-docs',
options: {
Expand Down
6 changes: 0 additions & 6 deletions .storybook/manager.js

This file was deleted.

19 changes: 19 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import "../styles/globals.css";
import { ThemeProvider } from "next-themes";
import { useDarkMode } from "storybook-dark-mode";
import { themes } from "@storybook/theming";

function ThemeWrapper({children}) {
// render your custom theme provider
return (
<ThemeProvider attribute="class" forcedTheme={useDarkMode() ? 'dark' : 'light'}>
{children}
</ThemeProvider>
);
}

export const decorators = [(renderStory => <ThemeWrapper>{renderStory()}</ThemeWrapper>)];

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
Expand All @@ -19,5 +34,9 @@ export const parameters = {
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
}
}
},
darkMode: {
dark: themes.dark,
light: themes.normal
}
};
35 changes: 32 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"ncp": "^2.0.0",
"postcss": "^8.4.21",
"prettier": "^2.8.7",
"storybook": "^7.0.2"
"storybook": "^7.0.2",
"storybook-dark-mode": "^3.0.0"
},
"description": "LinkFree connect audiences to all of your content with just one link. It is an open-source alternative to [Linktree](https://linktr.ee/) implemented in JavaScript - It was initially created on a YouTube [live stream](https://www.youtube.com/watch?v=Jorl_vcp-Ew).",
"repository": {
Expand All @@ -111,4 +112,4 @@
"bugs": {
"url": "https://github.com/EddieHubCommunity/LinkFree/issues"
}
}
}

0 comments on commit bb849fe

Please sign in to comment.