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.
Files changed (151) hide show
  1. package/README.md +268 -0
  2. package/dist/assets/audio-playing.json +3657 -0
  3. package/dist/index.cjs +9654 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1431 -0
  6. package/dist/index.d.ts +1431 -0
  7. package/dist/index.js +8788 -0
  8. package/dist/index.js.map +1 -0
  9. package/package.json +140 -0
  10. package/src/common/assets/audio-playing.json +3657 -0
  11. package/src/common/constants/constants.ts +24 -0
  12. package/src/common/constants/types/common.ts +10 -0
  13. package/src/common/hooks/useAudioPlayer.tsx +198 -0
  14. package/src/common/hooks/useDevice.ts +26 -0
  15. package/src/common/hooks/useNativeBridge.ts +42 -0
  16. package/src/common/hooks/useNotification.tsx +179 -0
  17. package/src/common/hooks/useWindowWidth.ts +19 -0
  18. package/src/common/utils/common-helper.ts +81 -0
  19. package/src/components/ItemDemo.tsx +15 -0
  20. package/src/components/accordion.tsx +126 -0
  21. package/src/components/alert-dialog.tsx +148 -0
  22. package/src/components/alert.tsx +65 -0
  23. package/src/components/aspect-ratio.tsx +7 -0
  24. package/src/components/audio-player.tsx +58 -0
  25. package/src/components/avatar.tsx +133 -0
  26. package/src/components/badge.tsx +65 -0
  27. package/src/components/button/button.styles.ts +258 -0
  28. package/src/components/button/button.tsx +215 -0
  29. package/src/components/button/icon-button.styles.ts +101 -0
  30. package/src/components/button/icon-button.tsx +100 -0
  31. package/src/components/button/index.tsx +3 -0
  32. package/src/components/button/link-button.tsx +184 -0
  33. package/src/components/cascader.tsx +175 -0
  34. package/src/components/checkbox.tsx +135 -0
  35. package/src/components/command.tsx +155 -0
  36. package/src/components/context-menu.tsx +198 -0
  37. package/src/components/count-down.tsx +83 -0
  38. package/src/components/custom-notification.tsx +95 -0
  39. package/src/components/dialog.tsx +158 -0
  40. package/src/components/drawer.tsx +116 -0
  41. package/src/components/dropdown-menu.tsx +196 -0
  42. package/src/components/energy-progress.tsx +55 -0
  43. package/src/components/form.tsx +201 -0
  44. package/src/components/group.tsx +9 -0
  45. package/src/components/guide.tsx +243 -0
  46. package/src/components/icon.tsx +89 -0
  47. package/src/components/icons/outline/DownIcon.tsx +18 -0
  48. package/src/components/icons/outline/FilterIcon.tsx +21 -0
  49. package/src/components/icons/outline/arrow-left.tsx +16 -0
  50. package/src/components/icons/outline/arrow-up-tray.tsx +16 -0
  51. package/src/components/icons/outline/check-circle.tsx +17 -0
  52. package/src/components/icons/outline/config.tsx +42 -0
  53. package/src/components/icons/outline/pencil-square.tsx +16 -0
  54. package/src/components/icons/outline/trash.tsx +17 -0
  55. package/src/components/icons/outline/window.tsx +16 -0
  56. package/src/components/icons/outline/x-circle.tsx +17 -0
  57. package/src/components/icons/outline/x-mark.tsx +16 -0
  58. package/src/components/icons/solid/audio-playing.tsx +31 -0
  59. package/src/components/icons/solid/caret-down.tsx +14 -0
  60. package/src/components/icons/solid/code.tsx +18 -0
  61. package/src/components/icons/solid/drag.tsx +14 -0
  62. package/src/components/icons/solid/phone.tsx +23 -0
  63. package/src/components/icons/solid/rectangle-group.tsx +14 -0
  64. package/src/components/image.tsx +151 -0
  65. package/src/components/input.tsx +118 -0
  66. package/src/components/label.tsx +26 -0
  67. package/src/components/link.tsx +123 -0
  68. package/src/components/marquee/index.css +15 -0
  69. package/src/components/marquee/marquee.tsx +220 -0
  70. package/src/components/masonry.tsx +138 -0
  71. package/src/components/menubar.tsx +234 -0
  72. package/src/components/mobile/m-tooltip.tsx +34 -0
  73. package/src/components/modal.tsx +561 -0
  74. package/src/components/navigation-bar.tsx +100 -0
  75. package/src/components/number-input.tsx +143 -0
  76. package/src/components/page-content.tsx +16 -0
  77. package/src/components/popover.tsx +191 -0
  78. package/src/components/progress.tsx +80 -0
  79. package/src/components/radio-group.tsx +44 -0
  80. package/src/components/scroll-area.tsx +49 -0
  81. package/src/components/search-bar.tsx +140 -0
  82. package/src/components/secondary-navigation-bar.tsx +307 -0
  83. package/src/components/select.tsx +273 -0
  84. package/src/components/separator.tsx +31 -0
  85. package/src/components/sheet.tsx +143 -0
  86. package/src/components/skeleton.tsx +20 -0
  87. package/src/components/slider.tsx +160 -0
  88. package/src/components/spinner.tsx +48 -0
  89. package/src/components/swiper/index.module.scss +88 -0
  90. package/src/components/swiper/index.tsx +319 -0
  91. package/src/components/switch.tsx +67 -0
  92. package/src/components/tabs.tsx +325 -0
  93. package/src/components/textarea.tsx +71 -0
  94. package/src/components/toast/toast.tsx +182 -0
  95. package/src/components/toast/toaster.tsx +160 -0
  96. package/src/components/toast/use-toast.tsx +248 -0
  97. package/src/components/toggle-group.tsx +64 -0
  98. package/src/components/toggle.tsx +46 -0
  99. package/src/components/tooltip.tsx +283 -0
  100. package/src/components/typography.tsx +437 -0
  101. package/src/index.ts +66 -0
  102. package/src/lib/utils.ts +62 -0
  103. package/src/stories/Accordion.stories.tsx +64 -0
  104. package/src/stories/AccordionItem.stories.tsx +48 -0
  105. package/src/stories/Avatar.stories.ts +58 -0
  106. package/src/stories/Badge.stories.tsx +40 -0
  107. package/src/stories/BannerSwiper.stories.tsx +102 -0
  108. package/src/stories/Button.stories.tsx +543 -0
  109. package/src/stories/Checkbox.stories.tsx +161 -0
  110. package/src/stories/Configure.mdx +341 -0
  111. package/src/stories/CssProperties.mdx +30 -0
  112. package/src/stories/Description.stories.ts +70 -0
  113. package/src/stories/Display.stories.ts +64 -0
  114. package/src/stories/FeaturedSwiper.stories.tsx +6978 -0
  115. package/src/stories/GridSwiper.stories.tsx +1407 -0
  116. package/src/stories/Guide.stories.tsx +247 -0
  117. package/src/stories/Heading.stories.ts +89 -0
  118. package/src/stories/Icon.stories.ts +77 -0
  119. package/src/stories/IconButton.stories.tsx +301 -0
  120. package/src/stories/IconTextButton.stories.ts +59 -0
  121. package/src/stories/Image.stories.ts +55 -0
  122. package/src/stories/Input.stories.tsx +203 -0
  123. package/src/stories/Modal.stories.tsx +144 -0
  124. package/src/stories/NavigationBar.stories.tsx +81 -0
  125. package/src/stories/Notification.stories.tsx +276 -0
  126. package/src/stories/Popover.stories.tsx +100 -0
  127. package/src/stories/SearchBar.stories.ts +43 -0
  128. package/src/stories/SecondaryNavigationBar.stories.tsx +199 -0
  129. package/src/stories/Select.stories.tsx +107 -0
  130. package/src/stories/Separator.stories.tsx +49 -0
  131. package/src/stories/Spinner.stories.tsx +48 -0
  132. package/src/stories/SubHeading.stories.ts +64 -0
  133. package/src/stories/Swich.stories.tsx +69 -0
  134. package/src/stories/Tabs.stories.tsx +90 -0
  135. package/src/stories/Text.stories.ts +78 -0
  136. package/src/stories/Textarea.stories.tsx +155 -0
  137. package/src/stories/Toast.stories.tsx +424 -0
  138. package/src/stories/Tooltip.stories.tsx +244 -0
  139. package/src/stories/ViewAutoSwiper.stories.tsx +1408 -0
  140. package/src/styles/components-dark.scss +212 -0
  141. package/src/styles/components-light.scss +210 -0
  142. package/src/styles/design-dark.scss +330 -0
  143. package/src/styles/design-light.scss +345 -0
  144. package/src/styles/design2-dark.scss +319 -0
  145. package/src/styles/design2-light.scss +364 -0
  146. package/src/styles/font.css +19 -0
  147. package/src/styles/global.scss +251 -0
  148. package/src/styles/md-viewer.scss +155 -0
  149. package/src/styles/new-tokens.scss +255 -0
  150. package/src/styles/tokens.scss +401 -0
  151. package/src/types/scss.d.ts +24 -0
