diff options
| author | shu <nvcsadjkojf@outlook.com> | 2026-10-22 13:03:06 +0800 |
|---|---|---|
| committer | shu <nvcsadjkojf@outlook.com> | 2026-10-22 13:03:06 +0800 |
| commit | bfe5541e56f68b74fd41974c804f8e7ac1ff9f2a (patch) | |
| tree | 5f5026082ad8d87af02500bcb13d6fbdc8bfa77a /src/demos/DialogsDemo.tsx | |
基于 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 两种路由模式的页面和侧边栏导航均已验证
Diffstat (limited to 'src/demos/DialogsDemo.tsx')
| -rw-r--r-- | src/demos/DialogsDemo.tsx | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/demos/DialogsDemo.tsx b/src/demos/DialogsDemo.tsx new file mode 100644 index 0000000..1b887df --- /dev/null +++ b/src/demos/DialogsDemo.tsx @@ -0,0 +1,95 @@ +import { useState } from 'react' +import { BottomSheet } from '@astryxdesign/core/BottomSheet' +import { Button } from '@astryxdesign/core/Button' +import { Dialog, DialogHeader } from '@astryxdesign/core/Dialog' +import { Drawer, DrawerHeader } from '@astryxdesign/core/Drawer' +import { HStack } from '@astryxdesign/core/HStack' +import { Layout, LayoutContent } from '@astryxdesign/core/Layout' +import { Section } from '@astryxdesign/core/Section' +import { Heading } from '@astryxdesign/core/Heading' +import { Text } from '@astryxdesign/core/Text' +import { VStack } from '@astryxdesign/core/VStack' + +type ActiveLayer = 'dialog' | 'drawer' | 'sheet' | null + +export function DialogsDemo() { + const [active, setActive] = useState<ActiveLayer>(null) + + return ( + <> + <HStack gap={2} wrap="wrap"> + <Button label="打开对话框" onClick={() => setActive('dialog')} /> + <Button + label="打开抽屉" + variant="secondary" + onClick={() => setActive('drawer')} + /> + <Button + label="打开底部面板" + variant="secondary" + onClick={() => setActive('sheet')} + /> + </HStack> + + <Dialog + isOpen={active === 'dialog'} + onOpenChange={(open) => setActive(open ? 'dialog' : null)}> + <Layout + header={ + <DialogHeader + title="确认发布" + onOpenChange={(open) => setActive(open ? 'dialog' : null)} + /> + } + content={ + <LayoutContent> + <Text type="body" as="p"> + 发布后,当前版本会立即对全部用户可见。你仍然可以稍后回滚。 + </Text> + </LayoutContent> + } + /> + </Dialog> + + <Drawer + isOpen={active === 'drawer'} + onOpenChange={(open) => setActive(open ? 'drawer' : null)} + label="项目详情" + width={360}> + <Layout + header={ + <DrawerHeader + title="项目详情" + onOpenChange={(open) => setActive(open ? 'drawer' : null)} + /> + } + content={ + <LayoutContent> + <VStack gap={2}> + <Heading level={3}>Astryx 起始模板</Heading> + <Text type="body" color="secondary" as="p"> + 抽屉适合承载不打断主流程的详细信息和次要操作。 + </Text> + </VStack> + </LayoutContent> + } + /> + </Drawer> + + <BottomSheet + isOpen={active === 'sheet'} + onOpenChange={(open) => setActive(open ? 'sheet' : null)} + label="筛选"> + <Section padding={4}> + <VStack gap={3}> + <Heading level={3}>筛选条件</Heading> + <Text type="body" color="secondary" as="p"> + 底部面板适合移动端上的快速筛选和短操作。 + </Text> + <Button label="应用筛选" onClick={() => setActive(null)} /> + </VStack> + </Section> + </BottomSheet> + </> + ) +} |
