From bfe5541e56f68b74fd41974c804f8e7ac1ff9f2a Mon Sep 17 00:00:00 2001 From: shu Date: Thu, 22 Oct 2026 13:03:06 +0800 Subject: feat: 初始化 Astryx React 应用模板 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 基于 Vite 8、React 19、TypeScript 6、React Router 7 和 Astryx 0.7.2 搭建完整的中文应用起始模板,包含可直接运行的应用外壳与示例页面。 主要变更: - 使用 Astryx 构建 AppShell、顶部导航、可折叠侧边栏和响应式移动端抽屉。 - 接入 Astryx neutral 主题与中文语言包,支持明暗主题切换并持久化偏好。 - 新增概览、组件、图标、关于和 404 页面,统一使用共享页面框架。 - 将页面路由、侧边栏名称、图标和active状态合并到 app-routes.tsx, 路由与导航由同一份配置生成,避免重复维护。 - 新增根目录 app.config.ts,可在 browser/history 与 hash 路由模式之间切换; 当前保留 hash 模式配置。 - 组件页提供 14 个可交互组合场景,覆盖全部 173 个 Astryx 组件, 包含按钮、表单、表格、导航、聊天、对话框、菜单、命令面板和 Toast 等。 - 新增图标页面,支持浏览 29 个 Astryx 语义图标和 1903 个 Lucide 图标, 提供搜索、分页、图标集切换和点击复制用法。 - 对组件页和图标页实施路由级懒加载,并按 React、React Router 拆分 vendor chunk,降低首屏入口体积并改善长期缓存。 - 接入 React Router 的 LinkProvider,保证 Astryx 链接、导航和按钮在两种 路由模式下均使用客户端导航。 - 配置 pnpm 供应链策略例外与依赖构建许可,锁定可以正常安装的依赖版本。 - 补充 README,记录项目结构、脚本、组件展厅、图标页、路由模式与构建策略。 验证结果: - pnpm build 通过 - pnpm lint 0 warnings - browser 与 hash 两种路由模式的页面和侧边栏导航均已验证 --- theme.template.ts | 399 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) create mode 100644 theme.template.ts (limited to 'theme.template.ts') diff --git a/theme.template.ts b/theme.template.ts new file mode 100644 index 0000000..64b61a8 --- /dev/null +++ b/theme.template.ts @@ -0,0 +1,399 @@ +/** + * Astryx theme template — every `defineTheme` field, with a note on what it + * does and when to reach for it. + * + * Only `name` is required. Delete what you do not need: the values here are + * placeholders that reproduce the built-in defaults, so a field you leave + * untouched changes nothing. + * + * Each section names the CLI command that prints the authoritative reference + * for it. These comments are a map; the CLI is the territory — it reads the + * same source the components do. `astryx docs` lists every topic. + * + * ═══════════════════════════════════════════════════════════════════════ + * HOW A THEME IS CONSUMED + * ═══════════════════════════════════════════════════════════════════════ + * + * 1. WRAP THE APP. A theme does nothing until it is provided. + * + * import {Theme} from '@astryxdesign/core/theme'; + * import {myTheme} from './theme'; + * + * // 'system' | 'light' | 'dark' + * + * + * + * `system` follows the OS. Nest a second `` to give one region its + * own theme or mode — a dark sidebar inside a light page. + * + * 2. SHIP THE FONTS YOU NAME. Astryx sets the `--font-family-*` tokens; it + * never loads a font file, so use whatever typeface the design needs and + * load it yourself. Either add it to your app's : + * + * + * + * + * or self-host it in your global CSS: + * + * @font-face { + * font-family: 'Inter'; + * src: url('/fonts/Inter.woff2') format('woff2'); + * font-weight: 100 900; + * font-display: swap; + * } + * + * Always give `fallbacks` as well. A named family with no file loads + * nothing and warns about nothing — the fallback silently becomes your + * theme. + * + * 3. BUILD IT FOR PRODUCTION. + * + * astryx theme build src/theme.ts + * + * writes `.css` (tokens, component overrides and prose styles in + * `@scope` rules), `.js` (the theme with `__built: true` and + * pre-resolved values), `.d.ts`, and `.variants.d.ts` when the + * theme adds custom prop values. Import the module and the CSS together: + * + * import {myThemeTheme} from './theme/my-theme'; + * import './theme/my-theme.css'; + * + * Unbuilt, `` injects a