Add runtime skin contract and docs

This commit is contained in:
2026-03-20 11:22:03 +08:00
parent 5c9eb84c63
commit 246851a68e
9 changed files with 1053 additions and 1 deletions
+20
View File
@@ -1,6 +1,12 @@
import "../src/preview.css";
import type { Preview } from "@storybook/react";
import {
defaultSkin,
setSkin,
skinDetails,
skinNames
} from "@ai-ui/ui";
import {
defaultMotionMode,
defaultTheme,
@@ -34,10 +40,22 @@ const preview: Preview = {
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: {
@@ -63,8 +81,10 @@ const preview: Preview = {
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();