diff --git a/design-system/apps/design-lab/public/assets/bitfun-mascot.svg b/design-system/apps/design-lab/public/assets/bitfun-mascot.svg new file mode 100644 index 0000000000..ee3a4fa433 --- /dev/null +++ b/design-system/apps/design-lab/public/assets/bitfun-mascot.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/design-system/apps/design-lab/public/assets/daily-divination.webp b/design-system/apps/design-lab/public/assets/daily-divination.webp new file mode 100644 index 0000000000..2bcccda7ed Binary files /dev/null and b/design-system/apps/design-lab/public/assets/daily-divination.webp differ diff --git a/design-system/apps/design-lab/public/assets/gomoku.webp b/design-system/apps/design-lab/public/assets/gomoku.webp new file mode 100644 index 0000000000..3b7109e686 Binary files /dev/null and b/design-system/apps/design-lab/public/assets/gomoku.webp differ diff --git a/design-system/apps/design-lab/public/assets/openbitfun-mark.svg b/design-system/apps/design-lab/public/assets/openbitfun-mark.svg new file mode 100644 index 0000000000..c085955b39 --- /dev/null +++ b/design-system/apps/design-lab/public/assets/openbitfun-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/design-system/apps/design-lab/public/assets/regex-playground.webp b/design-system/apps/design-lab/public/assets/regex-playground.webp new file mode 100644 index 0000000000..dd7ddb72ae Binary files /dev/null and b/design-system/apps/design-lab/public/assets/regex-playground.webp differ diff --git a/design-system/apps/design-lab/public/demo/mobile/assets/bitfun-mascot.svg b/design-system/apps/design-lab/public/demo/mobile/assets/bitfun-mascot.svg new file mode 100644 index 0000000000..ee3a4fa433 --- /dev/null +++ b/design-system/apps/design-lab/public/demo/mobile/assets/bitfun-mascot.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/design-system/apps/design-lab/public/demo/mobile/assets/daily-divination.webp b/design-system/apps/design-lab/public/demo/mobile/assets/daily-divination.webp new file mode 100644 index 0000000000..2bcccda7ed Binary files /dev/null and b/design-system/apps/design-lab/public/demo/mobile/assets/daily-divination.webp differ diff --git a/design-system/apps/design-lab/public/demo/mobile/assets/gomoku.webp b/design-system/apps/design-lab/public/demo/mobile/assets/gomoku.webp new file mode 100644 index 0000000000..3b7109e686 Binary files /dev/null and b/design-system/apps/design-lab/public/demo/mobile/assets/gomoku.webp differ diff --git a/design-system/apps/design-lab/public/demo/mobile/assets/openbitfun-mark.svg b/design-system/apps/design-lab/public/demo/mobile/assets/openbitfun-mark.svg new file mode 100644 index 0000000000..c085955b39 --- /dev/null +++ b/design-system/apps/design-lab/public/demo/mobile/assets/openbitfun-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/design-system/apps/design-lab/public/demo/mobile/assets/regex-playground.webp b/design-system/apps/design-lab/public/demo/mobile/assets/regex-playground.webp new file mode 100644 index 0000000000..dd7ddb72ae Binary files /dev/null and b/design-system/apps/design-lab/public/demo/mobile/assets/regex-playground.webp differ diff --git a/design-system/apps/design-lab/public/demo/mobile/index.html b/design-system/apps/design-lab/public/demo/mobile/index.html new file mode 100644 index 0000000000..e5ed3f01a9 --- /dev/null +++ b/design-system/apps/design-lab/public/demo/mobile/index.html @@ -0,0 +1,2632 @@ + + + + + +OpenBitFun · Mobile + + + + + + + + +
+ 设备: +
+ + + +
+
+ +
+
+
+ +
+ 03:00 + + + + + + +
+
+ + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+
+ + + + +
+
+ + +
+
+ + + +
+
+
+ + +
+
+ + 小应用 + +
+
+ +
+
+
+ + + +
+
左右滑动切换
+
+ + + +
+
+ +
+ +
+
+ + +
+
+
+
+
+ + + + diff --git a/design-system/apps/design-lab/scripts/generate-skill.mjs b/design-system/apps/design-lab/scripts/generate-skill.mjs new file mode 100644 index 0000000000..b1b407db60 --- /dev/null +++ b/design-system/apps/design-lab/scripts/generate-skill.mjs @@ -0,0 +1,13 @@ +/* Writes the committed SKILL.md from the registry and token catalogs. Run after changing a + component's meta or a token: node scripts/generate-skill.mjs (from apps/design-lab). */ +import { mkdir, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { buildDesignSystemSkill, SKILL_PATH } from "../src/skill/buildSkill.ts"; +import { skillSources } from "./skill-sources.mjs"; + +const repoRoot = path.resolve(fileURLToPath(new URL("../../../../", import.meta.url))); +const target = path.join(repoRoot, SKILL_PATH); +await mkdir(path.dirname(target), { recursive: true }); +await writeFile(target, buildDesignSystemSkill(skillSources())); +console.log(`Wrote ${path.relative(repoRoot, target)}`); diff --git a/design-system/apps/design-lab/scripts/skill-sources.mjs b/design-system/apps/design-lab/scripts/skill-sources.mjs new file mode 100644 index 0000000000..a7f44a3f6e --- /dev/null +++ b/design-system/apps/design-lab/scripts/skill-sources.mjs @@ -0,0 +1,17 @@ +import { componentPlatforms, componentRegistry } from "@openbitfun/ui/registry"; +import { tokenCatalog } from "@openbitfun/design-tokens"; +import { themeTokenCatalog } from "@openbitfun/theme-openbitfun"; + +/* Collects the skill sources from the built packages, in the shape buildDesignSystemSkill takes. */ +export function skillSources() { + return { + components: componentRegistry.map(component => ({ + name: component.name, + description: component.description, + platform: componentPlatforms(component)[0], + props: component.props, + })), + systemTokens: tokenCatalog, + themeTokens: themeTokenCatalog, + }; +} diff --git a/design-system/apps/design-lab/src/App.tsx b/design-system/apps/design-lab/src/App.tsx index 1803dd5cce..d08c3ec6b4 100644 --- a/design-system/apps/design-lab/src/App.tsx +++ b/design-system/apps/design-lab/src/App.tsx @@ -14,6 +14,7 @@ import { AppWindow, Blocks, BookOpen, Bot, Braces, FileText, House, Languages, M import { Button, Dialog, DialogBody, DialogClose, DialogDescription, DialogHeader, DialogHeading, DialogTitle, IconButton, KeyHint, Listbox, ListboxEmpty, ListboxOption, SearchField, Select, Sheet, Icon as CatalogIcon, DesignSystemProvider, ThemeRoot, + canonicalIconNames, type ColorScheme, type ContrastMode, type DensityMode, @@ -35,8 +36,12 @@ import { ComponentsPage } from "./pages/ComponentsPage"; import { GettingStartedPage } from "./pages/GettingStartedPage"; import { ResourcesPage } from "./pages/ResourcesPage"; import { PatternsPage } from "./pages/PatternsPage"; +import { MobilePatternsPage } from "./pages/MobilePatternsPage"; +import { DemoComparePage } from "./pages/DemoComparePage"; +import { SkillPage } from "./pages/SkillPage"; import { FlowChatMockPage } from "./pages/FlowChatMockPage"; import { ColorsPage } from "./pages/ColorsPage"; +import { IconsPage } from "./pages/IconsPage"; import { SubagentIpPage } from "./pages/SubagentIpPage"; import { SUBAGENT_AVATAR_CATALOG } from "./assets/subagentAvatars"; import { @@ -64,9 +69,13 @@ type LabRoute = | { page: "mobile" } | { page: "brand" } | { page: "patterns" } + | { page: "mobile-patterns" } + | { page: "demo-compare" } | { page: "flow-chat" } | { page: "flow-chat-mock" } | { page: "colors" } + | { page: "icons" } + | { page: "skill" } | { page: "subagent-ip" } | { page: "resources" } | { page: "tokens" } @@ -115,6 +124,12 @@ function parseRoute(hash: string): LabRoute { if (route === "tokens") { return { page: "tokens" }; } + if (route === "skill") { + return { page: "skill" }; + } + if (route === "icons") { + return { page: "icons" }; + } if (route === "colors") { return { page: "colors" }; } @@ -122,15 +137,23 @@ function parseRoute(hash: string): LabRoute { return { page: "getting-started" }; } if (route === "components") { + // The default component of this route: Web surface or Mobile surface (the rail's two tabs). return { page: "components" }; } if (route === "brand" || route.startsWith("brand/")) return { page: "brand" }; if (route === "mobile") { + // Same library page, mobile surface: the rail highlights the Mobile tab. return { page: "mobile" }; } if (route === "patterns") { return { page: "patterns" }; } + if (route === "demo-compare") { + return { page: "demo-compare" }; + } + if (route === "mobile-patterns") { + return { page: "mobile-patterns" }; + } if (route === "flow-chat") { return { page: "flow-chat" }; } @@ -236,6 +259,20 @@ export function App() { label: t("nav.colors"), route: { page: "colors" }, }, + { + detail: t("icons.intro", { count: canonicalIconNames.length }), + icon: "session", + keywords: `icons icon library glyph stroke 图标 ${t("nav.icons")}`, + label: t("nav.icons"), + route: { page: "icons" }, + }, + { + detail: t("skill.searchDetail"), + icon: FileText, + keywords: `skill ai agent prompt generate SKILL.md 生成 规范 ${t("nav.skill")}`, + label: t("nav.skill"), + route: { page: "skill" }, + }, { detail: t("search.componentsDetail", { count: componentRegistry.length }), icon: Blocks, @@ -264,6 +301,20 @@ export function App() { label: t("nav.patterns"), route: { page: "patterns" }, }, + { + detail: t("scenes.mobile.label"), + icon: Smartphone, + keywords: `mobile patterns scenes phone handheld home mini apps sidebar ${t("nav.patterns")}`, + label: `${t("nav.patterns")} · ${t("design.mobile")}`, + route: { page: "mobile-patterns" }, + }, + { + detail: t("compare.searchDetail"), + icon: Smartphone, + keywords: `demo compare fidelity measure 对照 还原 ${t("nav.demoCompare")}`, + label: t("nav.demoCompare"), + route: { page: "demo-compare" }, + }, { detail: t("search.flowChatDetail", { count: flowChatComponents.length }), icon: SquareTerminal, @@ -600,6 +651,19 @@ export function App() { /> )} + {route.page === "mobile-patterns" && ( + + )} + + {route.page === "demo-compare" && ( + + )} + {route.page === "flow-chat-mock" && } {route.page === "tokens" && ( @@ -634,6 +698,10 @@ export function App() { /> )} + {route.page === "icons" && } + + {route.page === "skill" && } + {route.page === "subagent-ip" && } {route.page === "resources" && } diff --git a/design-system/apps/design-lab/src/components/LabComponentIndex.tsx b/design-system/apps/design-lab/src/components/LabComponentIndex.tsx index 2bb5fc1636..3792289a47 100644 --- a/design-system/apps/design-lab/src/components/LabComponentIndex.tsx +++ b/design-system/apps/design-lab/src/components/LabComponentIndex.tsx @@ -5,17 +5,19 @@ import { useI18n } from "../i18n"; import { getComponentCategoryLabel, getComponentDescription } from "../i18n/componentMetadata"; /* The component directory belongs to the navigation, not to a second index beside it: it hangs - under the Components route in the rail, the way the Foundations chapters hang under theirs. It - keeps its own search and its own scroll region, so a list this long never pushes the other - routes out of the rail. */ -export function LabComponentIndex({ selected }: { selected?: string }) { + under its route in the rail, the way the Foundations chapters hang under theirs. It keeps its own + search and its own scroll region, so a list this long never pushes the other routes out of the + rail. `scope` splits the catalog into the two surface tabs: Web and Mobile. */ +export function LabComponentIndex({ scope = "all", selected }: { scope?: "all" | "mobile" | "web"; selected?: string }) { const { t } = useI18n(); const [query, setQuery] = useState(""); const listRef = useRef(null); const activeLinkRef = useRef(null); - const categories = Array.from(new Set(componentRegistry.map(component => component.category))); - const normalizedQuery = query.trim().toLowerCase(); const catalogComponents = componentRegistry.filter(component => + scope === "all" ? true : scope === "mobile" ? component.category === "mobile" : component.category !== "mobile"); + const categories = Array.from(new Set(catalogComponents.map(component => component.category))); + const normalizedQuery = query.trim().toLowerCase(); + const results = catalogComponents.filter(component => `${component.name} ${component.category} ${component.description} ${getComponentDescription(component.name, component.description, t)} ${getComponentCategoryLabel(component.category, t)}`.toLowerCase().includes(normalizedQuery), ); @@ -42,10 +44,10 @@ export function LabComponentIndex({ selected }: { selected?: string }) { {/* The directory can be counted by looking, so the rail does not print the total — but a reader who cannot see the list still needs the filtered count as the query changes. The region stays live and comes off screen instead of out of the page. */} - {t("design.results", { count: catalogComponents.length })} + {t("design.results", { count: results.length })}