aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/demos/DialogsDemo.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/DialogsDemo.tsx')
-rw-r--r--src/demos/DialogsDemo.tsx95
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>
+ </>
+ )
+}