@anker-in/headless-ui 0.0.11 → 0.0.13

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 (108) hide show
  1. package/CONTRIBUTING.md +20 -1
  2. package/README.md +1 -1
  3. package/dist/cjs/components/checkbox.d.ts +8 -1
  4. package/dist/cjs/components/checkbox.js +1 -1
  5. package/dist/cjs/components/checkbox.js.map +3 -3
  6. package/dist/cjs/components/dialog.js +1 -1
  7. package/dist/cjs/components/dialog.js.map +2 -2
  8. package/dist/cjs/components/heading.d.ts +10 -2
  9. package/dist/cjs/components/heading.js +1 -1
  10. package/dist/cjs/components/heading.js.map +3 -3
  11. package/dist/cjs/components/index.d.ts +1 -0
  12. package/dist/cjs/components/index.js +1 -1
  13. package/dist/cjs/components/index.js.map +2 -2
  14. package/dist/cjs/components/input.d.ts +1 -1
  15. package/dist/cjs/components/input.js.map +1 -1
  16. package/dist/cjs/components/radio.d.ts +13 -2
  17. package/dist/cjs/components/radio.js +1 -1
  18. package/dist/cjs/components/radio.js.map +3 -3
  19. package/dist/cjs/components/skeleton.d.ts +6 -3
  20. package/dist/cjs/components/skeleton.js +4 -1
  21. package/dist/cjs/components/skeleton.js.map +3 -3
  22. package/dist/cjs/components/text.d.ts +17 -3
  23. package/dist/cjs/components/text.js +1 -1
  24. package/dist/cjs/components/text.js.map +3 -3
  25. package/dist/cjs/stories/checkbox.stories.d.ts +44 -3
  26. package/dist/cjs/stories/checkbox.stories.js +1 -1
  27. package/dist/cjs/stories/checkbox.stories.js.map +3 -3
  28. package/dist/cjs/stories/dialog.stories.d.ts +18 -3
  29. package/dist/cjs/stories/dialog.stories.js +1 -1
  30. package/dist/cjs/stories/dialog.stories.js.map +3 -3
  31. package/dist/cjs/stories/heading.stories.d.ts +70 -0
  32. package/dist/cjs/stories/heading.stories.js +2 -0
  33. package/dist/cjs/stories/heading.stories.js.map +7 -0
  34. package/dist/cjs/stories/input.stories.d.ts +5 -0
  35. package/dist/cjs/stories/input.stories.js +1 -1
  36. package/dist/cjs/stories/input.stories.js.map +2 -2
  37. package/dist/cjs/stories/radio.stories.d.ts +37 -3
  38. package/dist/cjs/stories/radio.stories.js +1 -1
  39. package/dist/cjs/stories/radio.stories.js.map +3 -3
  40. package/dist/cjs/stories/skeleton.stories.d.ts +9 -3
  41. package/dist/cjs/stories/skeleton.stories.js +1 -1
  42. package/dist/cjs/stories/skeleton.stories.js.map +3 -3
  43. package/dist/cjs/stories/text.stories.d.ts +38 -3
  44. package/dist/cjs/stories/text.stories.js +9 -1
  45. package/dist/cjs/stories/text.stories.js.map +3 -3
  46. package/dist/esm/components/checkbox.d.ts +8 -1
  47. package/dist/esm/components/checkbox.js +1 -1
  48. package/dist/esm/components/checkbox.js.map +3 -3
  49. package/dist/esm/components/dialog.js +1 -1
  50. package/dist/esm/components/dialog.js.map +2 -2
  51. package/dist/esm/components/heading.d.ts +10 -2
  52. package/dist/esm/components/heading.js +1 -1
  53. package/dist/esm/components/heading.js.map +3 -3
  54. package/dist/esm/components/index.d.ts +1 -0
  55. package/dist/esm/components/index.js +1 -1
  56. package/dist/esm/components/index.js.map +2 -2
  57. package/dist/esm/components/input.d.ts +1 -1
  58. package/dist/esm/components/input.js.map +1 -1
  59. package/dist/esm/components/radio.d.ts +13 -2
  60. package/dist/esm/components/radio.js +1 -1
  61. package/dist/esm/components/radio.js.map +3 -3
  62. package/dist/esm/components/skeleton.d.ts +6 -3
  63. package/dist/esm/components/skeleton.js +4 -1
  64. package/dist/esm/components/skeleton.js.map +3 -3
  65. package/dist/esm/components/text.d.ts +17 -3
  66. package/dist/esm/components/text.js +1 -1
  67. package/dist/esm/components/text.js.map +3 -3
  68. package/dist/esm/stories/checkbox.stories.d.ts +44 -3
  69. package/dist/esm/stories/checkbox.stories.js +1 -1
  70. package/dist/esm/stories/checkbox.stories.js.map +3 -3
  71. package/dist/esm/stories/dialog.stories.d.ts +18 -3
  72. package/dist/esm/stories/dialog.stories.js +1 -1
  73. package/dist/esm/stories/dialog.stories.js.map +3 -3
  74. package/dist/esm/stories/heading.stories.d.ts +70 -0
  75. package/dist/esm/stories/heading.stories.js +2 -0
  76. package/dist/esm/stories/heading.stories.js.map +7 -0
  77. package/dist/esm/stories/input.stories.d.ts +5 -0
  78. package/dist/esm/stories/input.stories.js +1 -1
  79. package/dist/esm/stories/input.stories.js.map +2 -2
  80. package/dist/esm/stories/radio.stories.d.ts +37 -3
  81. package/dist/esm/stories/radio.stories.js +1 -1
  82. package/dist/esm/stories/radio.stories.js.map +3 -3
  83. package/dist/esm/stories/skeleton.stories.d.ts +9 -3
  84. package/dist/esm/stories/skeleton.stories.js +1 -1
  85. package/dist/esm/stories/skeleton.stories.js.map +3 -3
  86. package/dist/esm/stories/text.stories.d.ts +38 -3
  87. package/dist/esm/stories/text.stories.js +9 -1
  88. package/dist/esm/stories/text.stories.js.map +3 -3
  89. package/package.json +1 -1
  90. package/src/components/checkbox.tsx +34 -18
  91. package/src/components/dialog.tsx +1 -0
  92. package/src/components/heading.tsx +61 -5
  93. package/src/components/index.ts +1 -0
  94. package/src/components/input.tsx +1 -1
  95. package/src/components/radio.tsx +63 -28
  96. package/src/components/skeleton.tsx +33 -2
  97. package/src/components/text.tsx +25 -7
  98. package/src/stories/checkbox.stories.tsx +80 -3
  99. package/src/stories/dialog.stories.tsx +60 -31
  100. package/src/stories/heading.stories.tsx +90 -0
  101. package/src/stories/input.stories.tsx +5 -0
  102. package/src/stories/radio.stories.tsx +52 -16
  103. package/src/stories/skeleton.stories.tsx +36 -2
  104. package/src/stories/text.stories.tsx +74 -13
  105. package/src/styles/global.css +5 -5
  106. package/style.css +70 -19
  107. package/dist/cjs/tsconfig.tsbuildinfo +0 -1
  108. package/dist/esm/tsconfig.tsbuildinfo +0 -1
