@soul-refiner/design-system 0.1.10 → 0.1.12
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/package.json +1 -1
- package/src/components/actions/dropdown/dropdown.tsx +1 -1
- package/src/components/actions/toggle/index.ts +1 -0
- package/src/components/actions/toggle/toggle.tsx +75 -0
- package/src/components/actions/upload/upload.tsx +0 -2
- package/src/components/index.ts +1 -0
- package/src/components/input/filter/filter.tsx +305 -0
- package/src/components/input/filter/index.ts +2 -0
- package/src/components/input/index.ts +2 -0
- package/src/components/navigation/index.ts +2 -0
- package/src/components/navigation/tabs/index.ts +2 -0
- package/src/components/navigation/tabs/tabs.tsx +246 -0
package/package.json
CHANGED
|
@@ -134,7 +134,7 @@ const Dropdown = ({
|
|
|
134
134
|
};
|
|
135
135
|
|
|
136
136
|
if (React.isValidElement(child)) {
|
|
137
|
-
// eslint is okay bc deconstruction removes field
|
|
137
|
+
// eslint ignore is okay bc deconstruction removes field
|
|
138
138
|
// eslint-disable-next-line
|
|
139
139
|
const { onClick, ...possibleProps } = child.props;
|
|
140
140
|
props = possibleProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {} from '';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { Box, P } from 'components';
|
|
4
|
+
|
|
5
|
+
export interface ToggleProps {
|
|
6
|
+
checked?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
onChange?: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Toggle = ({ checked, label, onChange }: ToggleProps) => {
|
|
12
|
+
const status =
|
|
13
|
+
checked === undefined ? 'indeterminate' : checked ? 'checked' : 'unchecked';
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Box $align="center" $gap={8}>
|
|
17
|
+
<Wrapper as="label" onClick={onChange}>
|
|
18
|
+
<Input checked={!!checked} onChange={onChange} type="checkbox" />
|
|
19
|
+
<Slider $status={status} />
|
|
20
|
+
</Wrapper>
|
|
21
|
+
{label && <P $fontSize={14}>{label}</P>}
|
|
22
|
+
</Box>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Wrapper = styled.label`
|
|
27
|
+
width: 28px;
|
|
28
|
+
height: 16px;
|
|
29
|
+
position: relative;
|
|
30
|
+
display: inline-block;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const Input = styled.input`
|
|
34
|
+
opacity: 0;
|
|
35
|
+
width: 0;
|
|
36
|
+
height: 0;
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const Slider = styled.span<{
|
|
40
|
+
$status: 'indeterminate' | 'checked' | 'unchecked';
|
|
41
|
+
}>`
|
|
42
|
+
position: absolute;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
top: 0px;
|
|
45
|
+
bottom: 0px;
|
|
46
|
+
right: 0px;
|
|
47
|
+
left: 0px;
|
|
48
|
+
border-radius: 18px;
|
|
49
|
+
${({ $status }) =>
|
|
50
|
+
$status === 'checked'
|
|
51
|
+
? `
|
|
52
|
+
background-color: var(--color-primary-blue-2);
|
|
53
|
+
&:before {
|
|
54
|
+
transform: translateX(12px);
|
|
55
|
+
}`
|
|
56
|
+
: $status === 'unchecked'
|
|
57
|
+
? 'background-color: var(--color-grey-8);'
|
|
58
|
+
: `
|
|
59
|
+
background-color: var(--color-yellow-5);
|
|
60
|
+
&:before {
|
|
61
|
+
transform: translateX(6px);
|
|
62
|
+
}
|
|
63
|
+
`}
|
|
64
|
+
|
|
65
|
+
&:before {
|
|
66
|
+
position: absolute;
|
|
67
|
+
content: '';
|
|
68
|
+
height: 12px;
|
|
69
|
+
width: 12px;
|
|
70
|
+
left: 2px;
|
|
71
|
+
bottom: 2px;
|
|
72
|
+
background-color: var(--color-white);
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
}
|
|
75
|
+
`;
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { BoxProps, P } from 'components';
|
|
4
|
+
import { ChevronDown, ChevronUp } from 'icons';
|
|
5
|
+
import { Styles } from 'common';
|
|
6
|
+
|
|
7
|
+
/********************************************************
|
|
8
|
+
* Filter
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type FilterTriggerTypes = 'outlined' | 'pill' | 'labeled' | 'avatar' | 'text';
|
|
12
|
+
|
|
13
|
+
export interface FilterProps extends React.PropsWithChildren {
|
|
14
|
+
closeOnBlur?: boolean;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
graphic?: React.ReactElement;
|
|
18
|
+
label?: string;
|
|
19
|
+
sx?: string;
|
|
20
|
+
triggerType: FilterTriggerTypes;
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Filter = ({
|
|
25
|
+
closeOnBlur = true,
|
|
26
|
+
children,
|
|
27
|
+
disabled,
|
|
28
|
+
graphic,
|
|
29
|
+
label,
|
|
30
|
+
sx,
|
|
31
|
+
triggerType,
|
|
32
|
+
value,
|
|
33
|
+
}: FilterProps) => {
|
|
34
|
+
const wrapperRef = React.useRef<HTMLDivElement>(null);
|
|
35
|
+
const optionsRef = React.useRef<HTMLDivElement>(null);
|
|
36
|
+
const [open, setOpen] = React.useState(false);
|
|
37
|
+
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (disabled) {
|
|
40
|
+
setOpen(false);
|
|
41
|
+
}
|
|
42
|
+
}, [disabled]);
|
|
43
|
+
|
|
44
|
+
const handleOpen = () => {
|
|
45
|
+
if (disabled) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
setOpen((prev) => !prev);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleBlur = (event: React.FocusEvent) => {
|
|
52
|
+
if (
|
|
53
|
+
closeOnBlur &&
|
|
54
|
+
wrapperRef?.current &&
|
|
55
|
+
!wrapperRef?.current?.contains(event.relatedTarget)
|
|
56
|
+
) {
|
|
57
|
+
setOpen(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Wrapper $sx={sx} tabIndex={0} ref={wrapperRef} onBlurCapture={handleBlur}>
|
|
63
|
+
<FilterTrigger
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
graphic={graphic}
|
|
66
|
+
label={label}
|
|
67
|
+
onClick={handleOpen}
|
|
68
|
+
open={open}
|
|
69
|
+
type={triggerType}
|
|
70
|
+
value={value}
|
|
71
|
+
/>
|
|
72
|
+
{open && <Container ref={optionsRef}>{children}</Container>}
|
|
73
|
+
</Wrapper>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const Wrapper = styled.div<{ $sx?: string }>`
|
|
78
|
+
position: relative;
|
|
79
|
+
display: block;
|
|
80
|
+
outline: none;
|
|
81
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
const Container = styled.div`
|
|
85
|
+
position: absolute;
|
|
86
|
+
width: max-content;
|
|
87
|
+
z-index: 100;
|
|
88
|
+
outline: none;
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
/********************************************************
|
|
92
|
+
* Triggers
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
const textProps: any = {
|
|
96
|
+
as: 'span',
|
|
97
|
+
$fontSize: 14,
|
|
98
|
+
$lineHeight: 20,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const wrapperProps: any = {
|
|
102
|
+
$align: 'center',
|
|
103
|
+
$dir: 'row',
|
|
104
|
+
$gap: 16,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export interface FilterTriggerProps {
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
graphic?: React.ReactElement;
|
|
110
|
+
label?: string;
|
|
111
|
+
onClick?: (event: React.MouseEvent) => void;
|
|
112
|
+
open: boolean;
|
|
113
|
+
type: FilterTriggerTypes;
|
|
114
|
+
value: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const FilterTrigger = ({
|
|
118
|
+
disabled,
|
|
119
|
+
graphic,
|
|
120
|
+
label,
|
|
121
|
+
onClick,
|
|
122
|
+
open,
|
|
123
|
+
type,
|
|
124
|
+
value,
|
|
125
|
+
}: FilterTriggerProps) => {
|
|
126
|
+
if (type === 'pill') {
|
|
127
|
+
return (
|
|
128
|
+
<Pill disabled={disabled} onClick={onClick} {...wrapperProps}>
|
|
129
|
+
{graphic}
|
|
130
|
+
<P {...textProps}>{value}</P>
|
|
131
|
+
{!graphic && (open ? <ChevronUp /> : <ChevronDown />)}
|
|
132
|
+
</Pill>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (type === 'labeled') {
|
|
137
|
+
return (
|
|
138
|
+
<Labeled disabled={disabled} onClick={onClick} {...wrapperProps}>
|
|
139
|
+
<P {...textProps}>{label}</P>
|
|
140
|
+
<LabelSeparator />
|
|
141
|
+
<P $color="primary-blue-2" $mediumBold {...textProps}>
|
|
142
|
+
{value}
|
|
143
|
+
</P>
|
|
144
|
+
{open ? <ChevronUp /> : <ChevronDown />}
|
|
145
|
+
</Labeled>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (type === 'avatar') {
|
|
150
|
+
return (
|
|
151
|
+
<Avatar
|
|
152
|
+
$align="center"
|
|
153
|
+
$dir="row"
|
|
154
|
+
$gap={8}
|
|
155
|
+
disabled={disabled}
|
|
156
|
+
onClick={onClick}
|
|
157
|
+
>
|
|
158
|
+
{graphic}
|
|
159
|
+
{open ? <ChevronUp /> : <ChevronDown />}
|
|
160
|
+
</Avatar>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (type === 'text') {
|
|
165
|
+
return (
|
|
166
|
+
<Text disabled={disabled} onClick={onClick} {...wrapperProps}>
|
|
167
|
+
<P $color="grey-4" $semiBold {...textProps}>
|
|
168
|
+
{label}:
|
|
169
|
+
</P>
|
|
170
|
+
<P
|
|
171
|
+
$color="primary-blue-2"
|
|
172
|
+
$semiBold
|
|
173
|
+
className="filter-trigger-value"
|
|
174
|
+
{...textProps}
|
|
175
|
+
>
|
|
176
|
+
{value}
|
|
177
|
+
</P>
|
|
178
|
+
{open ? <ChevronUp /> : <ChevronDown />}
|
|
179
|
+
</Text>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<Outlined disabled={disabled} onClick={onClick} {...wrapperProps}>
|
|
185
|
+
{graphic}
|
|
186
|
+
<P {...textProps}>{value}</P>
|
|
187
|
+
{!graphic && (open ? <ChevronUp /> : <ChevronDown />)}
|
|
188
|
+
</Outlined>
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
Filter.Trigger = FilterTrigger;
|
|
193
|
+
FilterTrigger.displayName = 'Filter.Trigger';
|
|
194
|
+
|
|
195
|
+
const sharedStyles = css`
|
|
196
|
+
display: flex;
|
|
197
|
+
padding: 10px 16px;
|
|
198
|
+
border: none;
|
|
199
|
+
outline: none;
|
|
200
|
+
cursor: pointer;
|
|
201
|
+
user-select: none;
|
|
202
|
+
|
|
203
|
+
&:disabled {
|
|
204
|
+
background-color: var(--color-grey-9);
|
|
205
|
+
border: 1px solid var(--color-grey-8);
|
|
206
|
+
pointer-events: none;
|
|
207
|
+
|
|
208
|
+
& > * {
|
|
209
|
+
color: var(--color-grey-7);
|
|
210
|
+
fill: var(--color-grey-7);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
|
|
215
|
+
const Outlined = styled.button<BoxProps>`
|
|
216
|
+
${sharedStyles}
|
|
217
|
+
${Styles.flex}
|
|
218
|
+
border: 1px solid var(--color-grey-8);
|
|
219
|
+
border-radius: 8px;
|
|
220
|
+
background-color: var(--color-white);
|
|
221
|
+
|
|
222
|
+
&:hover {
|
|
223
|
+
background-color: var(--color-grey-9);
|
|
224
|
+
}
|
|
225
|
+
`;
|
|
226
|
+
|
|
227
|
+
const Pill = styled.button<BoxProps>`
|
|
228
|
+
${sharedStyles}
|
|
229
|
+
${Styles.flex}
|
|
230
|
+
border-radius: 24px;
|
|
231
|
+
background-color: var(--color-primary-blue-4);
|
|
232
|
+
|
|
233
|
+
& > * {
|
|
234
|
+
color: var(--color-primary-blue-2);
|
|
235
|
+
fill: currentColor;
|
|
236
|
+
|
|
237
|
+
&:hover {
|
|
238
|
+
color: var(--color-primary-blue-1);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
`;
|
|
242
|
+
|
|
243
|
+
const Labeled = styled.button<BoxProps>`
|
|
244
|
+
${sharedStyles}
|
|
245
|
+
${Styles.flex}
|
|
246
|
+
border-radius: 24px;
|
|
247
|
+
border: 1px solid var(--color-grey-8);
|
|
248
|
+
background-color: var(--color-white);
|
|
249
|
+
|
|
250
|
+
&:hover {
|
|
251
|
+
background-color: var(--color-grey-9);
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
const LabelSeparator = styled.div`
|
|
256
|
+
width: 1px;
|
|
257
|
+
height: 20px;
|
|
258
|
+
background-color: var(--color-grey-8);
|
|
259
|
+
`;
|
|
260
|
+
|
|
261
|
+
const Avatar = styled.button<BoxProps>`
|
|
262
|
+
${sharedStyles}
|
|
263
|
+
${Styles.flex}
|
|
264
|
+
padding: 4px 16px;
|
|
265
|
+
border-radius: 32px;
|
|
266
|
+
|
|
267
|
+
&:hover {
|
|
268
|
+
background-color: var(--color-grey-10);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
&:active {
|
|
272
|
+
background-color: var(--color-grey-9);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
&:disabled {
|
|
276
|
+
img {
|
|
277
|
+
opacity: 0.5;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
`;
|
|
281
|
+
|
|
282
|
+
const Text = styled.button<BoxProps>`
|
|
283
|
+
${sharedStyles}
|
|
284
|
+
${Styles.flex}
|
|
285
|
+
gap: 8px;
|
|
286
|
+
background-color: transparent;
|
|
287
|
+
border-radius: 32px;
|
|
288
|
+
|
|
289
|
+
&:hover {
|
|
290
|
+
background-color: var(--color-grey-10);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&:active {
|
|
294
|
+
& > .filter-trigger-value {
|
|
295
|
+
color: var(--color-primary-blue-0);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
&:disabled {
|
|
300
|
+
background-color: transparent;
|
|
301
|
+
border: 1px solid transparent;
|
|
302
|
+
}
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
export { Filter };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { Checkbox } from './checkbox';
|
|
2
2
|
export type { CheckboxProps } from './checkbox';
|
|
3
|
+
export { Filter } from './filter';
|
|
4
|
+
export type { FilterProps, FilterTriggerProps } from './filter';
|
|
3
5
|
export { Radio } from './radio';
|
|
4
6
|
export type { RadioProps } from './radio';
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { P } from 'components';
|
|
4
|
+
|
|
5
|
+
type TabColors =
|
|
6
|
+
| 'blue'
|
|
7
|
+
| 'grey'
|
|
8
|
+
| 'green'
|
|
9
|
+
| 'mint'
|
|
10
|
+
| 'orange'
|
|
11
|
+
| 'ocean'
|
|
12
|
+
| 'pink'
|
|
13
|
+
| 'purple'
|
|
14
|
+
| 'red'
|
|
15
|
+
| 'yellow';
|
|
16
|
+
type TabSizes = 'small' | 'medium' | 'large';
|
|
17
|
+
|
|
18
|
+
const colorLookup: Record<TabColors, Record<'icon' | 'bg', string>> = {
|
|
19
|
+
blue: {
|
|
20
|
+
bg: 'var(--color-hue-blue-2)',
|
|
21
|
+
icon: 'var(--color-hue-blue-1)',
|
|
22
|
+
},
|
|
23
|
+
green: {
|
|
24
|
+
bg: 'var(--color-green-8)',
|
|
25
|
+
icon: 'var(--color-green-2)',
|
|
26
|
+
},
|
|
27
|
+
grey: {
|
|
28
|
+
bg: 'var(--color-grey-9)',
|
|
29
|
+
icon: 'var(--color-grey-7)',
|
|
30
|
+
},
|
|
31
|
+
mint: {
|
|
32
|
+
bg: 'var(--color-hue-mint-2)',
|
|
33
|
+
icon: 'var(--color-hue-mint-1)',
|
|
34
|
+
},
|
|
35
|
+
ocean: {
|
|
36
|
+
bg: 'var(--color-hue-ocean-2)',
|
|
37
|
+
icon: 'var(--color-hue-ocean-1)',
|
|
38
|
+
},
|
|
39
|
+
orange: {
|
|
40
|
+
bg: 'var(--color-hue-orange-2)',
|
|
41
|
+
icon: 'var(--color-hue-orange-1)',
|
|
42
|
+
},
|
|
43
|
+
pink: {
|
|
44
|
+
bg: 'var(--color-hue-pink-2)',
|
|
45
|
+
icon: 'var(--color-hue-pink-1)',
|
|
46
|
+
},
|
|
47
|
+
purple: {
|
|
48
|
+
bg: 'var(--color-hue-purple-2)',
|
|
49
|
+
icon: 'var(--color-hue-purple-1)',
|
|
50
|
+
},
|
|
51
|
+
red: {
|
|
52
|
+
bg: 'var(--color-red-9)',
|
|
53
|
+
icon: 'var(--color-red-3)',
|
|
54
|
+
},
|
|
55
|
+
yellow: {
|
|
56
|
+
bg: 'var(--color-yellow-8)',
|
|
57
|
+
icon: 'var(--color-yellow-3)',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export interface TabProps {
|
|
62
|
+
activeIndex: number;
|
|
63
|
+
items: {
|
|
64
|
+
color?: TabColors;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
icon?: React.ReactElement;
|
|
67
|
+
label: string;
|
|
68
|
+
}[];
|
|
69
|
+
onChange: (index: number) => void;
|
|
70
|
+
size?: TabSizes;
|
|
71
|
+
sx?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const Tabs = ({
|
|
75
|
+
activeIndex,
|
|
76
|
+
items,
|
|
77
|
+
onChange,
|
|
78
|
+
size = 'large',
|
|
79
|
+
sx,
|
|
80
|
+
}: TabProps) => {
|
|
81
|
+
const id = React.useId();
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Wrapper $sx={sx}>
|
|
85
|
+
{items.map((item, index) => (
|
|
86
|
+
<Item
|
|
87
|
+
active={activeIndex === index}
|
|
88
|
+
color={item?.color}
|
|
89
|
+
disabled={item?.disabled}
|
|
90
|
+
key={id + index.toString(36)}
|
|
91
|
+
icon={item?.icon}
|
|
92
|
+
label={item.label}
|
|
93
|
+
onClick={() => onChange(index)}
|
|
94
|
+
size={size}
|
|
95
|
+
/>
|
|
96
|
+
))}
|
|
97
|
+
</Wrapper>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const Wrapper = styled.ul<{
|
|
102
|
+
$sx?: string;
|
|
103
|
+
}>`
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-flow: row nowrap;
|
|
106
|
+
align-items: flex-end;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
gap: 16px;
|
|
109
|
+
margin: 0px;
|
|
110
|
+
padding: 0px;
|
|
111
|
+
|
|
112
|
+
${({ $sx }) => ($sx ? $sx : '')}
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
export interface TabsItemProps {
|
|
116
|
+
active: boolean;
|
|
117
|
+
color?: TabColors;
|
|
118
|
+
disabled?: boolean;
|
|
119
|
+
icon?: React.ReactElement;
|
|
120
|
+
label: string;
|
|
121
|
+
onClick: () => void;
|
|
122
|
+
size: TabSizes;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const Item = ({
|
|
126
|
+
active,
|
|
127
|
+
color,
|
|
128
|
+
disabled,
|
|
129
|
+
icon,
|
|
130
|
+
label,
|
|
131
|
+
onClick,
|
|
132
|
+
size = 'large',
|
|
133
|
+
}: TabsItemProps) => {
|
|
134
|
+
const inputColor = disabled ? 'grey' : color ? color : 'blue';
|
|
135
|
+
const iconColor = colorLookup[inputColor].icon;
|
|
136
|
+
const bgColor = colorLookup[inputColor].bg;
|
|
137
|
+
const fontSize = size === 'large' ? 16 : size === 'medium' ? 14 : 12;
|
|
138
|
+
const lineHeight = size === 'large' ? 24 : size === 'medium' ? 20 : 16;
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Li
|
|
142
|
+
$active={active}
|
|
143
|
+
$color={iconColor}
|
|
144
|
+
$disabled={disabled}
|
|
145
|
+
$hasIcon={!!icon}
|
|
146
|
+
$size={size}
|
|
147
|
+
onClick={!disabled ? onClick : undefined}
|
|
148
|
+
>
|
|
149
|
+
{icon && <IconWrapper $bg={bgColor}>{icon}</IconWrapper>}
|
|
150
|
+
<P $fontSize={fontSize} $lineHeight={lineHeight} $semiBold>
|
|
151
|
+
{label}
|
|
152
|
+
</P>
|
|
153
|
+
</Li>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const Li = styled.li<{
|
|
158
|
+
$active: boolean;
|
|
159
|
+
$color: string;
|
|
160
|
+
$disabled?: boolean;
|
|
161
|
+
$hasIcon: boolean;
|
|
162
|
+
$size: TabSizes;
|
|
163
|
+
}>`
|
|
164
|
+
position: relative;
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: center;
|
|
167
|
+
gap: 8px;
|
|
168
|
+
cursor: pointer;
|
|
169
|
+
user-select: none;
|
|
170
|
+
|
|
171
|
+
${({ $size, $hasIcon }) =>
|
|
172
|
+
$hasIcon
|
|
173
|
+
? 'padding: 16px 12px;'
|
|
174
|
+
: $size === 'small'
|
|
175
|
+
? 'padding: 10px 8px;'
|
|
176
|
+
: $size === 'medium'
|
|
177
|
+
? 'padding: 14px 10px;'
|
|
178
|
+
: 'padding: 22px 12px;'}
|
|
179
|
+
|
|
180
|
+
${({ $hasIcon, $color, $disabled }) =>
|
|
181
|
+
$disabled
|
|
182
|
+
? `
|
|
183
|
+
cursor: initial;
|
|
184
|
+
`
|
|
185
|
+
: $hasIcon
|
|
186
|
+
? `
|
|
187
|
+
&:hover {
|
|
188
|
+
p {
|
|
189
|
+
color: ${$color};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
div > svg {
|
|
194
|
+
fill: ${$color};
|
|
195
|
+
}`
|
|
196
|
+
: `
|
|
197
|
+
&:hover {
|
|
198
|
+
background-color: var(--color-grey-10);
|
|
199
|
+
&:after {
|
|
200
|
+
position: absolute;
|
|
201
|
+
content: '';
|
|
202
|
+
width: 100%;
|
|
203
|
+
height: 3px;
|
|
204
|
+
bottom: 0px;
|
|
205
|
+
left: 0px;
|
|
206
|
+
background-color: var(--color-primary-blue-3);
|
|
207
|
+
border-top-right-radius: 3px;
|
|
208
|
+
border-top-left-radius: 3px;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
&:active {
|
|
212
|
+
background-color: var(--color-grey-9);
|
|
213
|
+
}`}
|
|
214
|
+
|
|
215
|
+
${({ $active, $color, $hasIcon }) =>
|
|
216
|
+
$active
|
|
217
|
+
? `
|
|
218
|
+
&:after {
|
|
219
|
+
position: absolute;
|
|
220
|
+
content: '';
|
|
221
|
+
width: 100%;
|
|
222
|
+
height: 3px;
|
|
223
|
+
bottom: 0px;
|
|
224
|
+
left: 0px;
|
|
225
|
+
background-color: ${
|
|
226
|
+
$hasIcon ? $color : 'var(--color-primary-blue-2)'
|
|
227
|
+
} !important;
|
|
228
|
+
border-top-right-radius: 3px;
|
|
229
|
+
border-top-left-radius: 3px;
|
|
230
|
+
}
|
|
231
|
+
`
|
|
232
|
+
: ''}
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
const IconWrapper = styled.div<{
|
|
236
|
+
$bg: string;
|
|
237
|
+
}>`
|
|
238
|
+
padding: 8px;
|
|
239
|
+
border-radius: 8px;
|
|
240
|
+
background-color: ${({ $bg }) => $bg};
|
|
241
|
+
`;
|
|
242
|
+
|
|
243
|
+
Tabs.Item = Item;
|
|
244
|
+
Item.displayName = 'Tabs.Item';
|
|
245
|
+
|
|
246
|
+
export { Tabs };
|