@anker-in/headless-ui 0.0.2

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 (59) hide show
  1. package/dist/esm/components/badge.d.ts +9 -0
  2. package/dist/esm/components/button.d.ts +19 -0
  3. package/dist/esm/components/checkbox.d.ts +4 -0
  4. package/dist/esm/components/dialog.d.ts +19 -0
  5. package/dist/esm/components/heading.d.ts +7 -0
  6. package/dist/esm/components/index.d.ts +10 -0
  7. package/dist/esm/components/input.d.ts +21 -0
  8. package/dist/esm/components/popover.d.ts +6 -0
  9. package/dist/esm/components/radio.d.ts +5 -0
  10. package/dist/esm/components/skeleton.d.ts +6 -0
  11. package/dist/esm/components/text.d.ts +8 -0
  12. package/dist/esm/components/theme.d.ts +8 -0
  13. package/dist/esm/helpers/component-props.d.ts +7 -0
  14. package/dist/esm/helpers/constants.d.ts +2 -0
  15. package/dist/esm/helpers/index.d.ts +1 -0
  16. package/dist/esm/helpers/utils.d.ts +2 -0
  17. package/dist/esm/icons/spinner.d.ts +8 -0
  18. package/dist/esm/index.d.ts +1 -0
  19. package/dist/esm/index.js +42 -0
  20. package/dist/esm/index.js.map +7 -0
  21. package/dist/esm/stories/badge.stories.d.ts +26 -0
  22. package/dist/esm/stories/button.stories.d.ts +39 -0
  23. package/dist/esm/stories/checkbox.stories.d.ts +6 -0
  24. package/dist/esm/stories/dialog.stories.d.ts +6 -0
  25. package/dist/esm/stories/input.stories.d.ts +30 -0
  26. package/dist/esm/stories/popover.stories.d.ts +6 -0
  27. package/dist/esm/stories/radio.stories.d.ts +6 -0
  28. package/dist/esm/stories/skeleton.stories.d.ts +14 -0
  29. package/dist/style.css +1352 -0
  30. package/package.json +64 -0
  31. package/src/components/__tests__/button.test.js +9 -0
  32. package/src/components/badge.tsx +29 -0
  33. package/src/components/button.tsx +92 -0
  34. package/src/components/checkbox.tsx +26 -0
  35. package/src/components/dialog.tsx +97 -0
  36. package/src/components/heading.tsx +23 -0
  37. package/src/components/index.ts +15 -0
  38. package/src/components/input.tsx +73 -0
  39. package/src/components/popover.tsx +29 -0
  40. package/src/components/radio.tsx +36 -0
  41. package/src/components/skeleton.tsx +10 -0
  42. package/src/components/text.tsx +22 -0
  43. package/src/components/theme.tsx +17 -0
  44. package/src/helpers/component-props.ts +17 -0
  45. package/src/helpers/constants.ts +3 -0
  46. package/src/helpers/index.ts +1 -0
  47. package/src/helpers/utils.ts +6 -0
  48. package/src/icons/spinner.tsx +30 -0
  49. package/src/index.ts +1 -0
  50. package/src/stories/badge.stories.tsx +44 -0
  51. package/src/stories/button.stories.tsx +90 -0
  52. package/src/stories/checkbox.stories.tsx +16 -0
  53. package/src/stories/dialog.stories.tsx +45 -0
  54. package/src/stories/input.stories.tsx +59 -0
  55. package/src/stories/popover.stories.tsx +24 -0
  56. package/src/stories/radio.stories.tsx +19 -0
  57. package/src/stories/skeleton.stories.tsx +33 -0
  58. package/src/styles/global.css +196 -0
  59. package/src/styles/index.css +0 -0
