-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
511 additions
and
3,261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
packages/storybook/.storybook/addons/react-strict-mode/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
import type { PropsWithChildren } from "react" | ||
import type {PropsWithChildren} from "react"; | ||
|
||
import { addons, makeDecorator } from "@storybook/preview-api" | ||
import { getQueryParams } from "@storybook/preview-api" | ||
import React, { StrictMode, useEffect, useState } from "react" | ||
import {addons, makeDecorator} from "@storybook/preview-api"; | ||
import React, {StrictMode, useEffect, useState} from "react"; | ||
|
||
function StrictModeDecorator({ children }: PropsWithChildren<any>) { | ||
const [isStrict, setStrict] = useState(() => getQueryParams()?.strict === "true") | ||
function StrictModeDecorator({children}: PropsWithChildren<any>) { | ||
const strictQuery = new URLSearchParams(window.location.search).get("strict"); | ||
const [isStrict, setStrict] = useState(strictQuery === "true"); | ||
|
||
useEffect(() => { | ||
const channel = addons.getChannel() | ||
const channel = addons.getChannel(); | ||
|
||
channel.on("strict/updated", setStrict) | ||
channel.on("strict/updated", setStrict); | ||
|
||
return () => { | ||
channel.removeListener("strict/updated", setStrict) | ||
} | ||
}, []) | ||
channel.removeListener("strict/updated", setStrict); | ||
}; | ||
}, []); | ||
|
||
return isStrict ? <StrictMode>{children}</StrictMode> : children | ||
return isStrict ? <StrictMode>{children}</StrictMode> : children; | ||
} | ||
|
||
export const withStrictModeSwitcher = makeDecorator({ | ||
name: "withStrictModeSwitcher", | ||
parameterName: "strictModeSwitcher", | ||
wrapper: (getStory, context) => { | ||
return <StrictModeDecorator>{getStory(context)}</StrictModeDecorator> | ||
return <StrictModeDecorator>{getStory(context)}</StrictModeDecorator>; | ||
}, | ||
}) | ||
}); |
32 changes: 28 additions & 4 deletions
32
packages/storybook/.storybook/main.js → packages/storybook/.storybook/main.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,54 @@ | ||
import { dirname, join } from "path"; | ||
module.exports = { | ||
import remarkGfm from "remark-gfm"; | ||
import type { StorybookConfig } from '@storybook/react-vite'; | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
"./welcome.stories.mdx", | ||
"./welcome.mdx", | ||
"../../components/**/stories/**/*.stories.@(js|jsx|ts|tsx)", | ||
"../../core/theme/stories/*.stories.@(js|jsx|ts|tsx)", | ||
"../../core/theme/stories/*.stories.@(js|jsx|ts|tsx)" | ||
], | ||
|
||
staticDirs: ["../public"], | ||
|
||
addons: [ | ||
getAbsolutePath("@storybook/addon-a11y"), | ||
getAbsolutePath("@storybook/addon-essentials"), | ||
getAbsolutePath("@storybook/addon-links"), | ||
getAbsolutePath("storybook-dark-mode"), | ||
getAbsolutePath("@storybook/addon-mdx-gfm"), | ||
{ | ||
name: '@storybook/addon-docs', | ||
options: { | ||
mdxPluginOptions: { | ||
mdxCompileOptions: { | ||
remarkPlugins: [remarkGfm], | ||
}, | ||
}, | ||
}, | ||
}, | ||
"./addons/react-strict-mode/register", | ||
], | ||
|
||
framework: { | ||
name: getAbsolutePath("@storybook/react-vite"), | ||
options: {}, | ||
}, | ||
|
||
core: { | ||
disableTelemetry: true, | ||
}, | ||
|
||
typescript: { | ||
reactDocgen: false, | ||
}, | ||
|
||
docs: { | ||
autodocs: true | ||
} | ||
}; | ||
|
||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, "package.json"))); | ||
} | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.