cherry-styled-components 0.1.0 → 0.1.1
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/.claude/settings.local.json +7 -0
- package/.eslintrc.cjs +18 -0
- package/.prettierrc +11 -0
- package/.supermaven/config.json +1 -0
- package/README.md +33 -11
- package/dist/App.d.ts +2 -0
- package/dist/cherry.js +5174 -0
- package/dist/cherry.umd.cjs +1217 -0
- package/dist/lib/box.d.ts +4 -0
- package/dist/lib/button.d.ts +15 -0
- package/dist/lib/col.d.ts +16 -0
- package/dist/lib/container.d.ts +19 -0
- package/dist/lib/flex.d.ts +29 -0
- package/dist/lib/grid.d.ts +24 -0
- package/dist/lib/index.d.ts +15 -0
- package/dist/lib/input.d.ts +26 -0
- package/dist/lib/max-width.d.ts +14 -0
- package/dist/lib/range.d.ts +13 -0
- package/dist/lib/select.d.ts +15 -0
- package/dist/lib/space.d.ts +14 -0
- package/dist/lib/styled-components/index.d.ts +2 -0
- package/dist/lib/styled-components/registry.d.ts +5 -0
- package/dist/lib/styled-components/theme-provider.d.ts +12 -0
- package/dist/lib/textarea.d.ts +14 -0
- package/dist/lib/toggle.d.ts +14 -0
- package/dist/lib/utils/global.d.ts +3 -0
- package/dist/lib/utils/icons.d.ts +9 -0
- package/dist/lib/utils/index.d.ts +5 -0
- package/dist/lib/utils/mixins.d.ts +11 -0
- package/dist/lib/utils/theme.d.ts +231 -0
- package/dist/lib/utils/typography.d.ts +20 -0
- package/dist/main.d.ts +1 -0
- package/dist/toggle-theme.d.ts +3 -0
- package/index.html +13 -0
- package/package.json +37 -24
- package/pnpm-workspace.yaml +3 -0
- package/src/App.tsx +80 -0
- package/src/lib/box.tsx +26 -0
- package/src/lib/button.tsx +162 -0
- package/src/lib/col.tsx +45 -0
- package/src/lib/container.tsx +59 -0
- package/src/lib/flex.tsx +92 -0
- package/src/lib/grid.tsx +64 -0
- package/src/{app/components/cherry → lib}/index.ts +15 -15
- package/src/lib/input.tsx +384 -0
- package/src/lib/max-width.tsx +50 -0
- package/src/lib/range.tsx +208 -0
- package/src/lib/select.tsx +121 -0
- package/src/lib/space.tsx +52 -0
- package/src/{app/components/cherry → lib}/styled-components/index.ts +2 -2
- package/src/lib/styled-components/registry.tsx +26 -0
- package/src/lib/styled-components/theme-provider.tsx +49 -0
- package/src/lib/textarea.tsx +94 -0
- package/src/lib/toggle.tsx +147 -0
- package/src/{app/components/cherry → lib}/utils/global.tsx +95 -78
- package/src/lib/utils/icons.tsx +84 -0
- package/src/{app/components/cherry → lib}/utils/index.ts +5 -5
- package/src/lib/utils/mixins.tsx +95 -0
- package/src/lib/utils/theme.ts +289 -0
- package/src/lib/utils/typography.tsx +204 -0
- package/src/main.tsx +14 -0
- package/src/toggle-theme.tsx +25 -0
- package/src/vite-env.d.ts +8 -0
- package/tsconfig.json +24 -0
- package/vite.config.js +24 -0
- package/src/app/components/cherry/box.tsx +0 -16
- package/src/app/components/cherry/button.tsx +0 -177
- package/src/app/components/cherry/col.tsx +0 -39
- package/src/app/components/cherry/container.tsx +0 -55
- package/src/app/components/cherry/flex.tsx +0 -90
- package/src/app/components/cherry/grid.tsx +0 -60
- package/src/app/components/cherry/input.tsx +0 -254
- package/src/app/components/cherry/max-width.tsx +0 -43
- package/src/app/components/cherry/range.tsx +0 -223
- package/src/app/components/cherry/select.tsx +0 -122
- package/src/app/components/cherry/space.tsx +0 -54
- package/src/app/components/cherry/styled-components/registry.tsx +0 -26
- package/src/app/components/cherry/styled-components/theme-provider.tsx +0 -21
- package/src/app/components/cherry/textarea.tsx +0 -98
- package/src/app/components/cherry/toggle.tsx +0 -148
- package/src/app/components/cherry/utils/icons.tsx +0 -168
- package/src/app/components/cherry/utils/mixins.tsx +0 -107
- package/src/app/components/cherry/utils/theme.ts +0 -241
- package/src/app/components/cherry/utils/typography.tsx +0 -204
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import type { IStyledComponent } from "styled-components";
|
|
5
|
+
import {
|
|
6
|
+
Theme,
|
|
7
|
+
IconCheck,
|
|
8
|
+
formElementHeightStyles,
|
|
9
|
+
fullWidthStyles,
|
|
10
|
+
resetButton,
|
|
11
|
+
resetInput,
|
|
12
|
+
statusBorderStyles,
|
|
13
|
+
IconCalendar,
|
|
14
|
+
} from "./utils";
|
|
15
|
+
|
|
16
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
$label?: string;
|
|
19
|
+
$size?: "default" | "big";
|
|
20
|
+
$error?: boolean;
|
|
21
|
+
$success?: boolean;
|
|
22
|
+
$fullWidth?: boolean;
|
|
23
|
+
$icon?: React.ReactNode;
|
|
24
|
+
$iconPosition?: "left" | "right";
|
|
25
|
+
theme?: Theme;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface LabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {
|
|
29
|
+
$label?: string;
|
|
30
|
+
$size?: "default" | "big";
|
|
31
|
+
$error?: boolean;
|
|
32
|
+
$success?: boolean;
|
|
33
|
+
$fullWidth?: boolean;
|
|
34
|
+
theme?: Theme;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const StyledInputWrapper: IStyledComponent<"web", React.HTMLAttributes<HTMLSpanElement> & Pick<InputProps, "$label" | "$fullWidth" | "type">> = styled.span<Pick<InputProps, "$label" | "$fullWidth" | "type">>`
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
flex-wrap: ${({ type }) => (type === "checkbox" || type === "radio" ? "nowrap" : "wrap")};
|
|
40
|
+
align-items: center;
|
|
41
|
+
|
|
42
|
+
${({ $label }) =>
|
|
43
|
+
$label &&
|
|
44
|
+
css`
|
|
45
|
+
gap: 10px;
|
|
46
|
+
align-items: flex-start;
|
|
47
|
+
`}
|
|
48
|
+
|
|
49
|
+
& .icon-calendar {
|
|
50
|
+
position: absolute;
|
|
51
|
+
top: 50%;
|
|
52
|
+
right: 17px;
|
|
53
|
+
left: initial;
|
|
54
|
+
transform: translateY(-50%);
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
width: 24px;
|
|
57
|
+
height: 24px;
|
|
58
|
+
|
|
59
|
+
@supports (-moz-appearance: none) {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export const StyledLabel: IStyledComponent<"web", LabelProps> = styled.label<LabelProps>`
|
|
68
|
+
display: inline-block;
|
|
69
|
+
color: ${({ theme }) => theme.colors.grayDark};
|
|
70
|
+
font-size: ${({ theme }) => theme.fontSizes.text.lg};
|
|
71
|
+
line-height: ${({ theme }) => theme.lineHeights.text.lg};
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const StyledInput = styled.input<InputProps>`
|
|
75
|
+
${resetButton};
|
|
76
|
+
${resetInput};
|
|
77
|
+
font-family: inherit;
|
|
78
|
+
display: inline-block;
|
|
79
|
+
padding: 17px 15px;
|
|
80
|
+
border-radius: ${({ theme }) => theme.spacing.radius.xs};
|
|
81
|
+
font-weight: 400;
|
|
82
|
+
white-space: nowrap;
|
|
83
|
+
hyphens: auto;
|
|
84
|
+
color: ${({ theme }) => theme.colors.dark};
|
|
85
|
+
background: ${({ theme }) => theme.colors.light};
|
|
86
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
87
|
+
box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
|
|
88
|
+
transition: all 0.3s ease;
|
|
89
|
+
word-break: keep-all;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
|
|
93
|
+
&[type="date"] {
|
|
94
|
+
padding: 17px 45px 17px 15px;
|
|
95
|
+
|
|
96
|
+
@supports (-moz-appearance: none) {
|
|
97
|
+
padding: 13px 15px;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&::-webkit-datetime-edit {
|
|
102
|
+
padding: 0;
|
|
103
|
+
margin: 0;
|
|
104
|
+
vertical-align: middle;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&::-webkit-datetime-edit-fields-wrapper {
|
|
108
|
+
padding: 4px 0;
|
|
109
|
+
margin: 0;
|
|
110
|
+
vertical-align: middle;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&::-webkit-calendar-picker-indicator {
|
|
114
|
+
background: transparent;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
position: absolute;
|
|
117
|
+
right: 15px;
|
|
118
|
+
top: 50%;
|
|
119
|
+
transform: translateY(-50%);
|
|
120
|
+
width: 24px;
|
|
121
|
+
height: 24px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&::-webkit-datetime-edit-text {
|
|
125
|
+
color: ${({ theme }) => theme.colors.gray};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&::-webkit-datetime-edit-month-field {
|
|
129
|
+
&:focus {
|
|
130
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
131
|
+
color: ${({ theme }) => theme.colors.light};
|
|
132
|
+
border-radius: 4px;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&::-webkit-datetime-edit-day-field {
|
|
137
|
+
&:focus {
|
|
138
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
139
|
+
color: ${({ theme }) => theme.colors.light};
|
|
140
|
+
border-radius: 4px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&::-webkit-datetime-edit-year-field {
|
|
145
|
+
&:focus {
|
|
146
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
147
|
+
color: ${({ theme }) => theme.colors.light};
|
|
148
|
+
border-radius: 4px;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&::placeholder {
|
|
153
|
+
color: ${({ theme }) => theme.colors.gray};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@media (hover: hover) {
|
|
157
|
+
&:hover:not([disabled]) {
|
|
158
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&:focus:not([disabled]) {
|
|
163
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
164
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&:active:not([disabled]) {
|
|
168
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
${({ $size }) => formElementHeightStyles($size)}
|
|
172
|
+
|
|
173
|
+
${({ $size, theme }) =>
|
|
174
|
+
$size === "big"
|
|
175
|
+
? `font-size: ${theme.fontSizes.inputBig.lg};
|
|
176
|
+
line-height: ${theme.lineHeights.inputBig.lg};
|
|
177
|
+
`
|
|
178
|
+
: `font-size: ${theme.fontSizes.input.lg};
|
|
179
|
+
line-height: ${theme.lineHeights.input.lg};`}
|
|
180
|
+
|
|
181
|
+
${({ $error, $success, theme }) => {
|
|
182
|
+
return statusBorderStyles($error ? true : false, $success ? true : false, theme);
|
|
183
|
+
}}
|
|
184
|
+
|
|
185
|
+
${({ disabled, theme }) =>
|
|
186
|
+
disabled &&
|
|
187
|
+
`cursor: not-allowed;
|
|
188
|
+
background: ${theme.colors.grayLight};
|
|
189
|
+
border-color: ${theme.colors.gray};
|
|
190
|
+
color: ${theme.colors.gray};
|
|
191
|
+
`}
|
|
192
|
+
|
|
193
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
const StyledIconWrapper = styled.span<InputProps>`
|
|
197
|
+
display: inline-flex;
|
|
198
|
+
position: relative;
|
|
199
|
+
line-height: 0;
|
|
200
|
+
min-width: fit-content;
|
|
201
|
+
|
|
202
|
+
& em {
|
|
203
|
+
display: block;
|
|
204
|
+
border-radius: 50%;
|
|
205
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
& svg,
|
|
209
|
+
& em {
|
|
210
|
+
object-fit: contain;
|
|
211
|
+
position: absolute;
|
|
212
|
+
top: 50%;
|
|
213
|
+
left: 50%;
|
|
214
|
+
transform: translate(-50%, -50%) scale(0.7);
|
|
215
|
+
opacity: 0;
|
|
216
|
+
pointer-events: none;
|
|
217
|
+
transition: all 0.3s ease;
|
|
218
|
+
}
|
|
219
|
+
`;
|
|
220
|
+
|
|
221
|
+
const StyledRadioCheckboxInput = styled.input<InputProps>`
|
|
222
|
+
${resetButton};
|
|
223
|
+
display: inline-block;
|
|
224
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
225
|
+
box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
|
|
226
|
+
transition: all 0.3s ease;
|
|
227
|
+
|
|
228
|
+
@media (hover: hover) {
|
|
229
|
+
&:hover:not([disabled]) {
|
|
230
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
&:focus:not([disabled]) {
|
|
235
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
236
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&:active:not([disabled]) {
|
|
240
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
${({ type, theme }) =>
|
|
244
|
+
type === "checkbox" ? `border-radius: ${theme.spacing.radius.xs};` : `border-radius: 50%;`}
|
|
245
|
+
|
|
246
|
+
${({ disabled, theme }) =>
|
|
247
|
+
disabled &&
|
|
248
|
+
`cursor: not-allowed;
|
|
249
|
+
background: ${theme.colors.grayLight};
|
|
250
|
+
border: solid 2px ${theme.colors.gray};
|
|
251
|
+
color: ${theme.colors.gray};
|
|
252
|
+
`}
|
|
253
|
+
|
|
254
|
+
${({ $error, $success, theme }) => {
|
|
255
|
+
return statusBorderStyles($error ? true : false, $success ? true : false, theme);
|
|
256
|
+
}}
|
|
257
|
+
|
|
258
|
+
${({ $size }) => {
|
|
259
|
+
if ($size === "big") {
|
|
260
|
+
return `
|
|
261
|
+
min-width: 32px;
|
|
262
|
+
width: 32px;
|
|
263
|
+
min-height: 32px;
|
|
264
|
+
height: 32px;
|
|
265
|
+
|
|
266
|
+
& ~ svg {
|
|
267
|
+
min-width: 18px;
|
|
268
|
+
width: 18px;
|
|
269
|
+
min-height: 18px;
|
|
270
|
+
height: 18px;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
& ~ em {
|
|
274
|
+
min-width: 14px;
|
|
275
|
+
width: 14px;
|
|
276
|
+
min-height: 14px;
|
|
277
|
+
height: 14px;
|
|
278
|
+
}
|
|
279
|
+
`;
|
|
280
|
+
} else {
|
|
281
|
+
return `
|
|
282
|
+
min-width: 22px;
|
|
283
|
+
width: 22px;
|
|
284
|
+
min-height: 22px;
|
|
285
|
+
height: 22px;
|
|
286
|
+
|
|
287
|
+
& ~ svg {
|
|
288
|
+
min-width: 12px;
|
|
289
|
+
width: 12px;
|
|
290
|
+
min-height: 12px;
|
|
291
|
+
height: 12px;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
& ~ em {
|
|
295
|
+
min-width: 8px;
|
|
296
|
+
width: 8px;
|
|
297
|
+
min-height: 8px;
|
|
298
|
+
height: 8px;
|
|
299
|
+
}
|
|
300
|
+
`;
|
|
301
|
+
}
|
|
302
|
+
}}
|
|
303
|
+
|
|
304
|
+
&:checked ~ svg,
|
|
305
|
+
&:checked ~ em {
|
|
306
|
+
opacity: 1;
|
|
307
|
+
transform: translate(-50%, -50%) scale(1);
|
|
308
|
+
}
|
|
309
|
+
`;
|
|
310
|
+
|
|
311
|
+
const StyledCustomIconWrapper = styled.span<InputProps>`
|
|
312
|
+
position: relative;
|
|
313
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)};
|
|
314
|
+
|
|
315
|
+
& svg {
|
|
316
|
+
position: absolute;
|
|
317
|
+
top: 50%;
|
|
318
|
+
transform: translateY(-50%);
|
|
319
|
+
pointer-events: none;
|
|
320
|
+
width: 24px;
|
|
321
|
+
height: 24px;
|
|
322
|
+
object-fit: contain;
|
|
323
|
+
color: ${({ theme }) => theme.colors.primary};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
${({ $icon, $iconPosition }) =>
|
|
327
|
+
$icon && $iconPosition === "right"
|
|
328
|
+
? css`
|
|
329
|
+
& svg {
|
|
330
|
+
right: 16px;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
& input {
|
|
334
|
+
padding-right: 50px;
|
|
335
|
+
}
|
|
336
|
+
`
|
|
337
|
+
: css`
|
|
338
|
+
& svg {
|
|
339
|
+
left: 16px;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
& svg ~ input {
|
|
343
|
+
padding-left: 50px;
|
|
344
|
+
}
|
|
345
|
+
`}
|
|
346
|
+
`;
|
|
347
|
+
|
|
348
|
+
function LocalInput({ ...props }: InputProps, ref: React.Ref<HTMLInputElement>) {
|
|
349
|
+
if (props.type === "checkbox" || props.type === "radio") {
|
|
350
|
+
return (
|
|
351
|
+
<StyledInputWrapper $fullWidth={props.$fullWidth} type={props.type} $label={props.$label}>
|
|
352
|
+
<StyledIconWrapper>
|
|
353
|
+
<StyledRadioCheckboxInput {...props} ref={ref} />
|
|
354
|
+
{!props.disabled && props.type === "checkbox" ? <IconCheck /> : <em />}
|
|
355
|
+
</StyledIconWrapper>
|
|
356
|
+
{props.$label && (
|
|
357
|
+
<StyledLabel htmlFor={props.id}>
|
|
358
|
+
{props.$label}
|
|
359
|
+
</StyledLabel>
|
|
360
|
+
)}
|
|
361
|
+
</StyledInputWrapper>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<StyledInputWrapper $fullWidth={props.$fullWidth} type={props.type} $label={props.$label}>
|
|
367
|
+
{props.$label && <StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>}
|
|
368
|
+
<StyledCustomIconWrapper
|
|
369
|
+
$fullWidth={props.$fullWidth}
|
|
370
|
+
$iconPosition={props.$iconPosition}
|
|
371
|
+
$icon={props.$icon}
|
|
372
|
+
>
|
|
373
|
+
{props.$iconPosition !== "right" && props.$icon && props.$icon}
|
|
374
|
+
<StyledInput {...props} ref={ref} />
|
|
375
|
+
{props.$iconPosition === "right" && props.$icon && props.$icon}
|
|
376
|
+
{props.type === "date" && <IconCalendar className="icon-calendar" />}
|
|
377
|
+
</StyledCustomIconWrapper>
|
|
378
|
+
</StyledInputWrapper>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const Input = forwardRef(LocalInput);
|
|
383
|
+
|
|
384
|
+
export { Input };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Breakpoints, mq } from "./utils";
|
|
5
|
+
|
|
6
|
+
interface MaxWidthProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
$size?: number;
|
|
8
|
+
$xs?: number;
|
|
9
|
+
$sm?: number;
|
|
10
|
+
$md?: number;
|
|
11
|
+
$lg?: number;
|
|
12
|
+
$xl?: number;
|
|
13
|
+
$xxl?: number;
|
|
14
|
+
$xxxl?: number;
|
|
15
|
+
$m0?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const styles = ($size: number | "none") => `max-width: ${$size}px;`;
|
|
19
|
+
|
|
20
|
+
function responsiveStyles(props: any) {
|
|
21
|
+
return Object.keys(props)
|
|
22
|
+
.filter((key) => key.startsWith("$"))
|
|
23
|
+
.map((key) => {
|
|
24
|
+
const size = key.substring(1) as keyof Breakpoints<number>;
|
|
25
|
+
return props[key] && mq(size) + `{ ${styles(props[key])} }`;
|
|
26
|
+
})
|
|
27
|
+
.join("");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const StyledMaxWidth = styled.div<MaxWidthProps>`
|
|
31
|
+
display: block;
|
|
32
|
+
margin: ${({ $m0 }) => ($m0 ? "0" : "auto")};
|
|
33
|
+
|
|
34
|
+
${({ $size }) => `
|
|
35
|
+
${$size && styles($size)};
|
|
36
|
+
`}
|
|
37
|
+
${(props) => responsiveStyles(props)}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
function LocalMaxWidth({ ...props }: MaxWidthProps, ref: React.Ref<HTMLDivElement>) {
|
|
41
|
+
return (
|
|
42
|
+
<StyledMaxWidth {...props} ref={ref}>
|
|
43
|
+
{props.children}
|
|
44
|
+
</StyledMaxWidth>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const MaxWidth = forwardRef(LocalMaxWidth);
|
|
49
|
+
|
|
50
|
+
export { MaxWidth };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Theme, fullWidthStyles, resetButton, statusBorderStyles } from "./utils";
|
|
5
|
+
import { StyledLabel } from "./input";
|
|
6
|
+
|
|
7
|
+
interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
8
|
+
className?: string;
|
|
9
|
+
$label?: string;
|
|
10
|
+
$size?: "default" | "big";
|
|
11
|
+
$error?: boolean;
|
|
12
|
+
$success?: boolean;
|
|
13
|
+
$fullWidth?: boolean;
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const StyledInputWrapper = styled.span<InputProps>`
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
flex-wrap: ${({ type }) => (type === "checkbox" || type === "radio" ? "fprnowrap" : "wrap")};
|
|
20
|
+
gap: 10px;
|
|
21
|
+
align-items: center;
|
|
22
|
+
|
|
23
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
const StyledInput = styled.input<InputProps>`
|
|
27
|
+
${resetButton};
|
|
28
|
+
padding: 0;
|
|
29
|
+
height: 10px;
|
|
30
|
+
font-size: 0;
|
|
31
|
+
background: transparent;
|
|
32
|
+
min-width: 100px;
|
|
33
|
+
|
|
34
|
+
&::-webkit-slider-runnable-track {
|
|
35
|
+
width: 100%;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
border-radius: ${({ theme }) => theme.spacing.radius.xl};
|
|
38
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
39
|
+
box-shadow: 0 0 0 0 ${({ theme }) => theme.colors.primaryLight};
|
|
40
|
+
transition: all 0.3s ease;
|
|
41
|
+
${({ $error, $success, theme }) => {
|
|
42
|
+
return statusBorderStyles($error ? true : false, $success ? true : false, theme);
|
|
43
|
+
}}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&::-moz-range-track {
|
|
47
|
+
width: 100%;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
border-radius: ${({ theme }) => theme.spacing.radius.xl};
|
|
50
|
+
border: solid 2px ${({ theme }) => theme.colors.grayLight};
|
|
51
|
+
box-shadow: 0 0 0 0 ${({ theme }) => theme.colors.primaryLight};
|
|
52
|
+
transition: all 0.3s ease;
|
|
53
|
+
${({ $error, $success, theme }) => {
|
|
54
|
+
return statusBorderStyles($error ? true : false, $success ? true : false, theme);
|
|
55
|
+
}}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&::-webkit-slider-thumb {
|
|
59
|
+
${resetButton};
|
|
60
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
61
|
+
border: 0 solid transparent;
|
|
62
|
+
border-radius: 50%;
|
|
63
|
+
transition: all 0.3s ease;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&::-moz-range-thumb {
|
|
67
|
+
${resetButton};
|
|
68
|
+
background: ${({ theme }) => theme.colors.primary};
|
|
69
|
+
border: 0 solid transparent;
|
|
70
|
+
border-radius: 50%;
|
|
71
|
+
transition: all 0.3s ease;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@media (hover: hover) {
|
|
75
|
+
&:hover:not([disabled]) {
|
|
76
|
+
&::-webkit-slider-runnable-track {
|
|
77
|
+
border: solid 2px ${({ theme }) => theme.colors.primary};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&::-moz-range-track {
|
|
81
|
+
border: solid 2px ${({ theme }) => theme.colors.primary};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:focus:not([disabled]) {
|
|
87
|
+
&::-webkit-slider-runnable-track {
|
|
88
|
+
border: solid 2px ${({ theme }) => theme.colors.primary};
|
|
89
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
90
|
+
}
|
|
91
|
+
&::-webkit-slider-thumb {
|
|
92
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
93
|
+
}
|
|
94
|
+
&::-moz-range-track {
|
|
95
|
+
border: solid 2px ${({ theme }) => theme.colors.primary};
|
|
96
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
97
|
+
}
|
|
98
|
+
&::-moz-range-thumb {
|
|
99
|
+
box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&:active:not([disabled]) {
|
|
104
|
+
&::-webkit-slider-runnable-track {
|
|
105
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
106
|
+
}
|
|
107
|
+
&::-webkit-slider-thumb {
|
|
108
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
109
|
+
}
|
|
110
|
+
&::-moz-range-track {
|
|
111
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
112
|
+
}
|
|
113
|
+
&::-moz-range-thumb {
|
|
114
|
+
box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
${({ disabled, theme }) =>
|
|
119
|
+
disabled &&
|
|
120
|
+
`
|
|
121
|
+
cursor: not-allowed;
|
|
122
|
+
|
|
123
|
+
&::-webkit-slider-runnable-track {
|
|
124
|
+
background: ${theme.colors.grayLight};
|
|
125
|
+
cursor: not-allowed;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
&::-moz-range-track {
|
|
129
|
+
background: ${theme.colors.grayLight};
|
|
130
|
+
cursor: not-allowed;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&::-webkit-slider-thumb {
|
|
134
|
+
background: ${theme.colors.gray};
|
|
135
|
+
cursor: not-allowed;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&::-moz-range-thumb {
|
|
139
|
+
background: ${theme.colors.gray};
|
|
140
|
+
cursor: not-allowed;
|
|
141
|
+
}
|
|
142
|
+
`}
|
|
143
|
+
|
|
144
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
145
|
+
|
|
146
|
+
${({ $size }) => {
|
|
147
|
+
if ($size === "big") {
|
|
148
|
+
return `
|
|
149
|
+
height: 32px;
|
|
150
|
+
|
|
151
|
+
&::-webkit-slider-runnable-track {
|
|
152
|
+
height: 14px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&::-moz-range-track {
|
|
156
|
+
height: 10px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&::-webkit-slider-thumb {
|
|
160
|
+
width: 32px;
|
|
161
|
+
height: 32px;
|
|
162
|
+
margin-top: -11px;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&::-moz-range-thumb {
|
|
166
|
+
width: 32px;
|
|
167
|
+
height: 32px;
|
|
168
|
+
}
|
|
169
|
+
`;
|
|
170
|
+
} else {
|
|
171
|
+
return `
|
|
172
|
+
height: 22px;
|
|
173
|
+
|
|
174
|
+
&::-webkit-slider-runnable-track {
|
|
175
|
+
height: 10px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
&::-moz-range-track {
|
|
179
|
+
height: 6px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&::-webkit-slider-thumb {
|
|
183
|
+
width: 22px;
|
|
184
|
+
height: 22px;
|
|
185
|
+
margin-top: -8px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&::-moz-range-thumb {
|
|
189
|
+
width: 22px;
|
|
190
|
+
height: 22px;
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
}}
|
|
195
|
+
`;
|
|
196
|
+
|
|
197
|
+
function LocalRange({ ...props }: InputProps, ref: React.Ref<HTMLInputElement>) {
|
|
198
|
+
return (
|
|
199
|
+
<StyledInputWrapper $fullWidth={props.$fullWidth}>
|
|
200
|
+
{props.$label && <StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>}
|
|
201
|
+
<StyledInput {...props} type="range" ref={ref} />
|
|
202
|
+
</StyledInputWrapper>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const Range = forwardRef(LocalRange);
|
|
207
|
+
|
|
208
|
+
export { Range };
|