myshell-react-lib 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +268 -0
- package/dist/assets/audio-playing.json +3657 -0
- package/dist/index.cjs +9654 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1431 -0
- package/dist/index.d.ts +1431 -0
- package/dist/index.js +8788 -0
- package/dist/index.js.map +1 -0
- package/package.json +140 -0
- package/src/common/assets/audio-playing.json +3657 -0
- package/src/common/constants/constants.ts +24 -0
- package/src/common/constants/types/common.ts +10 -0
- package/src/common/hooks/useAudioPlayer.tsx +198 -0
- package/src/common/hooks/useDevice.ts +26 -0
- package/src/common/hooks/useNativeBridge.ts +42 -0
- package/src/common/hooks/useNotification.tsx +179 -0
- package/src/common/hooks/useWindowWidth.ts +19 -0
- package/src/common/utils/common-helper.ts +81 -0
- package/src/components/ItemDemo.tsx +15 -0
- package/src/components/accordion.tsx +126 -0
- package/src/components/alert-dialog.tsx +148 -0
- package/src/components/alert.tsx +65 -0
- package/src/components/aspect-ratio.tsx +7 -0
- package/src/components/audio-player.tsx +58 -0
- package/src/components/avatar.tsx +133 -0
- package/src/components/badge.tsx +65 -0
- package/src/components/button/button.styles.ts +258 -0
- package/src/components/button/button.tsx +215 -0
- package/src/components/button/icon-button.styles.ts +101 -0
- package/src/components/button/icon-button.tsx +100 -0
- package/src/components/button/index.tsx +3 -0
- package/src/components/button/link-button.tsx +184 -0
- package/src/components/cascader.tsx +175 -0
- package/src/components/checkbox.tsx +135 -0
- package/src/components/command.tsx +155 -0
- package/src/components/context-menu.tsx +198 -0
- package/src/components/count-down.tsx +83 -0
- package/src/components/custom-notification.tsx +95 -0
- package/src/components/dialog.tsx +158 -0
- package/src/components/drawer.tsx +116 -0
- package/src/components/dropdown-menu.tsx +196 -0
- package/src/components/energy-progress.tsx +55 -0
- package/src/components/form.tsx +201 -0
- package/src/components/group.tsx +9 -0
- package/src/components/guide.tsx +243 -0
- package/src/components/icon.tsx +89 -0
- package/src/components/icons/outline/DownIcon.tsx +18 -0
- package/src/components/icons/outline/FilterIcon.tsx +21 -0
- package/src/components/icons/outline/arrow-left.tsx +16 -0
- package/src/components/icons/outline/arrow-up-tray.tsx +16 -0
- package/src/components/icons/outline/check-circle.tsx +17 -0
- package/src/components/icons/outline/config.tsx +42 -0
- package/src/components/icons/outline/pencil-square.tsx +16 -0
- package/src/components/icons/outline/trash.tsx +17 -0
- package/src/components/icons/outline/window.tsx +16 -0
- package/src/components/icons/outline/x-circle.tsx +17 -0
- package/src/components/icons/outline/x-mark.tsx +16 -0
- package/src/components/icons/solid/audio-playing.tsx +31 -0
- package/src/components/icons/solid/caret-down.tsx +14 -0
- package/src/components/icons/solid/code.tsx +18 -0
- package/src/components/icons/solid/drag.tsx +14 -0
- package/src/components/icons/solid/phone.tsx +23 -0
- package/src/components/icons/solid/rectangle-group.tsx +14 -0
- package/src/components/image.tsx +151 -0
- package/src/components/input.tsx +118 -0
- package/src/components/label.tsx +26 -0
- package/src/components/link.tsx +123 -0
- package/src/components/marquee/index.css +15 -0
- package/src/components/marquee/marquee.tsx +220 -0
- package/src/components/masonry.tsx +138 -0
- package/src/components/menubar.tsx +234 -0
- package/src/components/mobile/m-tooltip.tsx +34 -0
- package/src/components/modal.tsx +561 -0
- package/src/components/navigation-bar.tsx +100 -0
- package/src/components/number-input.tsx +143 -0
- package/src/components/page-content.tsx +16 -0
- package/src/components/popover.tsx +191 -0
- package/src/components/progress.tsx +80 -0
- package/src/components/radio-group.tsx +44 -0
- package/src/components/scroll-area.tsx +49 -0
- package/src/components/search-bar.tsx +140 -0
- package/src/components/secondary-navigation-bar.tsx +307 -0
- package/src/components/select.tsx +273 -0
- package/src/components/separator.tsx +31 -0
- package/src/components/sheet.tsx +143 -0
- package/src/components/skeleton.tsx +20 -0
- package/src/components/slider.tsx +160 -0
- package/src/components/spinner.tsx +48 -0
- package/src/components/swiper/index.module.scss +88 -0
- package/src/components/swiper/index.tsx +319 -0
- package/src/components/switch.tsx +67 -0
- package/src/components/tabs.tsx +325 -0
- package/src/components/textarea.tsx +71 -0
- package/src/components/toast/toast.tsx +182 -0
- package/src/components/toast/toaster.tsx +160 -0
- package/src/components/toast/use-toast.tsx +248 -0
- package/src/components/toggle-group.tsx +64 -0
- package/src/components/toggle.tsx +46 -0
- package/src/components/tooltip.tsx +283 -0
- package/src/components/typography.tsx +437 -0
- package/src/index.ts +66 -0
- package/src/lib/utils.ts +62 -0
- package/src/stories/Accordion.stories.tsx +64 -0
- package/src/stories/AccordionItem.stories.tsx +48 -0
- package/src/stories/Avatar.stories.ts +58 -0
- package/src/stories/Badge.stories.tsx +40 -0
- package/src/stories/BannerSwiper.stories.tsx +102 -0
- package/src/stories/Button.stories.tsx +543 -0
- package/src/stories/Checkbox.stories.tsx +161 -0
- package/src/stories/Configure.mdx +341 -0
- package/src/stories/CssProperties.mdx +30 -0
- package/src/stories/Description.stories.ts +70 -0
- package/src/stories/Display.stories.ts +64 -0
- package/src/stories/FeaturedSwiper.stories.tsx +6978 -0
- package/src/stories/GridSwiper.stories.tsx +1407 -0
- package/src/stories/Guide.stories.tsx +247 -0
- package/src/stories/Heading.stories.ts +89 -0
- package/src/stories/Icon.stories.ts +77 -0
- package/src/stories/IconButton.stories.tsx +301 -0
- package/src/stories/IconTextButton.stories.ts +59 -0
- package/src/stories/Image.stories.ts +55 -0
- package/src/stories/Input.stories.tsx +203 -0
- package/src/stories/Modal.stories.tsx +144 -0
- package/src/stories/NavigationBar.stories.tsx +81 -0
- package/src/stories/Notification.stories.tsx +276 -0
- package/src/stories/Popover.stories.tsx +100 -0
- package/src/stories/SearchBar.stories.ts +43 -0
- package/src/stories/SecondaryNavigationBar.stories.tsx +199 -0
- package/src/stories/Select.stories.tsx +107 -0
- package/src/stories/Separator.stories.tsx +49 -0
- package/src/stories/Spinner.stories.tsx +48 -0
- package/src/stories/SubHeading.stories.ts +64 -0
- package/src/stories/Swich.stories.tsx +69 -0
- package/src/stories/Tabs.stories.tsx +90 -0
- package/src/stories/Text.stories.ts +78 -0
- package/src/stories/Textarea.stories.tsx +155 -0
- package/src/stories/Toast.stories.tsx +424 -0
- package/src/stories/Tooltip.stories.tsx +244 -0
- package/src/stories/ViewAutoSwiper.stories.tsx +1408 -0
- package/src/styles/components-dark.scss +212 -0
- package/src/styles/components-light.scss +210 -0
- package/src/styles/design-dark.scss +330 -0
- package/src/styles/design-light.scss +345 -0
- package/src/styles/design2-dark.scss +319 -0
- package/src/styles/design2-light.scss +364 -0
- package/src/styles/font.css +19 -0
- package/src/styles/global.scss +251 -0
- package/src/styles/md-viewer.scss +155 -0
- package/src/styles/new-tokens.scss +255 -0
- package/src/styles/tokens.scss +401 -0
- package/src/types/scss.d.ts +24 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable import/no-unused-modules */
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button } from '../components/button/button';
|
|
7
|
+
import { Modal, ModalBody, ModalFooter } from '../components/modal';
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Components/通用/Modal-弹窗',
|
|
11
|
+
component: Modal,
|
|
12
|
+
subcomponents: { ModalContent: ModalBody as any },
|
|
13
|
+
parameters: {
|
|
14
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
15
|
+
layout: 'centered',
|
|
16
|
+
},
|
|
17
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
args: {
|
|
20
|
+
// open: true
|
|
21
|
+
},
|
|
22
|
+
} satisfies Meta<typeof Modal>;
|
|
23
|
+
export default meta;
|
|
24
|
+
|
|
25
|
+
type Story = StoryObj<typeof meta>;
|
|
26
|
+
|
|
27
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
28
|
+
export const Demo: Story = {
|
|
29
|
+
args: {
|
|
30
|
+
...meta.args, // 继承默认参数
|
|
31
|
+
},
|
|
32
|
+
render: (args) => {
|
|
33
|
+
const [open, setOpen] = useState(false);
|
|
34
|
+
const [open1, setOpen1] = useState(false);
|
|
35
|
+
const [open2, setOpen2] = useState(false);
|
|
36
|
+
const [open3, setOpen3] = useState(false);
|
|
37
|
+
const [open4, setOpen4] = useState(false);
|
|
38
|
+
const [open5, setOpen5] = useState(false);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="w-[40vw] px-3 rounded-md space-y-2">
|
|
42
|
+
<div className="w-full text-sm">
|
|
43
|
+
先将旧版chakra
|
|
44
|
+
modal归拢到此组件,还不是特别完善,比如有哪几种宽度,哪几种固定样式等,后面有空继续加
|
|
45
|
+
</div>
|
|
46
|
+
<div className="flex flex-col justify-center items-center space-y-2">
|
|
47
|
+
<Button onClick={() => setOpen(true)}>Open</Button>
|
|
48
|
+
<Button onClick={() => setOpen1(true)}>Open 带 Footer</Button>
|
|
49
|
+
<Button onClick={() => setOpen2(true)}>Open Notification Info</Button>
|
|
50
|
+
<Button
|
|
51
|
+
className="bg-Colors-Background-Success-Bolder hover:bg-Colors-Background-Success-Hover"
|
|
52
|
+
onClick={() => setOpen3(true)}
|
|
53
|
+
>
|
|
54
|
+
Open Notification Success
|
|
55
|
+
</Button>
|
|
56
|
+
<Button onClick={() => setOpen4(true)}>
|
|
57
|
+
Open Notification Warning
|
|
58
|
+
</Button>
|
|
59
|
+
<Button color="error" onClick={() => setOpen5(true)}>
|
|
60
|
+
Open Notification Error
|
|
61
|
+
</Button>
|
|
62
|
+
</div>
|
|
63
|
+
<Modal
|
|
64
|
+
open={open5}
|
|
65
|
+
{...args}
|
|
66
|
+
isNotification
|
|
67
|
+
title="Info Notification"
|
|
68
|
+
state="error"
|
|
69
|
+
description='This is an info description which directly indicates a neutral informative change or action. (e.g., "We are
|
|
70
|
+
providing new services for all developers.")'
|
|
71
|
+
onClose={() => setOpen5(false)}
|
|
72
|
+
onConfirm={() => {
|
|
73
|
+
console.log('confirm');
|
|
74
|
+
setOpen5(false);
|
|
75
|
+
}}
|
|
76
|
+
cancelText="cancel"
|
|
77
|
+
confirmText="confirm"
|
|
78
|
+
/>
|
|
79
|
+
<Modal
|
|
80
|
+
open={open4}
|
|
81
|
+
{...args}
|
|
82
|
+
isNotification
|
|
83
|
+
title="Info Notification"
|
|
84
|
+
state="warning"
|
|
85
|
+
description='This is an info description which directly indicates a neutral informative change or action. (e.g., "We are
|
|
86
|
+
providing new services for all developers.")'
|
|
87
|
+
onClose={() => setOpen4(false)}
|
|
88
|
+
onConfirm={() => {
|
|
89
|
+
console.log('confirm');
|
|
90
|
+
setOpen4(false);
|
|
91
|
+
}}
|
|
92
|
+
cancelText="cancel"
|
|
93
|
+
confirmText="confirm"
|
|
94
|
+
/>
|
|
95
|
+
<Modal
|
|
96
|
+
open={open3}
|
|
97
|
+
{...args}
|
|
98
|
+
isNotification
|
|
99
|
+
title="Info Notification"
|
|
100
|
+
state="success"
|
|
101
|
+
description='This is an info description which directly indicates a neutral informative change or action. (e.g., "We are
|
|
102
|
+
providing new services for all developers.")'
|
|
103
|
+
onClose={() => setOpen3(false)}
|
|
104
|
+
onConfirm={() => {
|
|
105
|
+
console.log('confirm');
|
|
106
|
+
setOpen3(false);
|
|
107
|
+
}}
|
|
108
|
+
cancelText="cancel"
|
|
109
|
+
confirmText="confirm"
|
|
110
|
+
/>
|
|
111
|
+
<Modal
|
|
112
|
+
open={open2}
|
|
113
|
+
{...args}
|
|
114
|
+
isNotification
|
|
115
|
+
title="Info Notification"
|
|
116
|
+
state="info"
|
|
117
|
+
description='This is an info description which directly indicates a neutral informative change or action. (e.g., "We are
|
|
118
|
+
providing new services for all developers.")'
|
|
119
|
+
onClose={() => setOpen2(false)}
|
|
120
|
+
onConfirm={() => {
|
|
121
|
+
console.log('confirm');
|
|
122
|
+
setOpen2(false);
|
|
123
|
+
}}
|
|
124
|
+
cancelText="cancel"
|
|
125
|
+
confirmText="confirm"
|
|
126
|
+
/>
|
|
127
|
+
<Modal open={open} {...args} onClose={() => setOpen(false)}>
|
|
128
|
+
<ModalBody title="Modal Title">
|
|
129
|
+
<div className="p-6">Modal Content</div>
|
|
130
|
+
</ModalBody>
|
|
131
|
+
</Modal>
|
|
132
|
+
<Modal open={open1} {...args} onClose={() => setOpen1(false)}>
|
|
133
|
+
<ModalBody title="Modal Title">
|
|
134
|
+
<div className="p-6">Modal Content</div>
|
|
135
|
+
<ModalFooter className="space-x-2">
|
|
136
|
+
<Button variant="secondary">关闭</Button>
|
|
137
|
+
<Button>确定</Button>
|
|
138
|
+
</ModalFooter>
|
|
139
|
+
</ModalBody>
|
|
140
|
+
</Modal>
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { NavigationBar } from '../components/navigation-bar';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Components/通用/NavigationBar-一级页面导航栏',
|
|
9
|
+
component: NavigationBar,
|
|
10
|
+
parameters: {
|
|
11
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
12
|
+
layout: 'centered',
|
|
13
|
+
nextjs: {
|
|
14
|
+
appDirectory: true, // 如果组件里有用到router next/navigation,则需要设置此配置
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
|
|
20
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
21
|
+
args: {
|
|
22
|
+
title: 'Title',
|
|
23
|
+
showSearchBar: false,
|
|
24
|
+
searchValue: '',
|
|
25
|
+
energy: 0,
|
|
26
|
+
dailyEnergy: 0,
|
|
27
|
+
},
|
|
28
|
+
argTypes: {
|
|
29
|
+
title: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
},
|
|
32
|
+
energy: {
|
|
33
|
+
control: 'number',
|
|
34
|
+
},
|
|
35
|
+
dailyEnergy: {
|
|
36
|
+
control: 'number',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
} satisfies Meta<typeof NavigationBar>;
|
|
40
|
+
|
|
41
|
+
export default meta;
|
|
42
|
+
// export const Default: StoryObj<typeof meta> = {
|
|
43
|
+
// // 这里不需要设置 args,因为它会继承 meta 中的 args
|
|
44
|
+
// };
|
|
45
|
+
type Story = StoryObj<typeof meta>;
|
|
46
|
+
|
|
47
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
48
|
+
export const NavigationBarDemo: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
...meta.args, // 继承默认参数
|
|
51
|
+
},
|
|
52
|
+
render: (args) => {
|
|
53
|
+
return (
|
|
54
|
+
<div className="min-w-[60vw] w-full py-6 rounded-md flex flex-col justify-center items-center bg-Colors-Background-Neutral-Primary-Default">
|
|
55
|
+
<div className="w-full">
|
|
56
|
+
<div className="w-full mt-6">Default</div>
|
|
57
|
+
<NavigationBar {...args} />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<div className="w-full">
|
|
61
|
+
<div className="w-full mt-6">search bar</div>
|
|
62
|
+
<NavigationBar {...args} showSearchBar>
|
|
63
|
+
children
|
|
64
|
+
</NavigationBar>
|
|
65
|
+
</div>
|
|
66
|
+
<div className="w-full">
|
|
67
|
+
<div className="w-full mt-6">search bar</div>
|
|
68
|
+
<NavigationBar {...args} showSearchBar />
|
|
69
|
+
</div>
|
|
70
|
+
<div className="w-full">
|
|
71
|
+
<div className="w-full mt-6">自定义</div>
|
|
72
|
+
<NavigationBar {...args}>children</NavigationBar>
|
|
73
|
+
</div>
|
|
74
|
+
<div className="w-full">
|
|
75
|
+
<div className="w-full mt-6">EnergyProgress</div>
|
|
76
|
+
<NavigationBar {...args} dailyEnergy={20} energy={10}></NavigationBar>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
/* eslint-disable import/no-unused-modules */
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Toaster } from 'react-hot-toast';
|
|
5
|
+
|
|
6
|
+
import { Button } from '../components/button/button';
|
|
7
|
+
import { useNotification } from '../common/hooks/useNotification';
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'Components/反馈/Notification-全局提示',
|
|
11
|
+
// component: MessageDemo,
|
|
12
|
+
parameters: {
|
|
13
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'centered',
|
|
15
|
+
},
|
|
16
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
args: {},
|
|
19
|
+
argTypes: {},
|
|
20
|
+
} satisfies Meta;
|
|
21
|
+
export default meta;
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
25
|
+
export const Demo: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
...meta.args, // 继承默认参数
|
|
28
|
+
},
|
|
29
|
+
render: (args) => {
|
|
30
|
+
const { error, info, success, warning, message } = useNotification();
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="w-[70vw] min-h-[200px] py-10 px-3 rounded-md space-y-3">
|
|
34
|
+
<Toaster
|
|
35
|
+
position="top-center"
|
|
36
|
+
toastOptions={{
|
|
37
|
+
duration: 3000,
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
<div className="w-full grid grid-cols-4 gap-4">
|
|
42
|
+
<div className="flex flex-col space-y-2 justify-center items-center">
|
|
43
|
+
<div> State</div>
|
|
44
|
+
<Button
|
|
45
|
+
onClick={() => {
|
|
46
|
+
info({ content: 'This is a message!' });
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
info message
|
|
50
|
+
</Button>
|
|
51
|
+
|
|
52
|
+
<Button
|
|
53
|
+
onClick={() => {
|
|
54
|
+
success({ content: 'This is a message!' });
|
|
55
|
+
}}
|
|
56
|
+
className="bg-Colors-Background-Success-Bolder"
|
|
57
|
+
>
|
|
58
|
+
success message
|
|
59
|
+
</Button>
|
|
60
|
+
<Button
|
|
61
|
+
onClick={() => {
|
|
62
|
+
warning({ content: 'This is a message!' });
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
warning message
|
|
66
|
+
</Button>
|
|
67
|
+
<Button
|
|
68
|
+
onClick={() => {
|
|
69
|
+
error({ content: 'This is a message!' });
|
|
70
|
+
}}
|
|
71
|
+
color="error"
|
|
72
|
+
>
|
|
73
|
+
error message
|
|
74
|
+
</Button>
|
|
75
|
+
<Button
|
|
76
|
+
onClick={() => {
|
|
77
|
+
message({ content: 'This is a message!' });
|
|
78
|
+
}}
|
|
79
|
+
variant="secondary"
|
|
80
|
+
>
|
|
81
|
+
normal message
|
|
82
|
+
</Button>
|
|
83
|
+
</div>
|
|
84
|
+
<div className="flex flex-col space-y-2 justify-center items-center">
|
|
85
|
+
<div> Plain button</div>
|
|
86
|
+
<Button
|
|
87
|
+
onClick={() => {
|
|
88
|
+
info(
|
|
89
|
+
{
|
|
90
|
+
content: 'This is a message!',
|
|
91
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
92
|
+
},
|
|
93
|
+
30000
|
|
94
|
+
);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
info message
|
|
98
|
+
</Button>
|
|
99
|
+
|
|
100
|
+
<Button
|
|
101
|
+
onClick={() => {
|
|
102
|
+
success({
|
|
103
|
+
content: 'This is a message!',
|
|
104
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
105
|
+
});
|
|
106
|
+
}}
|
|
107
|
+
className="bg-Colors-Background-Success-Bolder"
|
|
108
|
+
>
|
|
109
|
+
success message
|
|
110
|
+
</Button>
|
|
111
|
+
<Button
|
|
112
|
+
onClick={() => {
|
|
113
|
+
warning({
|
|
114
|
+
content: 'This is a message!',
|
|
115
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
116
|
+
});
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
warning message
|
|
120
|
+
</Button>
|
|
121
|
+
<Button
|
|
122
|
+
onClick={() => {
|
|
123
|
+
error({
|
|
124
|
+
content: 'This is a message!',
|
|
125
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
126
|
+
});
|
|
127
|
+
}}
|
|
128
|
+
color="error"
|
|
129
|
+
>
|
|
130
|
+
error message
|
|
131
|
+
</Button>
|
|
132
|
+
<Button
|
|
133
|
+
onClick={() => {
|
|
134
|
+
message({
|
|
135
|
+
content: 'This is a message!',
|
|
136
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
137
|
+
});
|
|
138
|
+
}}
|
|
139
|
+
variant="secondary"
|
|
140
|
+
>
|
|
141
|
+
normal message
|
|
142
|
+
</Button>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div className="flex flex-col space-y-2 justify-center items-center">
|
|
146
|
+
<div> Close button</div>
|
|
147
|
+
<Button
|
|
148
|
+
onClick={() => {
|
|
149
|
+
info({ content: 'This is a message!', isClosable: true });
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
info message
|
|
153
|
+
</Button>
|
|
154
|
+
|
|
155
|
+
<Button
|
|
156
|
+
onClick={() => {
|
|
157
|
+
success({ content: 'This is a message!', isClosable: true });
|
|
158
|
+
}}
|
|
159
|
+
className="bg-Colors-Background-Success-Bolder"
|
|
160
|
+
>
|
|
161
|
+
success message
|
|
162
|
+
</Button>
|
|
163
|
+
<Button
|
|
164
|
+
onClick={() => {
|
|
165
|
+
warning({ content: 'This is a message!', isClosable: true });
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
warning message
|
|
169
|
+
</Button>
|
|
170
|
+
<Button
|
|
171
|
+
onClick={() => {
|
|
172
|
+
error({ content: 'This is a message!', isClosable: true });
|
|
173
|
+
}}
|
|
174
|
+
color="error"
|
|
175
|
+
>
|
|
176
|
+
error message
|
|
177
|
+
</Button>
|
|
178
|
+
<Button
|
|
179
|
+
onClick={() => {
|
|
180
|
+
message({ content: 'This is a message!', isClosable: true });
|
|
181
|
+
}}
|
|
182
|
+
variant="secondary"
|
|
183
|
+
>
|
|
184
|
+
normal message
|
|
185
|
+
</Button>
|
|
186
|
+
</div>
|
|
187
|
+
<div className="flex flex-col space-y-2 justify-center items-center">
|
|
188
|
+
<div> Plain&Close button</div>
|
|
189
|
+
<Button
|
|
190
|
+
onClick={() => {
|
|
191
|
+
info(
|
|
192
|
+
{
|
|
193
|
+
content: 'This is a message!',
|
|
194
|
+
action: (
|
|
195
|
+
<Button
|
|
196
|
+
variant={'plain'}
|
|
197
|
+
size={'md'}
|
|
198
|
+
className="font-normal"
|
|
199
|
+
>
|
|
200
|
+
Open
|
|
201
|
+
</Button>
|
|
202
|
+
),
|
|
203
|
+
isClosable: true,
|
|
204
|
+
},
|
|
205
|
+
300000000
|
|
206
|
+
);
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
info message
|
|
210
|
+
</Button>
|
|
211
|
+
|
|
212
|
+
<Button
|
|
213
|
+
onClick={() => {
|
|
214
|
+
success({
|
|
215
|
+
content: 'This is a message!',
|
|
216
|
+
action: <Button variant={'plain'}>Open</Button>,
|
|
217
|
+
isClosable: true,
|
|
218
|
+
});
|
|
219
|
+
}}
|
|
220
|
+
className="bg-Colors-Background-Success-Bolder"
|
|
221
|
+
>
|
|
222
|
+
success message
|
|
223
|
+
</Button>
|
|
224
|
+
<Button
|
|
225
|
+
onClick={() => {
|
|
226
|
+
warning({
|
|
227
|
+
content: 'This is a message!',
|
|
228
|
+
action: (
|
|
229
|
+
<Button variant={'plain'} className="font-normal">
|
|
230
|
+
Open
|
|
231
|
+
</Button>
|
|
232
|
+
),
|
|
233
|
+
isClosable: true,
|
|
234
|
+
});
|
|
235
|
+
}}
|
|
236
|
+
>
|
|
237
|
+
warning message
|
|
238
|
+
</Button>
|
|
239
|
+
<Button
|
|
240
|
+
onClick={() => {
|
|
241
|
+
error({
|
|
242
|
+
content: 'This is a message!',
|
|
243
|
+
action: (
|
|
244
|
+
<Button variant={'plain'} className="font-normal">
|
|
245
|
+
Open
|
|
246
|
+
</Button>
|
|
247
|
+
),
|
|
248
|
+
isClosable: true,
|
|
249
|
+
});
|
|
250
|
+
}}
|
|
251
|
+
color="error"
|
|
252
|
+
>
|
|
253
|
+
error message
|
|
254
|
+
</Button>
|
|
255
|
+
<Button
|
|
256
|
+
onClick={() => {
|
|
257
|
+
message({
|
|
258
|
+
content: 'This is a message!',
|
|
259
|
+
action: (
|
|
260
|
+
<Button variant={'plain'} className="font-normal">
|
|
261
|
+
Open
|
|
262
|
+
</Button>
|
|
263
|
+
),
|
|
264
|
+
isClosable: true,
|
|
265
|
+
});
|
|
266
|
+
}}
|
|
267
|
+
variant="secondary"
|
|
268
|
+
>
|
|
269
|
+
normal message
|
|
270
|
+
</Button>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
</div>
|
|
274
|
+
);
|
|
275
|
+
},
|
|
276
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/* eslint-disable import/no-unused-modules */
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Button } from '../components/button';
|
|
6
|
+
import { Popover } from '../components/popover';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Components/数据展示/Popover-气泡',
|
|
10
|
+
component: Popover,
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'centered',
|
|
15
|
+
},
|
|
16
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
args: {
|
|
19
|
+
showArrow: true,
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
variant: {
|
|
23
|
+
control: 'select',
|
|
24
|
+
description: '气泡类型',
|
|
25
|
+
options: ['default', 'info'],
|
|
26
|
+
},
|
|
27
|
+
align: {
|
|
28
|
+
control: 'select',
|
|
29
|
+
description: '箭头位置',
|
|
30
|
+
options: ['start', 'center', 'end'],
|
|
31
|
+
},
|
|
32
|
+
side: {
|
|
33
|
+
control: 'select',
|
|
34
|
+
description: '气泡方位',
|
|
35
|
+
options: ['top', 'right', 'bottom', 'left'],
|
|
36
|
+
},
|
|
37
|
+
sideOffset: {
|
|
38
|
+
control: 'number',
|
|
39
|
+
description: '偏移距离',
|
|
40
|
+
},
|
|
41
|
+
showArrow: {
|
|
42
|
+
control: 'boolean',
|
|
43
|
+
description: '是否显示箭头',
|
|
44
|
+
},
|
|
45
|
+
openChangeCallback: {
|
|
46
|
+
control: 'object',
|
|
47
|
+
description: '打开&关闭的回调函数',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
} satisfies Meta<typeof Popover>;
|
|
51
|
+
export default meta;
|
|
52
|
+
|
|
53
|
+
type Story = StoryObj<typeof meta>;
|
|
54
|
+
|
|
55
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
56
|
+
export const Demo: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
// 继承默认参数
|
|
59
|
+
...meta.args,
|
|
60
|
+
showArrow: true,
|
|
61
|
+
},
|
|
62
|
+
render: (args) => {
|
|
63
|
+
return (
|
|
64
|
+
<div className="w-[40vw] h-[200px] px-3 rounded-md flex justify-center items-center flex-col space-y-8">
|
|
65
|
+
<Popover
|
|
66
|
+
{...args}
|
|
67
|
+
open
|
|
68
|
+
content="Yes. this is Demo content."
|
|
69
|
+
openChangeCallback={(open) => console.log('openChangeCallback', open)}
|
|
70
|
+
>
|
|
71
|
+
<Button>default popover</Button>
|
|
72
|
+
</Popover>
|
|
73
|
+
<Popover
|
|
74
|
+
{...args}
|
|
75
|
+
variant="info"
|
|
76
|
+
content="Yes. this is Demo content."
|
|
77
|
+
openChangeCallback={(open) => console.log('openChangeCallback', open)}
|
|
78
|
+
>
|
|
79
|
+
info popover
|
|
80
|
+
</Popover>
|
|
81
|
+
<Popover
|
|
82
|
+
{...args}
|
|
83
|
+
open
|
|
84
|
+
content="Yes. this is Demo content."
|
|
85
|
+
openChangeCallback={(open) => console.log('openChangeCallback', open)}
|
|
86
|
+
>
|
|
87
|
+
<Button>default popover click</Button>
|
|
88
|
+
</Popover>
|
|
89
|
+
<Popover
|
|
90
|
+
{...args}
|
|
91
|
+
variant="info"
|
|
92
|
+
content="Yes. this is Demo content."
|
|
93
|
+
openChangeCallback={(open) => console.log('openChangeCallback', open)}
|
|
94
|
+
>
|
|
95
|
+
info popover click
|
|
96
|
+
</Popover>
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { SearchBar } from '@/components/search-bar';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Components/表单/SearchBar-搜索查询',
|
|
8
|
+
component: SearchBar,
|
|
9
|
+
parameters: {
|
|
10
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
11
|
+
layout: 'centered',
|
|
12
|
+
},
|
|
13
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
|
|
16
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
17
|
+
args: {
|
|
18
|
+
placeholder: 'Search',
|
|
19
|
+
onSearchChange: (value: string) => {
|
|
20
|
+
console.log(value);
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
// 定义size为select类型的控件
|
|
25
|
+
size: {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: ['sm', 'md'],
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
} satisfies Meta<typeof SearchBar>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
// export const Default: StoryObj<typeof meta> = {
|
|
34
|
+
// // 这里不需要设置 args,因为它会继承 meta 中的 args
|
|
35
|
+
// };
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
39
|
+
export const Demo: Story = {
|
|
40
|
+
args: {
|
|
41
|
+
...meta.args, // 继承默认参数
|
|
42
|
+
},
|
|
43
|
+
};
|