96 lines
2.0 KiB
TypeScript
96 lines
2.0 KiB
TypeScript
import "../src/preview.css";
|
|
|
|
import type { Preview } from "@storybook/react";
|
|
import {
|
|
defaultSkin,
|
|
setSkin,
|
|
skinDetails,
|
|
skinNames
|
|
} from "@ai-ui/ui";
|
|
import {
|
|
defaultMotionMode,
|
|
defaultTheme,
|
|
motionModeNames,
|
|
setMotionMode,
|
|
setTheme,
|
|
themeDetails,
|
|
themeNames
|
|
} from "@ai-ui/tokens";
|
|
|
|
const preview: Preview = {
|
|
globalTypes: {
|
|
theme: {
|
|
description: "Preview theme",
|
|
toolbar: {
|
|
icon: "paintbrush",
|
|
dynamicTitle: true,
|
|
items: themeNames.map((themeName) => ({
|
|
value: themeName,
|
|
title: themeDetails[themeName].label
|
|
}))
|
|
}
|
|
},
|
|
motion: {
|
|
description: "Preview motion mode",
|
|
toolbar: {
|
|
icon: "transfer",
|
|
dynamicTitle: true,
|
|
items: motionModeNames.map((modeName) => ({
|
|
value: modeName,
|
|
title: modeName === "system" ? "Motion / System" : "Motion / Reduced"
|
|
}))
|
|
}
|
|
},
|
|
skin: {
|
|
description: "Preview component skin",
|
|
toolbar: {
|
|
icon: "mirror",
|
|
dynamicTitle: true,
|
|
items: skinNames.map((skinName) => ({
|
|
value: skinName,
|
|
title: skinDetails[skinName].label
|
|
}))
|
|
}
|
|
}
|
|
},
|
|
initialGlobals: {
|
|
motion: defaultMotionMode,
|
|
skin: defaultSkin,
|
|
theme: defaultTheme
|
|
},
|
|
parameters: {
|
|
a11y: {
|
|
test: "error"
|
|
},
|
|
backgrounds: {
|
|
default: "canvas",
|
|
values: [
|
|
{
|
|
name: "canvas",
|
|
value: "var(--color-background)"
|
|
}
|
|
]
|
|
},
|
|
controls: {
|
|
expanded: true
|
|
},
|
|
layout: "fullscreen"
|
|
},
|
|
decorators: [
|
|
(Story, context) => {
|
|
if (typeof document !== "undefined") {
|
|
setTheme(context.globals.theme ?? defaultTheme);
|
|
setMotionMode(context.globals.motion ?? defaultMotionMode);
|
|
setSkin(context.globals.skin ?? defaultSkin);
|
|
|
|
document.body.dataset.theme = context.globals.theme ?? defaultTheme;
|
|
document.body.dataset.skin = context.globals.skin ?? defaultSkin;
|
|
}
|
|
|
|
return Story();
|
|
}
|
|
]
|
|
};
|
|
|
|
export default preview;
|