@@ -0,0 +1,199 @@
1
+ import { ArrowUpOnSquareIcon } from '@heroicons/react/24/outline';
2
+ import EllipsisHorizontalIcon from '@heroicons/react/24/outline/esm/EllipsisHorizontalIcon';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { headers } from 'next/headers';
5
+ import { SecondaryNavigationBar } from '../components/secondary-navigation-bar';
6
+ import React from 'react';
7
+
8
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
9
+ const meta = {
10
+ title: 'Components/通用/SecondaryNavigationBar-二级页面导航栏',
11
+ component: SecondaryNavigationBar,
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
+ nextjs: {
16
+ appDirectory: true, // 如果组件里有用到router next/navigation,则需要设置此配置
17
+ },
18
+ },
19
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
20
+ tags: ['autodocs'],
21
+
22
+ // 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
23
+ args: {
24
+ title: 'Title',
25
+ showClear: false,
26
+ showSearchBar: false,
27
+ searchValue: '',
28
+ backUrl: '/explore',
29
+ },
30
+ argTypes: {
31
+ title: {
32
+ control: 'text',
33
+ },
34
+ },
35
+ } satisfies Meta<typeof SecondaryNavigationBar>;
36
+
37
+ export default meta;
38
+ // export const Default: StoryObj<typeof meta> = {
39
+ // // 这里不需要设置 args,因为它会继承 meta 中的 args
40
+ // };
41
+ type Story = StoryObj<typeof meta>;
42
+
43
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
44
+ export const SecondaryNavigationBarDemo: Story = {
45
+ args: {
46
+ ...meta.args, // 继承默认参数
47
+ },
48
+ render: (args) => {
49
+ return (
50
+ <div className="min-w-[60vw] overflow-y-auto w-full p-6 rounded-md flex flex-col justify-center items-center bg-Colors-Background-Neutral-Primary-Default">
51
+ <div className="w-full">
52
+ <div className="w-full mt-6">Default</div>
53
+ <SecondaryNavigationBar
54
+ {...args}
55
+ backUrl=""
56
+ showClear={false}
57
+ showSearchBar={false}
58
+ />
59
+ </div>
60
+ <div className="w-full">
61
+ <div className="w-full mt-6">Back url</div>
62
+ <SecondaryNavigationBar
63
+ {...args}
64
+ backUrl="/"
65
+ showClear={false}
66
+ showSearchBar={false}
67
+ />
68
+ </div>
69
+ <div className="w-full">
70
+ <div className="w-full mt-6">Search bar</div>
71
+ <SecondaryNavigationBar {...args} showSearchBar />
72
+ </div>
73
+ <div className="w-full">
74
+ <div className="w-full mt-6">Clear</div>
75
+ <SecondaryNavigationBar
76
+ {...args}
77
+ showClear
78
+ clearText="Clear Filters"
79
+ showSearchBar
80
+ />
81
+ </div>
82
+ <div className="w-full">
83
+ <div className="w-full mt-6">icon buttons</div>
84
+ <SecondaryNavigationBar
85
+ {...args}
86
+ icons={[
87
+ {
88
+ icon: ArrowUpOnSquareIcon,
89
+ onClick: () => {
90
+ console.log('click');
91
+ },
92
+ },
93
+ {
94
+ icon: EllipsisHorizontalIcon,
95
+ onClick: () => {
96
+ console.log('click');
97
+ },
98
+ },
99
+ ]}
100
+ />
101
+ </div>
102
+ <div className="w-full">
103
+ <div className="w-full mt-6">action buttons</div>
104
+ <SecondaryNavigationBar
105
+ {...args}
106
+ actions={[
107
+ {
108
+ label: 'Cancel',
109
+ variant: 'primary',
110
+ color: 'gray',
111
+ onClick: () => {
112
+ console.log('click');
113
+ },
114
+ },
115
+ {
116
+ label: 'Cancel',
117
+ variant: 'primary',
118
+ color: 'brand',
119
+ onClick: () => {
120
+ console.log('click');
121
+ },
122
+ },
123
+ ]}
124
+ />
125
+ </div>
126
+ <div className="w-full">
127
+ <div className="w-full mt-6">text buttons</div>
128
+ <SecondaryNavigationBar
129
+ {...args}
130
+ actions={[
131
+ {
132
+ label: 'Label',
133
+ variant: 'plain',
134
+ color: 'brand',
135
+ onClick: () => {
136
+ console.log('click');
137
+ },
138
+ },
139
+ ]}
140
+ />
141
+ </div>
142
+ <div className="w-full">
143
+ <div className="w-full mt-6">avatar</div>
144
+ <SecondaryNavigationBar
145
+ {...args}
146
+ showSearchBar={false}
147
+ avatar={{
148
+ logo: 'https://www.myshellstatic.com/cdn-cgi/image/quality=40,format=webp/image/bot/logo/15035350/202409121847/8-cropped-image.png',
149
+ name: 'Emma',
150
+ }}
151
+ icons={[
152
+ {
153
+ icon: ArrowUpOnSquareIcon,
154
+ onClick: () => {
155
+ console.log('click');
156
+ },
157
+ },
158
+ {
159
+ icon: EllipsisHorizontalIcon,
160
+ onClick: () => {
161
+ console.log('click');
162
+ },
163
+ },
164
+ ]}
165
+ />
166
+ </div>
167
+ <div className="w-full">
168
+ <div className="w-full mt-6">bar右侧内容自定义</div>
169
+ <SecondaryNavigationBar {...args} showSearchBar={false}>
170
+ children
171
+ </SecondaryNavigationBar>
172
+ </div>
173
+ <div className="w-full">
174
+ <div className="w-full mt-6">无背景</div>
175
+ <SecondaryNavigationBar
176
+ {...args}
177
+ showSearchBar={false}
178
+ hasBackground={false}
179
+ icons={[
180
+ {
181
+ icon: ArrowUpOnSquareIcon,
182
+ onClick: () => {
183
+ console.log('click');
184
+ },
185
+ },
186
+ {
187
+ icon: EllipsisHorizontalIcon,
188
+ onClick: () => {
189
+ console.log('click');
190
+ },
191
+ },
192
+ ]}
193
+ />
194
+ <div className="h-[800px]">test content</div>
195
+ </div>
196
+ </div>
197
+ );
198
+ },
199
+ };
@@ -0,0 +1,107 @@
1
+ /* eslint-disable import/no-unused-modules */
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import { fn } from '@storybook/test';
4
+ import React from 'react';
5
+
6
+ import {
7
+ Select,
8
+ SelectContent,
9
+ SelectItem,
10
+ SelectTrigger,
11
+ SelectIcon,
12
+ SelectValue,
13
+ } from '../components/select';
14
+ import { CheckBadgeIcon, TrashIcon } from '@heroicons/react/24/outline';
15
+
16
+ const meta = {
17
+ title: 'Components/表单/Select-下拉框',
18
+ component: Select,
19
+ parameters: {
20
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
21
+ layout: 'centered',
22
+ },
23
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
24
+ tags: ['autodocs'],
25
+ args: {},
26
+ argTypes: {
27
+ options: {
28
+ control: 'object',
29
+ },
30
+ placeholder: {
31
+ control: 'text',
32
+ },
33
+ triggerClassName: {
34
+ control: 'text',
35
+ },
36
+ },
37
+ } satisfies Meta<typeof Select>;
38
+ export default meta;
39
+
40
+ type Story = StoryObj<typeof meta>;
41
+
42
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
43
+ export const Demo: Story = {
44
+ args: {
45
+ ...meta.args, // 继承默认参数
46
+ },
47
+ render: (args) => {
48
+ return (
49
+ <div className="w-[40vw] px-3 rounded-md flex gap-2">
50
+ <Select {...args}>
51
+ <SelectTrigger className="w-[180px]">
52
+ <div className="flex justify-between items-center grow">
53
+ <SelectValue placeholder="Theme" />
54
+ </div>
55
+ </SelectTrigger>
56
+ <SelectContent>
57
+ <SelectItem value="light">Light</SelectItem>
58
+ <SelectItem value="dark" icon={CheckBadgeIcon}>
59
+ Dark
60
+ </SelectItem>
61
+ <SelectItem value="system">System</SelectItem>
62
+ <SelectItem value="delete" critical icon={TrashIcon}>
63
+ Delete
64
+ </SelectItem>
65
+ <SelectItem value="disabled" disabled>
66
+ Disabled
67
+ </SelectItem>
68
+ </SelectContent>
69
+ </Select>
70
+ </div>
71
+ );
72
+ },
73
+ };
74
+
75
+ export const OptionsDemo: Story = {
76
+ render: () => {
77
+ const [value, setValue] = React.useState('');
78
+
79
+ return (
80
+ <div className="w-[40vw] px-3 rounded-md flex flex-col gap-4">
81
+ <h3 className="text-lg font-medium">当前选中值: {value}</h3>
82
+ <Select
83
+ value={value}
84
+ onValueChange={setValue}
85
+ triggerClassName="w-[180px]"
86
+ options={[
87
+ { value: 'Options1', label: 'Options1' },
88
+ { value: 'Options2', label: 'Options2' },
89
+ { value: 'Options3', label: 'Options3', icon: <CheckBadgeIcon /> },
90
+ {
91
+ value: 'Options4',
92
+ label: 'Options4',
93
+ icon: <TrashIcon />,
94
+ critical: true,
95
+ },
96
+ {
97
+ value: 'Options5',
98
+ label: 'Options5',
99
+ disabled: true,
100
+ },
101
+ ]}
102
+ placeholder="请选择选项"
103
+ />
104
+ </div>
105
+ );
106
+ },
107
+ };
@@ -0,0 +1,49 @@
1
+ /* eslint-disable import/no-unused-modules */
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import React from 'react';
4
+
5
+ import { Separator } from '@/components/separator';
6
+
7
+ const meta = {
8
+ title: 'Components/通用/Separator-分割线',
9
+ component: Separator,
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
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ['autodocs'],
16
+ args: {},
17
+ argTypes: {
18
+ orientation: {
19
+ description: '分割方向',
20
+ control: 'select',
21
+ options: ['horizontal', 'vertical'],
22
+ },
23
+ decorative: {
24
+ description: '是否是装饰性组件',
25
+ control: 'boolean',
26
+ },
27
+ className: {
28
+ control: 'text',
29
+ description: '样式覆盖',
30
+ },
31
+ },
32
+ } satisfies Meta<typeof Separator>;
33
+ export default meta;
34
+
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
38
+ export const Demo: Story = {
39
+ args: {
40
+ ...meta.args, // 继承默认参数
41
+ },
42
+ render: (args) => {
43
+ return (
44
+ <div className="w-[40vw] h-[200px] px-3 rounded-md flex justify-center items-center">
45
+ <Separator {...args} />
46
+ </div>
47
+ );
48
+ },
49
+ };
@@ -0,0 +1,48 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import Spinner from '@/components/spinner';
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/通用/Spinner-加载Icon',
8
+ component: Spinner,
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
+ size: 'lg',
19
+ },
20
+ argTypes: {
21
+ // 定义size为select类型的控件
22
+ size: {
23
+ control: 'select',
24
+ options: ['xs', 'sm', 'md', 'lg', 'xl'],
25
+ },
26
+ color: {
27
+ control: 'select',
28
+ options: ['default', 'brand', 'static', 'warning', 'success'],
29
+ },
30
+ speed: {
31
+ control: 'select',
32
+ options: ['slow', 'default', 'fast'],
33
+ },
34
+ },
35
+ } satisfies Meta<typeof Spinner>;
36
+
37
+ export default meta;
38
+ // export const Default: StoryObj<typeof meta> = {
39
+ // // 这里不需要设置 args,因为它会继承 meta 中的 args
40
+ // };
41
+ type Story = StoryObj<typeof meta>;
42
+
43
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
44
+ export const Demo: Story = {
45
+ args: {
46
+ ...meta.args, // 继承默认参数
47
+ },
48
+ };
@@ -0,0 +1,64 @@
1
+ /* eslint-disable import/no-unused-modules */
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import { SubHeading } from '@/components/typography';
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/文字排版/SubHeading-子标题',
9
+ component: SubHeading,
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
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ['autodocs'],
16
+
17
+ // 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
18
+ args: {}, // 默认参数
19
+ argTypes: {
20
+ // 定义size为select类型的控件
21
+ size: {
22
+ control: 'select',
23
+ options: ['lg', 'sm'],
24
+ },
25
+ // 定义color为select类型的控件
26
+ color: {
27
+ control: 'select',
28
+ options: [
29
+ 'default',
30
+ 'subtle',
31
+ 'subtler',
32
+ 'subtlest',
33
+ 'disabled',
34
+ 'static',
35
+ 'static-black',
36
+ 'brand',
37
+ 'critical',
38
+ 'critical-bolder',
39
+ 'warning',
40
+ 'warning-bolder',
41
+ 'success',
42
+ 'success-bolder',
43
+ ],
44
+ },
45
+
46
+ // 定义lineClamp为select类型的控件
47
+ lineClamp: {
48
+ control: 'select',
49
+ options: [1, 2, 3, 4, 5, 6],
50
+ },
51
+ },
52
+ } satisfies Meta<typeof SubHeading>;
53
+
54
+ export default meta;
55
+
56
+ type Story = StoryObj<typeof meta>;
57
+
58
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
59
+ export const Demo: Story = {
60
+ args: {
61
+ size: 'lg',
62
+ children: 'Subheading/lg',
63
+ },
64
+ };
@@ -0,0 +1,69 @@
1
+ import ArrowsUpDownIcon from '@heroicons/react/24/outline/esm/ArrowsUpDownIcon';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+
4
+ import { Switch } from '@/components/switch';
5
+ import React from 'react';
6
+
7
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
8
+ const meta = {
9
+ title: 'Components/表单/Switch-开关',
10
+ component: Switch,
11
+ parameters: {
12
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
13
+ layout: 'centered',
14
+ },
15
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
16
+ tags: ['autodocs'],
17
+
18
+ // 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
19
+ args: {
20
+ size: 'lg',
21
+ },
22
+ argTypes: {
23
+ // 定义size为select类型的控件
24
+ size: {
25
+ control: 'select',
26
+ options: ['sm', 'md', 'lg'],
27
+ },
28
+ },
29
+ } satisfies Meta<typeof Switch>;
30
+
31
+ export default meta;
32
+ // export const Default: StoryObj<typeof meta> = {
33
+ // // 这里不需要设置 args,因为它会继承 meta 中的 args
34
+ // };
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
38
+ export const IconButtonDemo: Story = {
39
+ args: {
40
+ ...meta.args, // 继承默认参数
41
+ },
42
+ render: (args) => {
43
+ return (
44
+ <div className="min-w-[60vw] w-full p-6 rounded-md flex flex-col justify-center items-center space-y-2">
45
+ <div className="w-full">示例:</div>
46
+ <div className="w-full flex flex-col justify-center items-center">
47
+ <div className="w-full flex justify-around mb-3">
48
+ <div className="font-bold w-10" />
49
+ <div className="flex justify-center">lg</div>
50
+ <div className="flex justify-center">md</div>
51
+ <div className="flex justify-center">sm</div>
52
+ </div>
53
+ <div className="w-full flex justify-around items-center mb-6">
54
+ <div className="font-semibold w-10">Default</div>
55
+ <Switch {...args} size="lg" />
56
+ <Switch {...args} size="md" />
57
+ <Switch {...args} size="sm" />
58
+ </div>
59
+ <div className="w-full flex justify-around items-center mb-6">
60
+ <div className="font-semibold w-10">With Label</div>
61
+ <Switch {...args} size="lg" label="Label" />
62
+ <Switch {...args} size="md" label="Label" />
63
+ <Switch {...args} size="sm" label="Label" />
64
+ </div>
65
+ </div>
66
+ </div>
67
+ );
68
+ },
69
+ };
@@ -0,0 +1,90 @@
1
+ /* eslint-disable import/no-unused-modules */
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import { fn } from '@storybook/test';
4
+ import React from 'react';
5
+
6
+ import { Tabs } from '../components/tabs';
7
+
8
+ const meta = {
9
+ title: 'Components/数据展示/Tabs-标签页',
10
+ component: Tabs,
11
+ // subcomponents: { AccordionItem: AccordionItem as AccordionItemType },
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
+ nextjs: {
16
+ appDirectory: true, // 如果组件里有用到router next/navigation,则需要设置此配置
17
+ },
18
+ },
19
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
20
+ tags: ['autodocs'],
21
+ args: {
22
+ defaultValue: '1',
23
+ variant: 'underline',
24
+ size: 'lg',
25
+ isLink: false,
26
+ },
27
+ argTypes: {
28
+ defaultValue: {
29
+ control: 'text',
30
+ },
31
+ isLink: {
32
+ control: 'boolean',
33
+ description: '是否为链接',
34
+ },
35
+ listClassName: {
36
+ control: 'text',
37
+ },
38
+ variant: {
39
+ control: 'select',
40
+ options: ['button', 'underline'],
41
+ description: '选项卡风格',
42
+ },
43
+ size: {
44
+ control: 'select',
45
+ options: ['sm', 'md', 'lg'],
46
+ description: '选项卡大小',
47
+ },
48
+ },
49
+ } satisfies Meta<typeof Tabs>;
50
+ export default meta;
51
+
52
+ type Story = StoryObj<typeof meta>;
53
+
54
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
55
+ export const Demo: Story = {
56
+ args: {
57
+ ...meta.args, // 继承默认参数
58
+ },
59
+ render: (args) => {
60
+ return (
61
+ <div className="w-[70vw] px-3 rounded-md">
62
+ <Tabs
63
+ {...args}
64
+ items={[
65
+ {
66
+ label: 'Tab 1',
67
+ value: '1',
68
+ children: 'Tab 1',
69
+ link: '/1',
70
+ },
71
+ {
72
+ label: 'Tab 2',
73
+ value: '2',
74
+ children: 'Tab 2',
75
+ link: '/2',
76
+ count: 11,
77
+ disabled: true,
78
+ },
79
+ {
80
+ label: 'Tab 3',
81
+ value: '3',
82
+ children: 'Tab 3',
83
+ link: '/3',
84
+ },
85
+ ]}
86
+ />
87
+ </div>
88
+ );
89
+ },
90
+ };