@shipfox/react-ui 0.0.1 → 0.2.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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-check.log +2 -2
- package/.turbo/turbo-type.log +1 -1
- package/CHANGELOG.md +16 -0
- package/README.md +21 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.d.ts +10 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +32 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/input.stories.js +199 -0
- package/dist/components/input.stories.js.map +1 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.d.ts.map +1 -0
- package/dist/components/textarea/index.js +3 -0
- package/dist/components/textarea/index.js.map +1 -0
- package/dist/components/textarea/textarea.d.ts +10 -0
- package/dist/components/textarea/textarea.d.ts.map +1 -0
- package/dist/components/textarea/textarea.js +31 -0
- package/dist/components/textarea/textarea.js.map +1 -0
- package/dist/components/textarea/textarea.stories.js +333 -0
- package/dist/components/textarea/textarea.stories.js.map +1 -0
- package/index.css +9 -0
- package/package.json +7 -7
- package/src/components/index.ts +1 -0
- package/src/components/input.stories.tsx +138 -0
- package/src/components/input.tsx +43 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/textarea.stories.tsx +190 -0
- package/src/components/textarea/textarea.tsx +42 -0
- package/src/utils/date.test.ts +1 -1
- package/src/utils/format/date.test.ts +1 -1
- package/src/utils/format/duration.test.ts +1 -1
- package/src/utils/format/number.test.ts +1 -1
- package/test/setup.ts +1 -1
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Code, Header } from '../../components/typography/index.js';
|
|
3
|
+
import { Textarea } from './textarea.js';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Components/Textarea',
|
|
6
|
+
component: Textarea,
|
|
7
|
+
tags: [
|
|
8
|
+
'autodocs'
|
|
9
|
+
],
|
|
10
|
+
argTypes: {
|
|
11
|
+
placeholder: {
|
|
12
|
+
control: 'text'
|
|
13
|
+
},
|
|
14
|
+
disabled: {
|
|
15
|
+
control: 'boolean'
|
|
16
|
+
},
|
|
17
|
+
'aria-invalid': {
|
|
18
|
+
control: 'boolean'
|
|
19
|
+
},
|
|
20
|
+
rows: {
|
|
21
|
+
control: 'number'
|
|
22
|
+
},
|
|
23
|
+
cols: {
|
|
24
|
+
control: 'number'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
args: {
|
|
28
|
+
placeholder: 'Type something…',
|
|
29
|
+
disabled: false,
|
|
30
|
+
'aria-invalid': false,
|
|
31
|
+
rows: 4
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
export const Default = {};
|
|
36
|
+
const variants = [
|
|
37
|
+
'base',
|
|
38
|
+
'component'
|
|
39
|
+
];
|
|
40
|
+
const sizes = [
|
|
41
|
+
'base',
|
|
42
|
+
'small'
|
|
43
|
+
];
|
|
44
|
+
export const States = {
|
|
45
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
46
|
+
className: "flex flex-col gap-32",
|
|
47
|
+
children: variants.map((variant)=>sizes.map((size)=>/*#__PURE__*/ _jsxs("div", {
|
|
48
|
+
className: "flex flex-col gap-16",
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ _jsxs(Header, {
|
|
51
|
+
variant: "h3",
|
|
52
|
+
children: [
|
|
53
|
+
variant,
|
|
54
|
+
" ",
|
|
55
|
+
size
|
|
56
|
+
]
|
|
57
|
+
}),
|
|
58
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
59
|
+
className: "flex flex-col gap-8",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
62
|
+
variant: "label",
|
|
63
|
+
className: "text-foreground-neutral-subtle",
|
|
64
|
+
children: "Default"
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
67
|
+
...args,
|
|
68
|
+
variant: variant,
|
|
69
|
+
size: size
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
74
|
+
className: "flex flex-col gap-8",
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
77
|
+
variant: "label",
|
|
78
|
+
className: "text-foreground-neutral-subtle",
|
|
79
|
+
children: "Hover"
|
|
80
|
+
}),
|
|
81
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
82
|
+
...args,
|
|
83
|
+
className: "hover",
|
|
84
|
+
variant: variant,
|
|
85
|
+
size: size
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
90
|
+
className: "flex flex-col gap-8",
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
93
|
+
variant: "label",
|
|
94
|
+
className: "text-foreground-neutral-subtle",
|
|
95
|
+
children: "Active"
|
|
96
|
+
}),
|
|
97
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
98
|
+
...args,
|
|
99
|
+
className: "active",
|
|
100
|
+
defaultValue: "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.",
|
|
101
|
+
variant: variant,
|
|
102
|
+
size: size
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}),
|
|
106
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
107
|
+
className: "flex flex-col gap-8",
|
|
108
|
+
children: [
|
|
109
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
110
|
+
variant: "label",
|
|
111
|
+
className: "text-foreground-neutral-subtle",
|
|
112
|
+
children: "Focus"
|
|
113
|
+
}),
|
|
114
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
115
|
+
...args,
|
|
116
|
+
className: "focus",
|
|
117
|
+
variant: variant,
|
|
118
|
+
size: size
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
122
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
123
|
+
className: "flex flex-col gap-8",
|
|
124
|
+
children: [
|
|
125
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
126
|
+
variant: "label",
|
|
127
|
+
className: "text-foreground-neutral-subtle",
|
|
128
|
+
children: "Disabled"
|
|
129
|
+
}),
|
|
130
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
131
|
+
...args,
|
|
132
|
+
disabled: true,
|
|
133
|
+
variant: variant,
|
|
134
|
+
size: size
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
139
|
+
className: "flex flex-col gap-8",
|
|
140
|
+
children: [
|
|
141
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
142
|
+
variant: "label",
|
|
143
|
+
className: "text-foreground-neutral-subtle",
|
|
144
|
+
children: "Invalid"
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
147
|
+
...args,
|
|
148
|
+
"aria-invalid": true,
|
|
149
|
+
variant: variant,
|
|
150
|
+
size: size
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}, variant + size)))
|
|
156
|
+
})
|
|
157
|
+
};
|
|
158
|
+
States.parameters = {
|
|
159
|
+
pseudo: {
|
|
160
|
+
hover: '.hover',
|
|
161
|
+
active: '.active',
|
|
162
|
+
focusVisible: '.focus'
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
export const Sizes = {
|
|
166
|
+
render: (args)=>/*#__PURE__*/ _jsxs("div", {
|
|
167
|
+
className: "flex flex-col gap-32",
|
|
168
|
+
children: [
|
|
169
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
170
|
+
className: "flex flex-col gap-8",
|
|
171
|
+
children: [
|
|
172
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
173
|
+
variant: "label",
|
|
174
|
+
className: "text-foreground-neutral-subtle",
|
|
175
|
+
children: "Rows: 2"
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
178
|
+
...args,
|
|
179
|
+
rows: 2
|
|
180
|
+
})
|
|
181
|
+
]
|
|
182
|
+
}),
|
|
183
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
184
|
+
className: "flex flex-col gap-8",
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
187
|
+
variant: "label",
|
|
188
|
+
className: "text-foreground-neutral-subtle",
|
|
189
|
+
children: "Rows: 4 (default)"
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
192
|
+
...args,
|
|
193
|
+
rows: 4
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
}),
|
|
197
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
198
|
+
className: "flex flex-col gap-8",
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
201
|
+
variant: "label",
|
|
202
|
+
className: "text-foreground-neutral-subtle",
|
|
203
|
+
children: "Rows: 6"
|
|
204
|
+
}),
|
|
205
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
206
|
+
...args,
|
|
207
|
+
rows: 6
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
}),
|
|
211
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
212
|
+
className: "flex flex-col gap-8",
|
|
213
|
+
children: [
|
|
214
|
+
/*#__PURE__*/ _jsx(Code, {
|
|
215
|
+
variant: "label",
|
|
216
|
+
className: "text-foreground-neutral-subtle",
|
|
217
|
+
children: "Rows: 10"
|
|
218
|
+
}),
|
|
219
|
+
/*#__PURE__*/ _jsx(Textarea, {
|
|
220
|
+
...args,
|
|
221
|
+
rows: 10
|
|
222
|
+
})
|
|
223
|
+
]
|
|
224
|
+
})
|
|
225
|
+
]
|
|
226
|
+
})
|
|
227
|
+
};
|
|
228
|
+
export const DesignMock = {
|
|
229
|
+
render: ()=>{
|
|
230
|
+
const variants = [
|
|
231
|
+
{
|
|
232
|
+
key: 'base',
|
|
233
|
+
label: 'Primary'
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
key: 'component',
|
|
237
|
+
label: 'Secondary'
|
|
238
|
+
}
|
|
239
|
+
];
|
|
240
|
+
const states = [
|
|
241
|
+
{
|
|
242
|
+
name: 'Default',
|
|
243
|
+
props: {}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: 'Hover',
|
|
247
|
+
props: {
|
|
248
|
+
className: 'hover'
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'Focus',
|
|
253
|
+
props: {
|
|
254
|
+
className: 'focus'
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'Filled',
|
|
259
|
+
props: {
|
|
260
|
+
defaultValue: 'Placeholder'
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'Filled Hover',
|
|
265
|
+
props: {
|
|
266
|
+
defaultValue: 'Placeholder',
|
|
267
|
+
className: 'hover'
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'Disabled',
|
|
272
|
+
props: {
|
|
273
|
+
disabled: true
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: 'Error',
|
|
278
|
+
props: {
|
|
279
|
+
'aria-invalid': true
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
];
|
|
283
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
284
|
+
className: "flex flex-col gap-32 pb-64 pt-32 px-32",
|
|
285
|
+
children: [
|
|
286
|
+
/*#__PURE__*/ _jsx(Header, {
|
|
287
|
+
variant: "h3",
|
|
288
|
+
className: "text-foreground-neutral-subtle",
|
|
289
|
+
children: "TEXT AREA"
|
|
290
|
+
}),
|
|
291
|
+
/*#__PURE__*/ _jsx("div", {
|
|
292
|
+
className: "flex flex-row gap-32",
|
|
293
|
+
children: variants.map((variant)=>/*#__PURE__*/ _jsx("div", {
|
|
294
|
+
className: "flex flex-col gap-32",
|
|
295
|
+
children: states.map((state)=>/*#__PURE__*/ _jsxs("div", {
|
|
296
|
+
className: "flex flex-col gap-8",
|
|
297
|
+
children: [
|
|
298
|
+
/*#__PURE__*/ _jsxs(Code, {
|
|
299
|
+
variant: "label",
|
|
300
|
+
className: "text-foreground-neutral-subtle",
|
|
301
|
+
children: [
|
|
302
|
+
"Size=Base (32), State=",
|
|
303
|
+
state.name,
|
|
304
|
+
", Color=",
|
|
305
|
+
variant.label
|
|
306
|
+
]
|
|
307
|
+
}),
|
|
308
|
+
/*#__PURE__*/ _jsx("div", {
|
|
309
|
+
className: "w-[280px]",
|
|
310
|
+
children: /*#__PURE__*/ _jsx(Textarea, {
|
|
311
|
+
placeholder: "Placeholder",
|
|
312
|
+
variant: variant.key,
|
|
313
|
+
size: "base",
|
|
314
|
+
rows: 2,
|
|
315
|
+
...state.props
|
|
316
|
+
})
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
}, state.name))
|
|
320
|
+
}, variant.key))
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
DesignMock.parameters = {
|
|
327
|
+
pseudo: {
|
|
328
|
+
hover: '.hover',
|
|
329
|
+
focusVisible: '.focus'
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
//# sourceMappingURL=textarea.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/textarea/textarea.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code, Header} from 'components/typography';\nimport {Textarea} from './textarea';\n\nconst meta = {\n title: 'Components/Textarea',\n component: Textarea,\n tags: ['autodocs'],\n argTypes: {\n placeholder: {control: 'text'},\n disabled: {control: 'boolean'},\n 'aria-invalid': {control: 'boolean'},\n rows: {control: 'number'},\n cols: {control: 'number'},\n },\n args: {\n placeholder: 'Type something…',\n disabled: false,\n 'aria-invalid': false,\n rows: 4,\n },\n} satisfies Meta<typeof Textarea>;\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {};\n\nconst variants = ['base', 'component'] as const;\nconst sizes = ['base', 'small'] as const;\n\nexport const States: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n {variants.map((variant) =>\n sizes.map((size) => (\n <div key={variant + size} className=\"flex flex-col gap-16\">\n <Header variant=\"h3\">\n {variant} {size}\n </Header>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Default\n </Code>\n\n <Textarea {...args} variant={variant} size={size} />\n </div>\n\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Hover\n </Code>\n\n <Textarea {...args} className=\"hover\" variant={variant} size={size} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Active\n </Code>\n\n <Textarea\n {...args}\n className=\"active\"\n defaultValue=\"The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.\"\n variant={variant}\n size={size}\n />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Focus\n </Code>\n\n <Textarea {...args} className=\"focus\" variant={variant} size={size} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Disabled\n </Code>\n\n <Textarea {...args} disabled variant={variant} size={size} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Invalid\n </Code>\n\n <Textarea {...args} aria-invalid variant={variant} size={size} />\n </div>\n </div>\n )),\n )}\n </div>\n ),\n};\n\nStates.parameters = {\n pseudo: {\n hover: '.hover',\n active: '.active',\n focusVisible: '.focus',\n },\n};\n\nexport const Sizes: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Rows: 2\n </Code>\n <Textarea {...args} rows={2} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Rows: 4 (default)\n </Code>\n <Textarea {...args} rows={4} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Rows: 6\n </Code>\n <Textarea {...args} rows={6} />\n </div>\n <div className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Rows: 10\n </Code>\n <Textarea {...args} rows={10} />\n </div>\n </div>\n ),\n};\n\nexport const DesignMock: Story = {\n render: () => {\n const variants = [\n {key: 'base', label: 'Primary'},\n {key: 'component', label: 'Secondary'},\n ] as const;\n const states = [\n {name: 'Default', props: {}},\n {name: 'Hover', props: {className: 'hover'}},\n {name: 'Focus', props: {className: 'focus'}},\n {name: 'Filled', props: {defaultValue: 'Placeholder'}},\n {name: 'Filled Hover', props: {defaultValue: 'Placeholder', className: 'hover'}},\n {name: 'Disabled', props: {disabled: true}},\n {name: 'Error', props: {'aria-invalid': true}},\n ] as const;\n\n return (\n <div className=\"flex flex-col gap-32 pb-64 pt-32 px-32\">\n <Header variant=\"h3\" className=\"text-foreground-neutral-subtle\">\n TEXT AREA\n </Header>\n <div className=\"flex flex-row gap-32\">\n {variants.map((variant) => (\n <div key={variant.key} className=\"flex flex-col gap-32\">\n {states.map((state) => (\n <div key={state.name} className=\"flex flex-col gap-8\">\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n Size=Base (32), State={state.name}, Color={variant.label}\n </Code>\n <div className=\"w-[280px]\">\n <Textarea\n placeholder=\"Placeholder\"\n variant={variant.key}\n size=\"base\"\n rows={2}\n {...state.props}\n />\n </div>\n </div>\n ))}\n </div>\n ))}\n </div>\n </div>\n );\n },\n};\n\nDesignMock.parameters = {\n pseudo: {\n hover: '.hover',\n focusVisible: '.focus',\n },\n};\n"],"names":["Code","Header","Textarea","meta","title","component","tags","argTypes","placeholder","control","disabled","rows","cols","args","Default","variants","sizes","States","render","div","className","map","variant","size","defaultValue","aria-invalid","parameters","pseudo","hover","active","focusVisible","Sizes","DesignMock","key","label","states","name","props","state"],"mappings":";AACA,SAAQA,IAAI,EAAEC,MAAM,QAAO,wBAAwB;AACnD,SAAQC,QAAQ,QAAO,aAAa;AAEpC,MAAMC,OAAO;IACXC,OAAO;IACPC,WAAWH;IACXI,MAAM;QAAC;KAAW;IAClBC,UAAU;QACRC,aAAa;YAACC,SAAS;QAAM;QAC7BC,UAAU;YAACD,SAAS;QAAS;QAC7B,gBAAgB;YAACA,SAAS;QAAS;QACnCE,MAAM;YAACF,SAAS;QAAQ;QACxBG,MAAM;YAACH,SAAS;QAAQ;IAC1B;IACAI,MAAM;QACJL,aAAa;QACbE,UAAU;QACV,gBAAgB;QAChBC,MAAM;IACR;AACF;AAEA,eAAeR,KAAK;AAIpB,OAAO,MAAMW,UAAiB,CAAC,EAAE;AAEjC,MAAMC,WAAW;IAAC;IAAQ;CAAY;AACtC,MAAMC,QAAQ;IAAC;IAAQ;CAAQ;AAE/B,OAAO,MAAMC,SAAgB;IAC3BC,QAAQ,CAACL,qBACP,KAACM;YAAIC,WAAU;sBACZL,SAASM,GAAG,CAAC,CAACC,UACbN,MAAMK,GAAG,CAAC,CAACE,qBACT,MAACJ;wBAAyBC,WAAU;;0CAClC,MAACnB;gCAAO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B;oBAAOqB,SAAQ;oBAAKF,WAAU;8BAAiC;;8BAGhE,KAACD;oBAAIC,WAAU;8BACZL,SAASM,GAAG,CAAC,CAACC,wBACb,KAACH;4BAAsBC,WAAU;sCAC9Be,OAAOd,GAAG,CAAC,CAACiB,sBACX,MAACnB;oCAAqBC,WAAU;;sDAC9B,MAACpB;4CAAKsB,SAAQ;4CAAQF,WAAU;;gDAAiC;gDACxCkB,MAAMF,IAAI;gDAAC;gDAASd,QAAQY,KAAK;;;sDAE1D,KAACf;4CAAIC,WAAU;sDACb,cAAA,KAAClB;gDACCM,aAAY;gDACZc,SAASA,QAAQW,GAAG;gDACpBV,MAAK;gDACLZ,MAAM;gDACL,GAAG2B,MAAMD,KAAK;;;;mCAVXC,MAAMF,IAAI;2BAFdd,QAAQW,GAAG;;;;IAsB/B;AACF,EAAE;AAEFD,WAAWN,UAAU,GAAG;IACtBC,QAAQ;QACNC,OAAO;QACPE,cAAc;IAChB;AACF"}
|
package/index.css
CHANGED
|
@@ -421,6 +421,12 @@
|
|
|
421
421
|
--alpha-400: var(--color-alpha-white-24);
|
|
422
422
|
|
|
423
423
|
/* Shadow */
|
|
424
|
+
--shadow-border-base:
|
|
425
|
+
0 -1px 0 0 var(--color-alpha-white-6), 0 0 0 1px var(--color-alpha-white-6), 0 0 0 1px
|
|
426
|
+
var(--color-neutral-800), 0 0 1px 1.5px var(--color-alpha-black-24), 0 2px 2px 0
|
|
427
|
+
var(--color-alpha-black-24);
|
|
428
|
+
--shadow-border-interactive-with-active: 0 0 0 1px #ff8b16, 0 0 0 4px rgba(255, 49, 0, 0.25);
|
|
429
|
+
--shadow-border-error: 0 0 0 1px #ff1f5a, 0 0 0 3px rgba(246, 0, 67, 0.25);
|
|
424
430
|
--shadow-button-inverted:
|
|
425
431
|
0 -1px 0 0 var(--color-alpha-white-12), 0 0 0 1px var(--color-alpha-white-10), 0 0 0 1px
|
|
426
432
|
var(--color-neutral-600), 0 0 1px 1.5px var(--color-alpha-black-24), 0 2px 2px 0
|
|
@@ -756,6 +762,9 @@
|
|
|
756
762
|
--font-display: "Inter", sans-serif;
|
|
757
763
|
|
|
758
764
|
/* Shadow */
|
|
765
|
+
--shadow-border-base: var(--shadow-border-base);
|
|
766
|
+
--shadow-border-interactive-with-active: var(--shadow-border-interactive-with-active);
|
|
767
|
+
--shadow-border-error: var(--shadow-border-error);
|
|
759
768
|
--shadow-button-inverted: var(--shadow-button-inverted);
|
|
760
769
|
--shadow-button-inverted-focus: var(--shadow-button-inverted-focus);
|
|
761
770
|
--shadow-button-neutral: var(--shadow-button-neutral);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/react-ui",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"storybook-addon-pseudo-states": "^9.1.8",
|
|
57
57
|
"tailwindcss": "^4.1.13",
|
|
58
58
|
"tw-animate-css": "^1.4.0",
|
|
59
|
-
"@shipfox/biome": "1.2.
|
|
60
|
-
"@shipfox/swc": "1.2.
|
|
61
|
-
"@shipfox/ts-config": "1.3.
|
|
62
|
-
"@shipfox/typescript": "1.1.
|
|
63
|
-
"@shipfox/vite": "1.2.
|
|
64
|
-
"@shipfox/vitest": "1.1.
|
|
59
|
+
"@shipfox/biome": "1.2.2",
|
|
60
|
+
"@shipfox/swc": "1.2.1",
|
|
61
|
+
"@shipfox/ts-config": "1.3.5",
|
|
62
|
+
"@shipfox/typescript": "1.1.2",
|
|
63
|
+
"@shipfox/vite": "1.2.2",
|
|
64
|
+
"@shipfox/vitest": "1.1.3"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "swc",
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/react';
|
|
2
|
+
import {Code, Header} from 'components/typography';
|
|
3
|
+
import {Input} from './input';
|
|
4
|
+
|
|
5
|
+
const typeOptions = [
|
|
6
|
+
'text',
|
|
7
|
+
'email',
|
|
8
|
+
'password',
|
|
9
|
+
'number',
|
|
10
|
+
'search',
|
|
11
|
+
'url',
|
|
12
|
+
'tel',
|
|
13
|
+
'date',
|
|
14
|
+
'time',
|
|
15
|
+
'datetime-local',
|
|
16
|
+
'month',
|
|
17
|
+
'week',
|
|
18
|
+
'color',
|
|
19
|
+
'file',
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
const meta = {
|
|
23
|
+
title: 'Components/Input',
|
|
24
|
+
component: Input,
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
argTypes: {
|
|
27
|
+
type: {
|
|
28
|
+
control: 'select',
|
|
29
|
+
options: typeOptions,
|
|
30
|
+
},
|
|
31
|
+
placeholder: {control: 'text'},
|
|
32
|
+
disabled: {control: 'boolean'},
|
|
33
|
+
'aria-invalid': {control: 'boolean'},
|
|
34
|
+
},
|
|
35
|
+
args: {
|
|
36
|
+
type: 'text',
|
|
37
|
+
placeholder: 'Type something…',
|
|
38
|
+
disabled: false,
|
|
39
|
+
'aria-invalid': false,
|
|
40
|
+
},
|
|
41
|
+
} satisfies Meta<typeof Input>;
|
|
42
|
+
|
|
43
|
+
export default meta;
|
|
44
|
+
|
|
45
|
+
type Story = StoryObj<typeof meta>;
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {};
|
|
48
|
+
|
|
49
|
+
const variants = ['base', 'component'] as const;
|
|
50
|
+
const sizes = ['base', 'small'] as const;
|
|
51
|
+
|
|
52
|
+
export const States: Story = {
|
|
53
|
+
render: (args) => (
|
|
54
|
+
<div className="flex flex-col gap-32">
|
|
55
|
+
{variants.map((variant) =>
|
|
56
|
+
sizes.map((size) => (
|
|
57
|
+
<div key={variant + size} className="flex flex-col gap-16">
|
|
58
|
+
<Header variant="h3">
|
|
59
|
+
{variant} {size}
|
|
60
|
+
</Header>
|
|
61
|
+
<div className="flex flex-col gap-8">
|
|
62
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
63
|
+
Default
|
|
64
|
+
</Code>
|
|
65
|
+
|
|
66
|
+
<Input {...args} variant={variant} size={size} />
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div className="flex flex-col gap-8">
|
|
70
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
71
|
+
Hover
|
|
72
|
+
</Code>
|
|
73
|
+
|
|
74
|
+
<Input {...args} className="hover" variant={variant} size={size} />
|
|
75
|
+
</div>
|
|
76
|
+
<div className="flex flex-col gap-8">
|
|
77
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
78
|
+
Active
|
|
79
|
+
</Code>
|
|
80
|
+
|
|
81
|
+
<Input
|
|
82
|
+
{...args}
|
|
83
|
+
className="active"
|
|
84
|
+
defaultValue="The quick brown fox jumps over the lazy dog"
|
|
85
|
+
variant={variant}
|
|
86
|
+
size={size}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
<div className="flex flex-col gap-8">
|
|
90
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
91
|
+
Focus
|
|
92
|
+
</Code>
|
|
93
|
+
|
|
94
|
+
<Input {...args} className="focus" variant={variant} size={size} />
|
|
95
|
+
</div>
|
|
96
|
+
<div className="flex flex-col gap-8">
|
|
97
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
98
|
+
Disabled
|
|
99
|
+
</Code>
|
|
100
|
+
|
|
101
|
+
<Input {...args} disabled variant={variant} size={size} />
|
|
102
|
+
</div>
|
|
103
|
+
<div className="flex flex-col gap-8">
|
|
104
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
105
|
+
Invalid
|
|
106
|
+
</Code>
|
|
107
|
+
|
|
108
|
+
<Input {...args} aria-invalid variant={variant} size={size} />
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
)),
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
States.parameters = {
|
|
118
|
+
pseudo: {
|
|
119
|
+
hover: '.hover',
|
|
120
|
+
active: '.active',
|
|
121
|
+
focusVisible: '.focus',
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const Types: Story = {
|
|
126
|
+
render: (args) => (
|
|
127
|
+
<div className="flex flex-col gap-32">
|
|
128
|
+
{typeOptions.map((t) => (
|
|
129
|
+
<div key={t} className="flex flex-col gap-8">
|
|
130
|
+
<Code variant="label" className="text-foreground-neutral-subtle">
|
|
131
|
+
{t}
|
|
132
|
+
</Code>
|
|
133
|
+
<Input {...args} type={t} />
|
|
134
|
+
</div>
|
|
135
|
+
))}
|
|
136
|
+
</div>
|
|
137
|
+
),
|
|
138
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {cva, type VariantProps} from 'class-variance-authority';
|
|
2
|
+
import type {ComponentProps} from 'react';
|
|
3
|
+
import {cn} from 'utils/cn';
|
|
4
|
+
|
|
5
|
+
export const inputVariants = cva('', {
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
base: 'bg-background-field-base',
|
|
9
|
+
component: 'bg-background-field-component',
|
|
10
|
+
},
|
|
11
|
+
size: {
|
|
12
|
+
base: 'py-6',
|
|
13
|
+
small: 'py-4',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: 'base',
|
|
18
|
+
size: 'base',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
type InputProps = Omit<ComponentProps<'input'>, 'size'> & VariantProps<typeof inputVariants>;
|
|
23
|
+
|
|
24
|
+
export function Input({className, type, variant, size, ...props}: InputProps) {
|
|
25
|
+
return (
|
|
26
|
+
<input
|
|
27
|
+
type={type}
|
|
28
|
+
data-slot="input"
|
|
29
|
+
className={cn(
|
|
30
|
+
'placeholder:text-foreground-neutral-muted w-full min-w-0 rounded-6 px-8 text-sm leading-20 text-foreground-neutral-base shadow-border-base transition-[color,box-shadow] outline-none',
|
|
31
|
+
'hover:bg-background-field-hover',
|
|
32
|
+
'selection:bg-background-accent-neutral-soft selection:text-foreground-neutral-on-inverted',
|
|
33
|
+
'file:text-foreground-neutral-base file:inline-flex file:font-medium',
|
|
34
|
+
'disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-background-neutral-disabled disabled:shadow-none disabled:text-foreground-neutral-disabled',
|
|
35
|
+
'focus-visible:shadow-border-interactive-with-active',
|
|
36
|
+
'aria-invalid:shadow-border-error',
|
|
37
|
+
inputVariants({variant, size}),
|
|
38
|
+
className,
|
|
39
|
+
)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textarea';
|