@@ -2,10 +2,12 @@ import * as React from 'react'
2
2
  import { Slot } from '@radix-ui/react-slot'
3
3
  import { cn } from '../helpers/index.js'
4
4
  import { type VariantProps, cva } from 'class-variance-authority'
5
+ import type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js'
5
6
 
6
7
  const textVariants = cva('', {
7
8
  variants: {
8
9
  size: {
10
+ none: '',
9
11
  1: 'ai-text-xs',
10
12
  2: 'ai-text-sm',
11
13
  3: 'ai-text-base',
@@ -24,22 +26,29 @@ const textVariants = cva('', {
24
26
  },
25
27
  },
26
28
  defaultVariants: {
27
- size: 3,
29
+ size: 'none',
28
30
  weights: 'normal',
29
31
  },
30
32
  })
31
33
 
32
34
  type TextElement = React.ElementRef<'span'>
33
- interface TextProps extends React.ComponentPropsWithoutRef<'span'>, VariantProps<typeof textVariants> {
34
- as?: 'div' | 'label' | 'p' | 'span' | undefined
35
+ type TextSpanProps = { as?: 'span' } & ComponentPropsWithout<'span', RemovedProps>
36
+ type TextDivProps = { as: 'div' } & ComponentPropsWithout<'div', RemovedProps>
37
+ type TextLabelProps = { as: 'label' } & ComponentPropsWithout<'label', RemovedProps>
38
+ type TextPProps = { as: 'p' } & ComponentPropsWithout<'p', RemovedProps>
39
+
40
+ interface CommonTextProps extends VariantProps<typeof textVariants> {
41
+ as?: 'div' | 'label' | 'p' | 'span'
35
42
  asChild?: boolean
36
43
  color?: string
37
44
  /** 相当于 dangerouslySetInnerHTML */
38
45
  html?: string
39
46
  }
40
47
 
48
+ type TextProps = CommonTextProps & (TextSpanProps | TextDivProps | TextLabelProps | TextPProps)
49
+
41
50
  const Text = React.forwardRef<TextElement, TextProps>((props, forwardedRef) => {
42
- const { children, size, className, asChild, as: Tag = 'span', color, html, ...textProps } = props
51
+ const { children, size = 'none', weights, className, asChild, as: Tag = 'span', color, html, ...textProps } = props
43
52
 
44
53
  const htmlContentProps = html
45
54
  ? {
@@ -47,18 +56,27 @@ const Text = React.forwardRef<TextElement, TextProps>((props, forwardedRef) => {
47
56
  }
48
57
  : null
49
58
 
59
+ const styleProps = color
60
+ ? {
61
+ style: {
62
+ color,
63
+ },
64
+ }
65
+ : null
66
+
50
67
  return (
51
68
  <Slot
52
69
  {...textProps}
53
70
  ref={forwardedRef}
54
71
  className={cn(
55
72
  textVariants({
56
- size: size,
73
+ size,
74
+ weights,
57
75
  }),
58
- className,
59
- `text-[${color}]`
76
+ className
60
77
  )}
61
78
  {...htmlContentProps}
79
+ {...styleProps}
62
80
  >
63
81
  {asChild ? children : <Tag>{htmlContentProps ? null : children}</Tag>}
64
82
  </Slot>
@@ -1,11 +1,88 @@
1
+ import type { Meta, StoryObj } from '@storybook/react/*'
1
2
  import { Checkbox } from '../components/index'
2
3
  import React from 'react'
3
4
 
4
- export default { title: 'Components/Checkbox' }
5
+ const meta = {
6
+ title: 'Components/Checkbox',
7
+ component: Checkbox,
8
+ parameters: {
9
+ layout: 'centered',
10
+ docs: {
11
+ description: {
12
+ component: '复选框, 基于@radix-ui/react-checkbox https://www.radix-ui.com/primitives/docs/components/checkbox',
13
+ },
14
+ },
15
+ },
16
+ tags: ['autodocs'],
17
+ argTypes: {
18
+ size: {
19
+ control: {
20
+ type: 'select',
21
+ },
22
+ options: ['sm', 'base', 'lg'],
23
+ description: '尺寸',
24
+ table: {
25
+ defaultValue: { summary: 'base' },
26
+ },
27
+ },
28
+ },
29
+ args: {
30
+ size: 'base',
31
+ },
32
+ } satisfies Meta<typeof Checkbox>
5
33
 
6
- export const Default = () => (
34
+ export default meta
35
+
36
+ type Story = StoryObj<typeof meta>
37
+
38
+ export const Default: Story = {
39
+ args: {
40
+ size: 'base',
41
+ },
42
+ }
43
+
44
+ export const Sizes = () => (
45
+ <div className="ai-flex ai-flex-col ai-gap-2">
46
+ <div className="ai-flex ai-items-center ai-space-x-2">
47
+ <Checkbox id="terms" size="sm" />
48
+ <label
49
+ htmlFor="terms"
50
+ className="ai-text-sm ai-font-medium ai-leading-none peer-disabled:ai-cursor-not-allowed peer-disabled:ai-opacity-70"
51
+ >
52
+ Accept terms and conditions
53
+ </label>
54
+ </div>
55
+ <div className="ai-flex ai-items-center ai-space-x-2">
56
+ <Checkbox id="terms1" size="base" />
57
+ <label
58
+ htmlFor="terms1"
59
+ className="ai-text-base ai-font-medium ai-leading-none peer-disabled:ai-cursor-not-allowed peer-disabled:ai-opacity-70"
60
+ >
61
+ Accept terms and conditions
62
+ </label>
63
+ </div>
64
+ <div className="ai-flex ai-items-center ai-space-x-2">
65
+ <Checkbox id="terms2" size="lg" />
66
+ <label
67
+ htmlFor="terms2"
68
+ className="ai-text-lg ai-font-medium ai-leading-none peer-disabled:ai-cursor-not-allowed peer-disabled:ai-opacity-70"
69
+ >
70
+ Accept terms and conditions
71
+ </label>
72
+ </div>
73
+ </div>
74
+ )
75
+ Sizes.parameters = {
76
+ docs: {
77
+ description: {
78
+ story: '不同的尺寸',
79
+ },
80
+ },
81
+ }
82
+
83
+ export const Disabled = () => (
7
84
  <div className="ai-flex ai-items-center ai-space-x-2">
8
- <Checkbox id="terms" />
85
+ <Checkbox id="terms" disabled />
9
86
  <label
10
87
  htmlFor="terms"
11
88
  className="ai-text-sm ai-font-medium ai-leading-none peer-disabled:ai-cursor-not-allowed peer-disabled:ai-opacity-70"
@@ -10,36 +10,65 @@ import {
10
10
  DialogTrigger,
11
11
  Input,
12
12
  } from '../components/index'
13
+ import type { Meta, StoryObj } from '@storybook/react/*'
13
14
 
14
- export default { title: 'Components/Dialog' }
15
+ const meta = {
16
+ title: 'Components/Dialog',
17
+ component: Dialog,
18
+ subcomponents: {
19
+ DialogTrigger,
20
+ DialogContent,
21
+ DialogHeader,
22
+ DialogTitle,
23
+ DialogDescription,
24
+ DialogFooter,
25
+ } as any,
26
+ parameters: {
27
+ layout: 'centered',
28
+ docs: {
29
+ description: {
30
+ component: '弹窗组件,基于@radix-ui/react-dialog,https://www.radix-ui.com/primitives/docs/components/dialog ',
31
+ },
32
+ },
33
+ },
34
+ tags: ['autodocs'],
35
+ } satisfies Meta<typeof Dialog>
15
36
 
16
- export const Default = () => (
17
- <Dialog>
18
- <DialogTrigger asChild>
19
- <button>Edit Profile</button>
20
- </DialogTrigger>
21
- <DialogContent className="sm:ai-max-w-[425px]">
22
- <DialogHeader>
23
- <DialogTitle>Edit profile</DialogTitle>
24
- <DialogDescription>Make changes to your profile here. Click save when you're done.</DialogDescription>
25
- </DialogHeader>
26
- <div className="ai-grid ai-gap-4 ai-py-4">
27
- <div className="ai-grid ai-grid-cols-4 ai-items-center ai-gap-4">
28
- <label htmlFor="name" className="ai-text-right">
29
- Name
30
- </label>
31
- <Input id="name" defaultValue="Pedro Duarte" className="ai-col-span-3" />
32
- </div>
33
- <div className="ai-grid ai-grid-cols-4 ai-items-center ai-gap-4">
34
- <label htmlFor="username" className="ai-text-right">
35
- Username
36
- </label>
37
- <Input id="username" defaultValue="@peduarte" className="ai-col-span-3" />
38
- </div>
39
- </div>
40
- <DialogFooter>
41
- <Button type="submit">Save changes</Button>
42
- </DialogFooter>
43
- </DialogContent>
44
- </Dialog>
45
- )
37
+ export default meta
38
+
39
+ type Story = StoryObj<typeof Dialog>
40
+
41
+ export const Default: Story = {
42
+ args: {
43
+ children: (
44
+ <>
45
+ <DialogTrigger asChild>
46
+ <button>Edit Profile</button>
47
+ </DialogTrigger>
48
+ <DialogContent className="sm:ai-max-w-[425px]">
49
+ <DialogHeader>
50
+ <DialogTitle>Edit profile</DialogTitle>
51
+ <DialogDescription>Make changes to your profile here. Click save when you're done.</DialogDescription>
52
+ </DialogHeader>
53
+ <div className="ai-grid ai-gap-4 ai-py-4">
54
+ <div className="ai-grid ai-grid-cols-4 ai-items-center ai-gap-4">
55
+ <label htmlFor="name" className="ai-text-right">
56
+ Name
57
+ </label>
58
+ <Input id="name" defaultValue="Pedro Duarte" className="ai-col-span-3" />
59
+ </div>
60
+ <div className="ai-grid ai-grid-cols-4 ai-items-center ai-gap-4">
61
+ <label htmlFor="username" className="ai-text-right">
62
+ Username
63
+ </label>
64
+ <Input id="username" defaultValue="@peduarte" className="ai-col-span-3" />
65
+ </div>
66
+ </div>
67
+ <DialogFooter>
68
+ <Button type="submit">Save changes</Button>
69
+ </DialogFooter>
70
+ </DialogContent>
71
+ </>
72
+ ),
73
+ },
74
+ }
@@ -0,0 +1,90 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import { Heading } from '../components/index'
4
+ import React from 'react'
5
+
6
+ const meta = {
7
+ title: 'Typography/Heading',
8
+ component: Heading,
9
+ parameters: {
10
+ layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component: 'Heading 组件, 基本和text 组件一样,只是默认的标签类型不一样',
14
+ },
15
+ },
16
+ },
17
+ tags: ['autodocs'],
18
+ argTypes: {
19
+ size: {
20
+ control: {
21
+ type: 'select',
22
+ },
23
+ options: ['none', 1, 2, 3, 4, 5, 6, 7, 8, 9],
24
+ description: '文本尺寸,默认为none,浏览器默认大小和行高,1~9预设字体大小和行高',
25
+ table: {
26
+ defaultValue: { summary: 'none' },
27
+ },
28
+ },
29
+ weights: {
30
+ control: {
31
+ type: 'select',
32
+ },
33
+ options: ['light', 'normal', 'medium', 'bold'],
34
+ table: {
35
+ defaultValue: { summary: 'normal' },
36
+ },
37
+ },
38
+ color: {
39
+ control: {
40
+ type: 'color',
41
+ },
42
+ },
43
+ as: {
44
+ control: {
45
+ type: 'select',
46
+ },
47
+ options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
48
+ description: 'html 标签类型',
49
+ table: {
50
+ defaultValue: { summary: 'h1' },
51
+ },
52
+ },
53
+ html: {
54
+ type: 'string',
55
+ description: '相当于 dangerouslySetInnerHTML',
56
+ },
57
+ },
58
+ args: {
59
+ as: 'h1',
60
+ size: 'none',
61
+ weights: 'normal',
62
+ },
63
+ } satisfies Meta<typeof Heading>
64
+
65
+ export default meta
66
+
67
+ type Story = StoryObj<typeof meta>
68
+
69
+ export const Default: Story = {
70
+ args: {
71
+ as: 'h1',
72
+ children: ' The quick brown fox jumps over the lazy dog.',
73
+ },
74
+ }
75
+
76
+ export const All: Story = {
77
+ render: () => (
78
+ <>
79
+ <Heading size={1}>The quick brown fox jumps over the lazy dog.</Heading>
80
+ <Heading size={2}>The quick brown fox jumps over the lazy dog.</Heading>
81
+ <Heading size={3}>The quick brown fox jumps over the lazy dog.</Heading>
82
+ <Heading size={4}>The quick brown fox jumps over the lazy dog.</Heading>
83
+ <Heading size={5}>The quick brown fox jumps over the lazy dog.</Heading>
84
+ <Heading size={6}>The quick brown fox jumps over the lazy dog.</Heading>
85
+ <Heading size={7}>The quick brown fox jumps over the lazy dog.</Heading>
86
+ <Heading size={8}>The quick brown fox jumps over the lazy dog.</Heading>
87
+ <Heading size={9}>The quick brown fox jumps over the lazy dog.</Heading>
88
+ </>
89
+ ),
90
+ }
@@ -10,6 +10,11 @@ const meta = {
10
10
  subcomponents: { InputSlot: InputSlot as ComponentType<unknown> }, // TODO: 检查type , 去掉as类型转换
11
11
  parameters: {
12
12
  layout: 'centered',
13
+ docs: {
14
+ description: {
15
+ component: 'Input 组件, 用于输入框, 可以通过插槽插入额外的内容, 比如icon, 按钮',
16
+ },
17
+ },
13
18
  },
14
19
  tags: ['autodocs'],
15
20
  argTypes: {
@@ -1,19 +1,55 @@
1
+ import type { Meta, StoryObj } from '@storybook/react/*'
1
2
  import { RadioGroup, RadioGroupItem } from '../components/index'
2
- import React from 'react'
3
+ import React, { type ComponentType } from 'react'
3
4
 
4
- export default { title: 'Components/Radio' }
5
+ const meta = {
6
+ title: 'Components/RadioGroup',
7
+ component: RadioGroup,
8
+ subcomponents: { RadioGroupItem: RadioGroupItem as ComponentType<unknown> },
9
+ parameters: {
10
+ layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component:
14
+ '单选框, 基于@radix-ui/react-radio-group https://www.radix-ui.com/primitives/docs/components/radio-group',
15
+ },
16
+ },
17
+ },
18
+ tags: ['autodocs'],
19
+ argTypes: {
20
+ size: {
21
+ control: {
22
+ type: 'select',
23
+ },
24
+ options: ['sm', 'base', 'lg'],
25
+ description: '尺寸',
26
+ table: {
27
+ defaultValue: { summary: 'base' },
28
+ },
29
+ },
30
+ },
31
+ args: {
32
+ size: 'base',
33
+ },
34
+ } satisfies Meta<typeof RadioGroup>
5
35
 
6
- export const Default = () => (
7
- <div className="ai-flex ai-h-40 ai-w-48 ai-items-center ai-justify-center">
8
- <RadioGroup defaultValue="ai-option-one">
9
- <div className="ai-flex ai-items-center ai-space-x-2">
10
- <RadioGroupItem value="option-one" id="option-one" />
11
- <label htmlFor="option-one">Option One</label>
12
- </div>
13
- <div className="ai-flex ai-items-center ai-space-x-2">
14
- <RadioGroupItem value="option-two" id="option-two" />
15
- <label htmlFor="option-two">Option Two</label>
16
- </div>
17
- </RadioGroup>
18
- </div>
19
- )
36
+ export default meta
37
+
38
+ type Story = StoryObj<typeof RadioGroup>
39
+ export const Default: Story = {
40
+ args: {
41
+ size: 'base',
42
+ children: (
43
+ <>
44
+ <div className="ai-flex ai-items-center ai-space-x-2">
45
+ <RadioGroupItem value="option-one" id="option-one" />
46
+ <label htmlFor="option-one">Option One</label>
47
+ </div>
48
+ <div className="ai-flex ai-items-center ai-space-x-2">
49
+ <RadioGroupItem value="option-two" id="option-two" />
50
+ <label htmlFor="option-two">Option Two</label>
51
+ </div>
52
+ </>
53
+ ),
54
+ },
55
+ }
@@ -8,6 +8,12 @@ const meta = {
8
8
  component: Skeleton,
9
9
  parameters: {
10
10
  layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component:
14
+ '骨架屏组件,用来在数据加载时展示一个占位图, 可以包在dom 外使用,通过loading 控制显示隐藏, 也可以单独使用,通过自定义class控制样式, 组合成想要的形状',
15
+ },
16
+ },
11
17
  },
12
18
  tags: ['autodocs'],
13
19
  } satisfies Meta<typeof Skeleton>
@@ -16,9 +22,19 @@ export default meta
16
22
 
17
23
  type Story = StoryObj<typeof meta>
18
24
 
19
- export const Default: Story = {}
25
+ export const Default: Story = {
26
+ args: {
27
+ loading: true,
28
+ children: (
29
+ <div className="ai-h-14 ai-rounded-3xl ai-overflow-hidden ai-px-4 ai-py-4 w-full">
30
+ Fog creeps across moors, hills, and rivers. It adds an eerie charm to the landscape, but also complicates
31
+ driving.
32
+ </div>
33
+ ),
34
+ },
35
+ }
20
36
 
21
- export const Example: Story = {
37
+ export const Multiple: Story = {
22
38
  render() {
23
39
  return (
24
40
  <div className="ai-flex ai-flex-col ai-items-center ai-justify-center">
@@ -31,3 +47,21 @@ export const Example: Story = {
31
47
  )
32
48
  },
33
49
  }
50
+
51
+ export const WithText: Story = {
52
+ render() {
53
+ return (
54
+ <>
55
+ <Skeleton loading={true}>
56
+ Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers,
57
+ and downpours, often accompanied by gray skies.
58
+ </Skeleton>
59
+ <hr />
60
+ <Skeleton loading={false}>
61
+ Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers,
62
+ and downpours, often accompanied by gray skies.
63
+ </Skeleton>
64
+ </>
65
+ )
66
+ },
67
+ }
@@ -4,10 +4,15 @@ import { Text } from '../components/index'
4
4
  import React from 'react'
5
5
 
6
6
  const meta = {
7
- title: 'Components/Text',
7
+ title: 'Typography/Text',
8
8
  component: Text,
9
9
  parameters: {
10
10
  layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component: '文本组件, 简单封装了常用的样式字段,用于展示文本内容.',
14
+ },
15
+ },
11
16
  },
12
17
  tags: ['autodocs'],
13
18
  argTypes: {
@@ -15,13 +20,35 @@ const meta = {
15
20
  control: {
16
21
  type: 'select',
17
22
  },
18
- options: [1, 2, 3, 4, 5, 6, 7, 8, 9],
23
+ description: '文本尺寸,默认为none,浏览器默认大小和行高,19预设字体大小和行高',
24
+ options: ['none', 1, 2, 3, 4, 5, 6, 7, 8, 9],
25
+ table: {
26
+ defaultValue: { summary: 'none' },
27
+ },
19
28
  },
20
29
  weights: {
21
30
  control: {
22
31
  type: 'select',
23
32
  },
24
33
  options: ['light', 'normal', 'medium', 'bold'],
34
+ table: {
35
+ defaultValue: { summary: 'normal' },
36
+ },
37
+ },
38
+ color: {
39
+ control: {
40
+ type: 'color',
41
+ },
42
+ },
43
+ as: {
44
+ control: {
45
+ type: 'select',
46
+ },
47
+ description: 'html 标签类型',
48
+ options: ['div', 'label', 'p', 'span'],
49
+ table: {
50
+ defaultValue: { summary: 'span' },
51
+ },
25
52
  },
26
53
  html: {
27
54
  type: 'string',
@@ -29,7 +56,7 @@ const meta = {
29
56
  },
30
57
  },
31
58
  args: {
32
- size: 3,
59
+ size: 'none',
33
60
  weights: 'normal',
34
61
  html: '',
35
62
  },
@@ -41,22 +68,56 @@ type Story = StoryObj<typeof meta>
41
68
  export const Default: Story = {
42
69
  args: {
43
70
  children: ' The quick brown fox jumps over the lazy dog.',
44
- size: 3,
71
+ size: 'none',
45
72
  weights: 'normal',
46
73
  },
47
74
  }
48
75
 
49
- const sizes = new Array(9).fill(0).map((_, i) => i + 1)
50
- export const All: Story = {
76
+ export const Sizes: Story = {
77
+ render() {
78
+ return (
79
+ <div className="ai-flex ai-flex-col">
80
+ <Text size={1}>The quick brown fox jumps over the lazy dog.</Text>
81
+ <Text size={2}>The quick brown fox jumps over the lazy dog.</Text>
82
+ <Text size={3}>The quick brown fox jumps over the lazy dog.</Text>
83
+ <Text size={4}>The quick brown fox jumps over the lazy dog.</Text>
84
+ <Text size={5}>The quick brown fox jumps over the lazy dog.</Text>
85
+ <Text size={6}>The quick brown fox jumps over the lazy dog.</Text>
86
+ <Text size={7}>The quick brown fox jumps over the lazy dog.</Text>
87
+ <Text size={8}>The quick brown fox jumps over the lazy dog.</Text>
88
+ <Text size={9}>The quick brown fox jumps over the lazy dog.</Text>
89
+ </div>
90
+ )
91
+ },
92
+ }
93
+
94
+ export const Weights: Story = {
95
+ render() {
96
+ return (
97
+ <div className="ai-flex ai-flex-col">
98
+ <Text weights="light">The quick brown fox jumps over the lazy dog.</Text>
99
+ <Text weights="normal">The quick brown fox jumps over the lazy dog.</Text>
100
+ <Text weights="medium">The quick brown fox jumps over the lazy dog.</Text>
101
+ <Text weights="bold">The quick brown fox jumps over the lazy dog.</Text>
102
+ </div>
103
+ )
104
+ },
105
+ }
106
+
107
+ export const Html: Story = {
51
108
  render() {
52
109
  return (
53
- <>
54
- {sizes.map(size => (
55
- <Text as="p" key={size} size={size as any}>
56
- The quick brown fox jumps over the lazy dog.
57
- </Text>
58
- ))}
59
- </>
110
+ <Text
111
+ html={`The <span style='font-size:20px;font:bold; -webkit-background-clip: text; background: linear-gradient(
112
+ to right,
113
+ #00ff00, /* 绿色 */
114
+ #00ff99, /* 浅绿色 */
115
+ #00ffff, /* 青色 */
116
+ #0099ff, /* 浅蓝色 */
117
+ #8000ff, /* 紫色 */
118
+ #ff00ff /* 粉色 */
119
+ );color: transparent;background-clip: text;'>quick brown fox</span> <br/> jumps over the lazy dog.`}
120
+ />
60
121
  )
61
122
  },
62
123
  }
@@ -154,17 +154,17 @@
154
154
  --brand-color-1: #e42d46;
155
155
  }
156
156
 
157
- /* TODO: */
157
+
158
158
  :root[data-brand-theme='soundcore'] {
159
- --btn-bg-color: #17bbef;
159
+ --btn-bg-color: #17BBEF;
160
160
  --btn-text-color: #ffffff;
161
161
  --btn-bg-color-active: #48cffa;
162
162
  --btn-bg-disabled-color: #ccdfe8;
163
163
 
164
164
  --btn-bg-secondary-color: #ffffff;
165
- --btn-text-secondary-color: #333333;
166
- --btn-bg-secondary-active-color: #555555;
167
- --btn-bg-secondary-disabled-color: #f5f5f5;
165
+ --btn-text-secondary-color: #17BBEF;
166
+ --btn-bg-secondary-active-color: #17BBEF;
167
+ --btn-bg-secondary-disabled-color: #17BBEF;
168
168
 
169
169
  --btn-radius: 30px;
170
170