@@ -0,0 +1,90 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import { SearchIcon } from '@storybook/icons'
3
+
4
+ import { Button } from '../components/index'
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
+ // 同时定义了页面左侧菜单
10
+ title: 'Components/Button',
11
+ component: Button,
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
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
19
+ argTypes: {
20
+ variant: {
21
+ control: {
22
+ type: 'select',
23
+ },
24
+ options: ['primary', 'secondary', 'link', 'ghost'],
25
+ },
26
+ size: {
27
+ control: {
28
+ type: 'select',
29
+ },
30
+ options: ['sm', 'base', 'lg', 'icon'],
31
+ },
32
+ },
33
+ args: {
34
+ variant: 'primary',
35
+ size: 'base',
36
+ children: 'Button',
37
+ asChild: false,
38
+ disabled: false,
39
+ loading: false,
40
+ },
41
+ } satisfies Meta<typeof Button>
42
+
43
+ export default meta
44
+ type Story = StoryObj<typeof meta>
45
+
46
+ // More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
47
+ // args 会作为 props 传递给组件
48
+ // Story的名会作为菜单的名称 自动首字母大写并按照大写字母拆分 UseAsButton => Use As Button
49
+
50
+ export const Primary: Story = {
51
+ args: {
52
+ size: 'lg',
53
+ children: 'Primary',
54
+ },
55
+ }
56
+
57
+ export const Secondary: Story = {
58
+ args: {
59
+ size: 'lg',
60
+ variant: 'secondary',
61
+ children: 'Secondary',
62
+ },
63
+ }
64
+
65
+ export const Link: Story = {
66
+ args: {
67
+ size: 'lg',
68
+ variant: 'link',
69
+ children: 'Link',
70
+ },
71
+ }
72
+
73
+ export const WithIcon: Story = {
74
+ args: {
75
+ size: 'lg',
76
+ children: (
77
+ <>
78
+ WithIcon <SearchIcon className="ml-2" />
79
+ </>
80
+ ),
81
+ },
82
+ }
83
+
84
+ export const Aschild: Story = {
85
+ args: {
86
+ size: 'lg',
87
+ asChild: true,
88
+ children: <a href="http://example.com">as a a tag</a>,
89
+ },
90
+ }
@@ -0,0 +1,16 @@
1
+ import { Checkbox } from '../components/index'
2
+ import React from 'react'
3
+
4
+ export default { title: 'Components/Checkbox' }
5
+
6
+ export const Default = () => (
7
+ <div className="flex items-center space-x-2">
8
+ <Checkbox id="terms" />
9
+ <label
10
+ htmlFor="terms"
11
+ className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
12
+ >
13
+ Accept terms and conditions
14
+ </label>
15
+ </div>
16
+ )
@@ -0,0 +1,45 @@
1
+ import React from 'react'
2
+ import {
3
+ Button,
4
+ Dialog,
5
+ DialogContent,
6
+ DialogDescription,
7
+ DialogFooter,
8
+ DialogHeader,
9
+ DialogTitle,
10
+ DialogTrigger,
11
+ Input,
12
+ } from '../components/index'
13
+
14
+ export default { title: 'Components/Dialog' }
15
+
16
+ export const Default = () => (
17
+ <Dialog>
18
+ <DialogTrigger asChild>
19
+ <button>Edit Profile</button>
20
+ </DialogTrigger>
21
+ <DialogContent className="sm: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="grid gap-4 py-4">
27
+ <div className="grid grid-cols-4 items-center gap-4">
28
+ <label htmlFor="name" className="text-right">
29
+ Name
30
+ </label>
31
+ <Input id="name" defaultValue="Pedro Duarte" className="col-span-3" />
32
+ </div>
33
+ <div className="grid grid-cols-4 items-center gap-4">
34
+ <label htmlFor="username" className="text-right">
35
+ Username
36
+ </label>
37
+ <Input id="username" defaultValue="@peduarte" className="col-span-3" />
38
+ </div>
39
+ </div>
40
+ <DialogFooter>
41
+ <Button type="submit">Save changes</Button>
42
+ </DialogFooter>
43
+ </DialogContent>
44
+ </Dialog>
45
+ )
@@ -0,0 +1,59 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+ import type { ComponentType } from 'react'
3
+ import { Button, Input, InputSlot } from '../components/index'
4
+ import { SearchIcon } from '@storybook/icons'
5
+ import React from 'react'
6
+
7
+ const meta = {
8
+ title: 'Components/Input',
9
+ component: Input,
10
+ subcomponents: { InputSlot: InputSlot as ComponentType<unknown> }, // TODO: 检查type , 去掉as类型转换
11
+ parameters: {
12
+ layout: 'centered',
13
+ },
14
+ tags: ['autodocs'],
15
+ argTypes: {
16
+ size: {
17
+ control: {
18
+ type: 'select',
19
+ },
20
+ options: ['sm', 'base', 'lg'],
21
+ },
22
+ },
23
+ args: {
24
+ size: 'base',
25
+ },
26
+ } satisfies Meta<typeof Input>
27
+
28
+ export default meta
29
+
30
+ type Story = StoryObj<typeof meta>
31
+
32
+ export const Default: Story = {
33
+ args: {},
34
+ }
35
+
36
+ export const WithButton: Story = {
37
+ render() {
38
+ return (
39
+ <Input className="rounded-3xl pr-0" placeholder="Enter your email" type="text">
40
+ <InputSlot side="right">
41
+ <Button className="h-full rounded-none" size="sm">
42
+ subscribe
43
+ </Button>
44
+ </InputSlot>
45
+ </Input>
46
+ )
47
+ },
48
+ }
49
+ export const WithIcon: Story = {
50
+ render() {
51
+ return (
52
+ <Input type="text" placeholder="search in site">
53
+ <InputSlot side="left">
54
+ <SearchIcon />
55
+ </InputSlot>
56
+ </Input>
57
+ )
58
+ },
59
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react'
2
+ import { Popover, PopoverContent, PopoverTrigger } from '../components/index'
3
+
4
+ export default { title: 'Components/Popover' }
5
+
6
+ export const Default = () => (
7
+ <Popover>
8
+ <PopoverTrigger asChild>
9
+ <button>Open popover</button>
10
+ </PopoverTrigger>
11
+ <PopoverContent className="w-80">
12
+ <div className="grid gap-4">
13
+ <p>
14
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
15
+ standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to
16
+ make a type specimen book. It has survived not only five centuries, but also the leap into electronic
17
+ typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
18
+ sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
19
+ PageMaker including versions of Lorem Ipsum.
20
+ </p>
21
+ </div>
22
+ </PopoverContent>
23
+ </Popover>
24
+ )
@@ -0,0 +1,19 @@
1
+ import { RadioGroup, RadioGroupItem } from '../components/index'
2
+ import React from 'react'
3
+
4
+ export default { title: 'Components/Radio' }
5
+
6
+ export const Default = () => (
7
+ <div className="flex h-40 w-48 items-center justify-center">
8
+ <RadioGroup defaultValue="option-one">
9
+ <div className="flex items-center space-x-2">
10
+ <RadioGroupItem value="option-one" id="option-one" />
11
+ <label htmlFor="option-one">Option One</label>
12
+ </div>
13
+ <div className="flex items-center 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
+ )
@@ -0,0 +1,33 @@
1
+ import type { Meta, StoryObj } from '@storybook/react'
2
+
3
+ import { Skeleton } from '../components/index'
4
+ import React from 'react'
5
+
6
+ const meta = {
7
+ title: 'Components/Skeleton',
8
+ component: Skeleton,
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ tags: ['autodocs'],
13
+ } satisfies Meta<typeof Skeleton>
14
+
15
+ export default meta
16
+
17
+ type Story = StoryObj<typeof meta>
18
+
19
+ export const Default: Story = {}
20
+
21
+ export const Example: Story = {
22
+ render() {
23
+ return (
24
+ <div className="flex flex-col items-center justify-center">
25
+ <div className="flex w-full justify-between">
26
+ <Skeleton className="size-12 rounded-full" />
27
+ <Skeleton className="h-12 w-[70%] " />
28
+ </div>
29
+ <Skeleton className="mt-2 h-40 w-[200px]" />
30
+ </div>
31
+ )
32
+ },
33
+ }
@@ -0,0 +1,196 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ --btn-bg-color: #00a7e1;
7
+ --btn-text-color: #ffffff;
8
+ --btn-bg-active-color: #00a7e1;
9
+ --btn-bg-disabled-color: #ccdfe8;
10
+
11
+ --btn-bg-secondary-color: #ffffff;
12
+ --btn-text-secondary-color: #333333;
13
+ --btn-bg-secondary-active-color: #555555;
14
+ --btn-bg-secondary-disabled-color: #f5f5f5;
15
+
16
+ --btn-radius: 0;
17
+
18
+ --radius: 3em;
19
+
20
+ --brand-color-1: #005d8e;
21
+ --brand-color-2: ##337da5;
22
+ --brand-color-3: ##669ebb;
23
+ --brand-color-4: #99bed2;
24
+ --brand-color-5: #ccdfe8;
25
+
26
+ --secondary-brand-color-1: #042637;
27
+ --secondary-brand-color-2: #b3ecfb;
28
+ --secondary-brand-color-3: #f8f7f6;
29
+
30
+ --success-color-1: #34c759;
31
+ --success-color-2: #5dd27a;
32
+ --success-color-3: #85dd9b;
33
+ --success-color-4: #aee9bd;
34
+ --success-color-5: #d6f4de;
35
+
36
+ --warning-color-1: #ffc24d;
37
+ --warning-color-2: #fdcc6e;
38
+ --warning-color-3: #fbd68f;
39
+ --warning-color-4: #f8e0af;
40
+ --warning-color-5: #f6ead0;
41
+
42
+ --error-color-1: #ff4d4d;
43
+ --error-color-2: #fd6e6e;
44
+ --error-color-3: #fb908f;
45
+ --error-color-4: #f8b1af;
46
+ --error-color-5: #f6d3d0;
47
+
48
+ --primary-color: #333333;
49
+ --secondary-color: #666666;
50
+ --tertiary-color: #999999;
51
+ --quaternary-color: #cccccc;
52
+ --white-color: #ffffff;
53
+ --white-disable-color: hsla(0, 0%, 96%, 0.5);
54
+
55
+ --container-primary-color: #ffffff;
56
+ --container-secondary-color: #f4f4f1;
57
+
58
+ --bg-color-1: #f4f4f1;
59
+ --bg-color-2: #efefec;
60
+
61
+ --line-color: #e9e9e9;
62
+
63
+ --masks-color-1: hsla(0, 0%, 0%, 0.5);
64
+ --masks-color-2: hsla(0, 0%, 0%, 0.85);
65
+ }
66
+
67
+ :root[data-brand-theme='anker'] {
68
+ --btn-bg-color: #00a7e1;
69
+ --btn-text-color: #ffffff;
70
+ --btn-bg-active-color: #02b8f4;
71
+ --btn-bg-disabled-color: #ccdfe8;
72
+
73
+ --btn-bg-secondary-color: #ffffff;
74
+ --btn-text-secondary-color: #333333;
75
+ --btn-bg-secondary-active-color: #555555;
76
+ --btn-bg-secondary-disabled-color: #f5f5f5;
77
+
78
+ --btn-radius: 9999px;
79
+
80
+ --radius: 0em;
81
+ }
82
+
83
+ :root[data-brand-theme='eufy'] {
84
+ --btn-bg-color: #005d8e;
85
+ --btn-text-color: #ffffff;
86
+ --btn-bg-active-color: #669ebb;
87
+ --btn-bg-disabled-color: #ccdfe8;
88
+
89
+ --btn-bg-secondary-color: #ffffff;
90
+ --btn-text-secondary-color: #333333;
91
+ --btn-bg-secondary-active-color: #555555;
92
+ --btn-bg-secondary-disabled-color: #f5f5f5;
93
+
94
+ --btn-radius: 40px;
95
+
96
+ --radius: 40px;
97
+
98
+ --brand-color-1: #005d8e;
99
+ --brand-color-2: ##337da5;
100
+ --brand-color-3: ##669ebb;
101
+ --brand-color-4: #99bed2;
102
+ --brand-color-5: #ccdfe8;
103
+
104
+ --secondary-brand-color-1: #042637;
105
+ --secondary-brand-color-2: #b3ecfb;
106
+ --secondary-brand-color-3: #f8f7f6;
107
+
108
+ --success-color-1: #34c759;
109
+ --success-color-2: #5dd27a;
110
+ --success-color-3: #85dd9b;
111
+ --success-color-4: #aee9bd;
112
+ --success-color-5: #d6f4de;
113
+
114
+ --warning-color-1: #ffc24d;
115
+ --warning-color-2: #fdcc6e;
116
+ --warning-color-3: #fbd68f;
117
+ --warning-color-4: #f8e0af;
118
+ --warning-color-5: #f6ead0;
119
+
120
+ --error-color-1: #ff4d4d;
121
+ --error-color-2: #fd6e6e;
122
+ --error-color-3: #fb908f;
123
+ --error-color-4: #f8b1af;
124
+ --error-color-5: #f6d3d0;
125
+
126
+ --primary-color: #333333;
127
+ --secondary-color: #666666;
128
+ --tertiary-color: #999999;
129
+ --quaternary-color: #cccccc;
130
+ --white-color: #ffffff;
131
+ --white-disable-color: hsla(0, 0%, 96%, 0.5);
132
+
133
+ --container-primary-color: #ffffff;
134
+ --container-secondary-color: #f4f4f1;
135
+
136
+ --bg-color-1: #f4f4f1;
137
+ --bg-color-2: #efefec;
138
+
139
+ --line-color: #e9e9e9;
140
+
141
+ --masks-color-1: hsla(0, 0%, 0%, 0.5);
142
+ --masks-color-2: hsla(0, 0%, 0%, 0.85);
143
+ }
144
+
145
+ :root[data-brand-theme='nebula'] {
146
+ --btn-bg-color: #e42d46;
147
+ --btn-text-color: #ffffff;
148
+ --btn-bg-active-color: #ff3d5a;
149
+
150
+ --btn-radius: 0;
151
+
152
+ --radius: 0em;
153
+
154
+ --brand-color-1: #e42d46;
155
+ }
156
+
157
+ /* TODO: */
158
+ :root[data-brand-theme='soundCore'] {
159
+ --btn-bg-color: #17bbef;
160
+ --btn-text-color: #ffffff;
161
+ --btn-bg-color-active: #48cffa;
162
+ --btn-bg-disabled-color: #ccdfe8;
163
+
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;
168
+
169
+ --btn-radius: 30px;
170
+
171
+ --radius: 0em;
172
+
173
+ --brand-color-1: #17bbef;
174
+ }
175
+
176
+ :root[data-brand-theme='ankerWork'] {
177
+ --btn-bg-color: #00a7e1;
178
+ --btn-text-color: ##fff;
179
+ --btn-bg-active-color: #606060;
180
+
181
+ --btn-radius: 0px;
182
+ --radius: 0em;
183
+
184
+ --brand-color-1: #00a7e1;
185
+ }
186
+
187
+ :root[data-brand-theme='ankerMake'] {
188
+ --btn-bg-color: #88f387;
189
+ --btn-text-color: #333333;
190
+ --btn-bg-active-color: #88f387;
191
+
192
+ --btn-radius: 9999px;
193
+ --radius: 0em;
194
+
195
+ --brand-color-1: #88f387;
196
+ }
File without changes