blob: 1b887df7ed74be148c9e661affdea57dde64b806 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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>
</>
)
}
|