aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/demos/MenusDemo.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/MenusDemo.tsx')
-rw-r--r--src/demos/MenusDemo.tsx97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/demos/MenusDemo.tsx b/src/demos/MenusDemo.tsx
new file mode 100644
index 0000000..c928e6f
--- /dev/null
+++ b/src/demos/MenusDemo.tsx
@@ -0,0 +1,97 @@
+import { useState } from 'react'
+import { Avatar } from '@astryxdesign/core/Avatar'
+import { Button } from '@astryxdesign/core/Button'
+import { Card } from '@astryxdesign/core/Card'
+import { ContextMenu } from '@astryxdesign/core/ContextMenu'
+import { DropdownMenu } from '@astryxdesign/core/DropdownMenu'
+import { HStack } from '@astryxdesign/core/HStack'
+import { Heading } from '@astryxdesign/core/Heading'
+import { HoverCard } from '@astryxdesign/core/HoverCard'
+import { MoreMenu } from '@astryxdesign/core/MoreMenu'
+import { Popover } from '@astryxdesign/core/Popover'
+import { Text } from '@astryxdesign/core/Text'
+import { Tooltip } from '@astryxdesign/core/Tooltip'
+import { VStack } from '@astryxdesign/core/VStack'
+
+export function MenusDemo() {
+ const [popoverOpen, setPopoverOpen] = useState(false)
+
+ return (
+ <VStack gap={4}>
+ <HStack gap={2} wrap="wrap" vAlign="center">
+ <DropdownMenu
+ button={{ label: '操作菜单' }}
+ items={[
+ { label: '编辑', onClick: () => {} },
+ { label: '复制', onClick: () => {} },
+ { label: '删除', onClick: () => {} },
+ ]}
+ />
+ <MoreMenu
+ items={[
+ { label: '导出', onClick: () => {} },
+ { label: '分享', onClick: () => {} },
+ { label: '归档', onClick: () => {} },
+ ]}
+ />
+ <Tooltip content="这是一段提示文字" placement="above">
+ <Button label="悬停查看提示" variant="secondary" />
+ </Tooltip>
+ <Popover
+ isOpen={popoverOpen}
+ onOpenChange={setPopoverOpen}
+ hasAutoFocus={false}
+ placement="below"
+ label="设置"
+ width={260}
+ content={
+ <VStack gap={2}>
+ <Heading level={4}>快捷设置</Heading>
+ <Text type="body" color="secondary" as="p">
+ 弹层可以承载简短设置、筛选或上下文信息。
+ </Text>
+ </VStack>
+ }>
+ <Button label="打开浮层" variant="secondary" />
+ </Popover>
+ <HoverCard
+ placement="above"
+ content={
+ <VStack gap={2} width={220}>
+ <HStack gap={2} vAlign="center">
+ <Avatar name="林晓" size="md" />
+ <VStack gap={0}>
+ <Heading level={5}>林晓</Heading>
+ <Text type="supporting" size="sm">
+ 产品设计
+ </Text>
+ </VStack>
+ </HStack>
+ <Text type="body" color="secondary" as="p">
+ 专注于设计系统与复杂交互体验。
+ </Text>
+ </VStack>
+ }>
+ <Button label="悬停查看资料" variant="ghost" />
+ </HoverCard>
+ </HStack>
+
+ <ContextMenu
+ presentation="adaptive"
+ items={[
+ { label: '剪切', onClick: () => {} },
+ { label: '复制', onClick: () => {} },
+ { label: '粘贴', onClick: () => {} },
+ ]}>
+ <Card padding={4}>
+ <VStack gap={1} hAlign="center">
+ <Text type="label">右键或长按此区域</Text>
+ <Text type="supporting" size="sm">
+ 打开上下文菜单
+ </Text>
+ </VStack>
+ </Card>
+ </ContextMenu>
+ </VStack>
+ )
+}