@liguelead/design-system 0.0.6 → 0.0.8
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/components/Button/Button.styles.ts +3 -3
- package/components/Button/Button.tsx +62 -56
- package/components/Button/Button.types.ts +2 -1
- package/components/Checkbox/Checkbox.styles.ts +66 -0
- package/components/Checkbox/Checkbox.tsx +40 -0
- package/components/Checkbox/Checkbox.types.ts +11 -0
- package/components/Checkbox/index.tsx +2 -0
- package/components/DatePicker/DatePicker.styles.ts +66 -0
- package/components/DatePicker/DatePicker.tsx +135 -0
- package/components/DatePicker/DatePicker.types.ts +29 -0
- package/components/DatePicker/index.ts +1 -0
- package/components/IconButton/IconButton.tsx +53 -50
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -0
- package/components/SegmentedButton/SegmentedButton.tsx +49 -0
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -0
- package/components/SegmentedButton/index.ts +1 -0
- package/components/Select/Select.sizes.ts +56 -0
- package/components/Select/Select.states.tsx +69 -0
- package/components/Select/Select.styles.ts +148 -0
- package/components/Select/Select.tsx +144 -0
- package/components/Select/Select.types.ts +36 -0
- package/components/Select/index.ts +1 -0
- package/components/Text/Text.styles.ts +5 -5
- package/components/Text/Text.tsx +4 -42
- package/components/Text/Text.types.ts +42 -0
- package/components/TextField/TextField.tsx +7 -2
- package/components/TextField/TextField.types.ts +2 -1
- package/components/ThemeProvider/ThemeProvider.tsx +11 -20
- package/components/ThemeProvider/style.ts +781 -12
- package/components/index.ts +4 -0
- package/package.json +6 -3
- package/scripts/createTypes.js +32 -2
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SegmentedButtonProps } from './SegmentedButton.types'
|
|
2
|
+
import {
|
|
3
|
+
LeftButton,
|
|
4
|
+
RightButton,
|
|
5
|
+
WrapperSegmentedButton
|
|
6
|
+
} from './SegmentedButton.styles'
|
|
7
|
+
import { useState } from 'react'
|
|
8
|
+
|
|
9
|
+
const SegmentedButton: React.FC<SegmentedButtonProps> = ({
|
|
10
|
+
options,
|
|
11
|
+
disabled = false,
|
|
12
|
+
color = 'primary',
|
|
13
|
+
size = 'md',
|
|
14
|
+
...rest
|
|
15
|
+
}) => {
|
|
16
|
+
const { leftButton, rightButton } = options
|
|
17
|
+
const [selected, setSelected] = useState<string>('left')
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<WrapperSegmentedButton {...rest}>
|
|
21
|
+
<LeftButton
|
|
22
|
+
color={color}
|
|
23
|
+
disabled={disabled}
|
|
24
|
+
appearance={selected === 'left' ? 'solid' : 'outline'}
|
|
25
|
+
size={size}
|
|
26
|
+
onClick={() => {
|
|
27
|
+
setSelected('left')
|
|
28
|
+
leftButton.action?.()
|
|
29
|
+
}}
|
|
30
|
+
type="button">
|
|
31
|
+
{leftButton.label}
|
|
32
|
+
</LeftButton>
|
|
33
|
+
<RightButton
|
|
34
|
+
color={color}
|
|
35
|
+
appearance={selected === 'right' ? 'solid' : 'outline'}
|
|
36
|
+
disabled={disabled}
|
|
37
|
+
onClick={() => {
|
|
38
|
+
setSelected('right')
|
|
39
|
+
rightButton.action?.()
|
|
40
|
+
}}
|
|
41
|
+
size={size}
|
|
42
|
+
type="button">
|
|
43
|
+
{rightButton.label}
|
|
44
|
+
</RightButton>
|
|
45
|
+
</WrapperSegmentedButton>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default SegmentedButton
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { colorType } from 'types'
|
|
2
|
+
type SegmentedButtonType = {
|
|
3
|
+
label: string
|
|
4
|
+
action?: () => void
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface SegmentedButtons {
|
|
8
|
+
leftButton: SegmentedButtonType
|
|
9
|
+
rightButton: SegmentedButtonType
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface SegmentedButtonProps {
|
|
13
|
+
className?: string
|
|
14
|
+
options: SegmentedButtons
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
color?: colorType
|
|
17
|
+
size?: SegmentedButtonSizeTypes
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SegmentedButtonSizeTypes = 'sm' | 'md' | 'lg'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SegmentedButton'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { fontSize, lineHeight, spacing } from '@liguelead/foundation'
|
|
2
|
+
import { TextFieldSize } from './Select.types'
|
|
3
|
+
|
|
4
|
+
export const textFieldSizes = (
|
|
5
|
+
size: TextFieldSize,
|
|
6
|
+
leftIcon: boolean,
|
|
7
|
+
rightIcon: boolean
|
|
8
|
+
) => {
|
|
9
|
+
const withIconMargin = Number(spacing.spacing8) + 20
|
|
10
|
+
const withIconPadding = {
|
|
11
|
+
sm: Number(spacing.spacing12) + Number(withIconMargin),
|
|
12
|
+
md: Number(spacing.spacing16) + Number(withIconMargin),
|
|
13
|
+
lg: Number(spacing.spacing16) + Number(withIconMargin)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const sizes = {
|
|
17
|
+
sm: {
|
|
18
|
+
input: `
|
|
19
|
+
font-size: ${fontSize.fontSize14}px;
|
|
20
|
+
line-height: ${lineHeight.lineHeight22}px;
|
|
21
|
+
padding: ${spacing.spacing8}px ${spacing.spacing12}px;
|
|
22
|
+
padding-left: ${leftIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
23
|
+
padding-right: ${rightIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
24
|
+
`,
|
|
25
|
+
label: `font-size: ${fontSize.fontSize14}px;
|
|
26
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
27
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
28
|
+
},
|
|
29
|
+
md: {
|
|
30
|
+
input: `
|
|
31
|
+
font-size: ${fontSize.fontSize14}px;
|
|
32
|
+
line-height: ${lineHeight.lineHeight20}px;
|
|
33
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
34
|
+
padding-left: ${leftIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
35
|
+
padding-right: ${rightIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
36
|
+
`,
|
|
37
|
+
label: `font-size: ${fontSize.fontSize14}px;
|
|
38
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
39
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
40
|
+
},
|
|
41
|
+
lg: {
|
|
42
|
+
input: `
|
|
43
|
+
font-size: ${fontSize.fontSize16}px;
|
|
44
|
+
line-height: ${lineHeight.lineHeight24}px;
|
|
45
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
46
|
+
padding-left: ${leftIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
47
|
+
padding-right: ${rightIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
48
|
+
`,
|
|
49
|
+
label: `font-size: ${fontSize.fontSize16}px;
|
|
50
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
51
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return sizes[size]
|
|
56
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { parseColor } from '../../utils'
|
|
2
|
+
import { useTheme } from 'styled-components'
|
|
3
|
+
import { fontWeight, fontSize } from '@liguelead/foundation'
|
|
4
|
+
import { TextFieldStates } from './Select.types'
|
|
5
|
+
|
|
6
|
+
export const SelectStates = (state: keyof TextFieldStates) => {
|
|
7
|
+
const theme = useTheme()
|
|
8
|
+
const states: TextFieldStates = {
|
|
9
|
+
error: {
|
|
10
|
+
input: `
|
|
11
|
+
border: 1px solid ${parseColor(theme.colors.danger100)};
|
|
12
|
+
color: ${parseColor(theme.colors.neutral1000)};
|
|
13
|
+
&:focus {
|
|
14
|
+
border-color: ${parseColor(theme.colors.danger100)};
|
|
15
|
+
}
|
|
16
|
+
&:focus + label {
|
|
17
|
+
color: ${parseColor(theme.colors.danger100)};
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
label: `color: ${parseColor(theme.colors.danger100)};`,
|
|
21
|
+
helperText: `color: ${parseColor(theme.colors.danger100)};`,
|
|
22
|
+
animation: `
|
|
23
|
+
&:focus div + label,
|
|
24
|
+
&:not(:placeholder-shown) + label {
|
|
25
|
+
top: 0px;
|
|
26
|
+
left: 12px;
|
|
27
|
+
font-size: ${fontSize.fontSize12}px;
|
|
28
|
+
}`
|
|
29
|
+
},
|
|
30
|
+
default: {
|
|
31
|
+
input: `
|
|
32
|
+
border: 1px solid ${parseColor(theme.colors.neutral700)};
|
|
33
|
+
color: ${parseColor(theme.colors.neutral1000)};
|
|
34
|
+
|
|
35
|
+
&:focus {
|
|
36
|
+
border-color: ${parseColor(theme.colors.primary)};
|
|
37
|
+
}
|
|
38
|
+
&:focus label,
|
|
39
|
+
&:focus-within label {
|
|
40
|
+
color: ${parseColor(theme.colors.primary)} !important;
|
|
41
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
42
|
+
.select-label {
|
|
43
|
+
color: ${parseColor(theme.colors.primary)};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
label: `color: ${parseColor(theme.colors.neutral800)};`,
|
|
48
|
+
helperText: `color: ${parseColor(theme.colors.neutral700)};`,
|
|
49
|
+
animation: `
|
|
50
|
+
&:focus + label,
|
|
51
|
+
&:not(:placeholder-shown) + label {
|
|
52
|
+
top: 0px;
|
|
53
|
+
left: 12px;
|
|
54
|
+
font-size: ${fontSize.fontSize12}px;
|
|
55
|
+
}`
|
|
56
|
+
},
|
|
57
|
+
disabled: {
|
|
58
|
+
input: `
|
|
59
|
+
border: 2px solid ${parseColor(theme.colors.neutral500)};
|
|
60
|
+
color: ${parseColor(theme.colors.neutral600)};
|
|
61
|
+
`,
|
|
62
|
+
label: `color: ${parseColor(theme.colors.neutral500)};
|
|
63
|
+
background: transparent;`,
|
|
64
|
+
helperText: `color: ${parseColor(theme.colors.neutral500)};`,
|
|
65
|
+
animation: ``
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return states[state]
|
|
69
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { TextFieldSizeType, StateInterface } from './Select.types'
|
|
3
|
+
import {
|
|
4
|
+
fontSize,
|
|
5
|
+
fontWeight,
|
|
6
|
+
lineHeight,
|
|
7
|
+
spacing
|
|
8
|
+
} from '@liguelead/foundation'
|
|
9
|
+
import { parseColor } from '../../utils'
|
|
10
|
+
import { Content, Item } from '@radix-ui/react-select'
|
|
11
|
+
|
|
12
|
+
interface StyledInputProps {
|
|
13
|
+
size: TextFieldSizeType
|
|
14
|
+
$themefication: StateInterface
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const InputWrapper = styled.div`
|
|
18
|
+
position: relative;
|
|
19
|
+
width: 100%;
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
export const FloatingLabel = styled.label`
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 50%;
|
|
25
|
+
left: 12px;
|
|
26
|
+
transform: translateY(-50%);
|
|
27
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
28
|
+
transition: all 0.2s ease;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
background-color: white;
|
|
31
|
+
padding: 0 4px;
|
|
32
|
+
&.is-open {
|
|
33
|
+
color: ${({ theme }) => parseColor(theme.colors.primary)} !important;
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
|
|
37
|
+
export const HelperText = styled.span<{ error?: boolean }>`
|
|
38
|
+
font-size: ${fontSize.fontSize12}px;
|
|
39
|
+
line-height: ${lineHeight.lineHeight12}px;
|
|
40
|
+
padding-left: ${spacing.spacing16}px;
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
export const IconWrapper = styled.div<{ $right?: boolean; $error?: boolean }>`
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 0px;
|
|
49
|
+
height: 100%;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
${({ $right }) => ($right ? 'right: 0px;' : 'left: 0px;')}
|
|
52
|
+
padding: 0px ${spacing.spacing16}px;
|
|
53
|
+
|
|
54
|
+
& svg {
|
|
55
|
+
width: 20px;
|
|
56
|
+
height: 20px;
|
|
57
|
+
fill: ${({ theme, $error }) =>
|
|
58
|
+
$error
|
|
59
|
+
? parseColor(theme.colors.danger100)
|
|
60
|
+
: parseColor(theme.colors.neutral700)};
|
|
61
|
+
transition: fill 0.2s ease;
|
|
62
|
+
}
|
|
63
|
+
`
|
|
64
|
+
|
|
65
|
+
export const StyledContent = styled(Content)`
|
|
66
|
+
padding: 0px;
|
|
67
|
+
background-color: #fff;
|
|
68
|
+
min-width: var(--radix-select-trigger-width, auto);
|
|
69
|
+
width: 100%;
|
|
70
|
+
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
|
|
71
|
+
border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral500)};
|
|
72
|
+
border-top: 0px;
|
|
73
|
+
max-height: var(--radix-select-content-height, 314px);
|
|
74
|
+
overflow-y: scroll !important;
|
|
75
|
+
z-index: 10;
|
|
76
|
+
& .RadixSelectViewport {
|
|
77
|
+
max-height: 200px; /* Limite de altura do dropdown */
|
|
78
|
+
overflow-y: auto; /* Adiciona o scroll quando necessário */
|
|
79
|
+
scrollbar-width: thin; /* Personaliza a largura do scroll (opcional) */
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
export const StyledItem = styled(Item)`
|
|
84
|
+
padding: ${spacing.spacing12}px ${spacing.spacing20}px;
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: 8px;
|
|
88
|
+
transition: all 0.2s ease;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
&:hover {
|
|
91
|
+
background-color: ${({ theme }) => parseColor(theme.colors.neutral200)};
|
|
92
|
+
}
|
|
93
|
+
&[data-state='checked'] {
|
|
94
|
+
background-color: ${({ theme }) =>
|
|
95
|
+
parseColor(theme.colors.primaryLight)};
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
|
|
99
|
+
export const StyledInput = styled.input.withConfig({
|
|
100
|
+
shouldForwardProp: prop => !['control', 'errors', 'rules'].includes(prop)
|
|
101
|
+
})`
|
|
102
|
+
width: 100%;
|
|
103
|
+
border-radius: 4px;
|
|
104
|
+
outline: none;
|
|
105
|
+
transition: border-color 0.2s ease;
|
|
106
|
+
background: transparent;
|
|
107
|
+
&.is-open {
|
|
108
|
+
border-color: ${({ theme }) =>
|
|
109
|
+
parseColor(theme.colors.primary)} !important;
|
|
110
|
+
}
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
export const BorderWrapper = styled.div`
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 0;
|
|
116
|
+
left: 0;
|
|
117
|
+
right: 0;
|
|
118
|
+
bottom: 0;
|
|
119
|
+
pointer-events: none;
|
|
120
|
+
border: 2px solid #ccc;
|
|
121
|
+
border-radius: 4px;
|
|
122
|
+
background-color: transparent;
|
|
123
|
+
z-index: -1;
|
|
124
|
+
|
|
125
|
+
${StyledInput}:focus ~ & {
|
|
126
|
+
border-color: ${({ theme }) => theme.colors.primary};
|
|
127
|
+
}
|
|
128
|
+
`
|
|
129
|
+
|
|
130
|
+
export const Wrapper = styled.div<StyledInputProps>`
|
|
131
|
+
position: relative;
|
|
132
|
+
width: 100%;
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
${({ $themefication, size }) => `
|
|
135
|
+
${StyledInput} {
|
|
136
|
+
${$themefication.animation}
|
|
137
|
+
${$themefication.input}
|
|
138
|
+
${size.input}
|
|
139
|
+
}
|
|
140
|
+
${FloatingLabel} {
|
|
141
|
+
${$themefication.label}
|
|
142
|
+
${size.label}
|
|
143
|
+
}
|
|
144
|
+
${HelperText} {
|
|
145
|
+
${$themefication.label}
|
|
146
|
+
}
|
|
147
|
+
`}
|
|
148
|
+
`
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { forwardRef, useState } from 'react'
|
|
2
|
+
import * as RadixSelect from '@radix-ui/react-select'
|
|
3
|
+
import { CaretDown, Plus } from '@phosphor-icons/react'
|
|
4
|
+
import {
|
|
5
|
+
FloatingLabel,
|
|
6
|
+
HelperText,
|
|
7
|
+
IconWrapper,
|
|
8
|
+
InputWrapper,
|
|
9
|
+
StyledContent,
|
|
10
|
+
StyledInput,
|
|
11
|
+
StyledItem,
|
|
12
|
+
Wrapper
|
|
13
|
+
} from './Select.styles'
|
|
14
|
+
import { SelectStates } from './Select.states'
|
|
15
|
+
import { textFieldSizes } from './Select.sizes'
|
|
16
|
+
import TextField, { getState } from '../TextField/TextField'
|
|
17
|
+
import { SelectProps, StateInterface } from './Select.types'
|
|
18
|
+
|
|
19
|
+
const Select = forwardRef<HTMLInputElement, SelectProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
label,
|
|
23
|
+
defaultValue,
|
|
24
|
+
error,
|
|
25
|
+
helperText,
|
|
26
|
+
leftIcon,
|
|
27
|
+
size = 'md',
|
|
28
|
+
options,
|
|
29
|
+
className,
|
|
30
|
+
disabled = false,
|
|
31
|
+
handleLeftIcon,
|
|
32
|
+
register
|
|
33
|
+
},
|
|
34
|
+
ref
|
|
35
|
+
) => {
|
|
36
|
+
const [selectValue, setSelectValue] = useState(
|
|
37
|
+
defaultValue ?? options[0]?.value
|
|
38
|
+
)
|
|
39
|
+
const [open, setOpen] = useState(false)
|
|
40
|
+
|
|
41
|
+
const handleOnChange = (value: string) => {
|
|
42
|
+
if (value) {
|
|
43
|
+
setSelectValue(value)
|
|
44
|
+
register?.onChange({
|
|
45
|
+
target: {
|
|
46
|
+
name: register.name,
|
|
47
|
+
value
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const state = getState(disabled, !!error)
|
|
54
|
+
const textFieldState: StateInterface = SelectStates(state)
|
|
55
|
+
const textFieldSize = textFieldSizes(size, !!leftIcon, false)
|
|
56
|
+
const selectedLabel =
|
|
57
|
+
options.find(option => option.value === selectValue)?.label ?? ''
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Wrapper
|
|
61
|
+
className={className}
|
|
62
|
+
size={textFieldSize}
|
|
63
|
+
$themefication={textFieldState}>
|
|
64
|
+
<input
|
|
65
|
+
type="hidden"
|
|
66
|
+
value={selectValue}
|
|
67
|
+
ref={instance => {
|
|
68
|
+
if (typeof ref === 'function') {
|
|
69
|
+
ref(instance)
|
|
70
|
+
} else if (ref) {
|
|
71
|
+
ref.current = instance
|
|
72
|
+
}
|
|
73
|
+
register?.ref(instance)
|
|
74
|
+
}}
|
|
75
|
+
onChange={register?.onChange}
|
|
76
|
+
onBlur={register?.onBlur}
|
|
77
|
+
/>
|
|
78
|
+
{!disabled ? (
|
|
79
|
+
<RadixSelect.Root
|
|
80
|
+
value={selectValue}
|
|
81
|
+
onOpenChange={open => setOpen(open)}
|
|
82
|
+
defaultValue={defaultValue}
|
|
83
|
+
onValueChange={(value: string) =>
|
|
84
|
+
handleOnChange(value)
|
|
85
|
+
}>
|
|
86
|
+
<RadixSelect.Trigger asChild>
|
|
87
|
+
<InputWrapper>
|
|
88
|
+
{leftIcon && (
|
|
89
|
+
<IconWrapper onClick={handleLeftIcon}>
|
|
90
|
+
{leftIcon}
|
|
91
|
+
</IconWrapper>
|
|
92
|
+
)}
|
|
93
|
+
<IconWrapper $right $error={!!error}>
|
|
94
|
+
<CaretDown weight="fill" size={14} />
|
|
95
|
+
</IconWrapper>
|
|
96
|
+
<StyledInput
|
|
97
|
+
readOnly
|
|
98
|
+
style={{ cursor: 'pointer !important' }}
|
|
99
|
+
value={selectedLabel}
|
|
100
|
+
placeholder=" "
|
|
101
|
+
className={open ? 'is-open' : ''}
|
|
102
|
+
/>
|
|
103
|
+
<FloatingLabel
|
|
104
|
+
className={open ? 'is-open' : ''}>
|
|
105
|
+
{label}
|
|
106
|
+
</FloatingLabel>
|
|
107
|
+
</InputWrapper>
|
|
108
|
+
</RadixSelect.Trigger>
|
|
109
|
+
<StyledContent
|
|
110
|
+
asChild
|
|
111
|
+
sideOffset={0}
|
|
112
|
+
position="popper"
|
|
113
|
+
align="start"
|
|
114
|
+
className="RadixSelectContent">
|
|
115
|
+
<RadixSelect.Viewport className="RadixSelectViewport">
|
|
116
|
+
{options.map(option => (
|
|
117
|
+
<StyledItem
|
|
118
|
+
key={option.value}
|
|
119
|
+
value={option.value}>
|
|
120
|
+
<Plus width={20} />
|
|
121
|
+
{option.label}
|
|
122
|
+
</StyledItem>
|
|
123
|
+
))}
|
|
124
|
+
</RadixSelect.Viewport>
|
|
125
|
+
</StyledContent>
|
|
126
|
+
</RadixSelect.Root>
|
|
127
|
+
) : (
|
|
128
|
+
<TextField
|
|
129
|
+
leftIcon={leftIcon}
|
|
130
|
+
rightIcon={<CaretDown weight="fill" size={14} />}
|
|
131
|
+
label={label}
|
|
132
|
+
size={size}
|
|
133
|
+
disabled
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
{(helperText || error) && (
|
|
137
|
+
<HelperText>{error?.message || helperText}</HelperText>
|
|
138
|
+
)}
|
|
139
|
+
</Wrapper>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
export default Select
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
|
|
2
|
+
export interface SelectProps<TFieldValues extends FieldValues = FieldValues> {
|
|
3
|
+
className?: string
|
|
4
|
+
disabled?: boolean
|
|
5
|
+
error?: TFieldValues
|
|
6
|
+
label: string
|
|
7
|
+
options: Array<{ label: string; value: string }>
|
|
8
|
+
value?: string
|
|
9
|
+
defaultValue?: string
|
|
10
|
+
handleLeftIcon?: () => void
|
|
11
|
+
helperText?: string
|
|
12
|
+
leftIcon?: React.ReactNode
|
|
13
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
14
|
+
size?: 'sm' | 'md' | 'lg'
|
|
15
|
+
register?: UseFormRegisterReturn<string>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface StateInterface {
|
|
19
|
+
input: string
|
|
20
|
+
label: string
|
|
21
|
+
helperText: string
|
|
22
|
+
animation?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface TextFieldStates {
|
|
26
|
+
error: StateInterface
|
|
27
|
+
default: StateInterface
|
|
28
|
+
disabled: StateInterface
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type TextFieldSize = 'sm' | 'md' | 'lg'
|
|
32
|
+
|
|
33
|
+
export type TextFieldSizeType = {
|
|
34
|
+
input: string
|
|
35
|
+
label: string
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Select'
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {parseColor} from '../../utils'
|
|
2
|
-
import styled, {css} from 'styled-components'
|
|
1
|
+
import { parseColor } from '../../utils'
|
|
2
|
+
import styled, { css } from 'styled-components'
|
|
3
3
|
import {
|
|
4
4
|
fontSize,
|
|
5
5
|
fontWeight,
|
|
6
6
|
lineHeight,
|
|
7
7
|
fontFamily
|
|
8
8
|
} from '@liguelead/foundation'
|
|
9
|
-
import {TextProps} from './Text'
|
|
9
|
+
import { TextProps } from './Text.types'
|
|
10
10
|
|
|
11
11
|
type BodyProps = Omit<TextProps, 'tag'>
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ const Body = styled.p.withConfig({
|
|
|
21
21
|
${({
|
|
22
22
|
align = 'left',
|
|
23
23
|
color = 'neutral800',
|
|
24
|
-
isTitle
|
|
24
|
+
isTitle,
|
|
25
25
|
theme,
|
|
26
26
|
size = 'body01'
|
|
27
27
|
}) => css`
|
|
@@ -40,4 +40,4 @@ const Body = styled.p.withConfig({
|
|
|
40
40
|
`}
|
|
41
41
|
`
|
|
42
42
|
|
|
43
|
-
export {Body}
|
|
43
|
+
export { Body }
|
package/components/Text/Text.tsx
CHANGED
|
@@ -1,57 +1,19 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {Body} from './Text.styles'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type AlignType = 'left' | 'center' | 'right' | 'justify'
|
|
6
|
-
type SizeType =
|
|
7
|
-
| 'span01'
|
|
8
|
-
| 'body01'
|
|
9
|
-
| 'body02'
|
|
10
|
-
| 'heading01'
|
|
11
|
-
| 'heading02'
|
|
12
|
-
| 'heading03'
|
|
13
|
-
| 'heading04'
|
|
14
|
-
type TagType =
|
|
15
|
-
| 'h1'
|
|
16
|
-
| 'h2'
|
|
17
|
-
| 'h3'
|
|
18
|
-
| 'h4'
|
|
19
|
-
| 'h5'
|
|
20
|
-
| 'h6'
|
|
21
|
-
| 'p'
|
|
22
|
-
| 'span'
|
|
23
|
-
| 'label'
|
|
24
|
-
| 'small'
|
|
25
|
-
| 'b'
|
|
26
|
-
| 'i'
|
|
27
|
-
| 'em'
|
|
28
|
-
| 'td'
|
|
29
|
-
| 'div'
|
|
30
|
-
| 'a'
|
|
31
|
-
|
|
32
|
-
export interface TextProps {
|
|
33
|
-
align?: AlignType
|
|
34
|
-
children?: React.ReactNode
|
|
35
|
-
color?: colorType
|
|
36
|
-
isTitle?: boolean
|
|
37
|
-
tag?: TagType
|
|
38
|
-
size?: SizeType
|
|
39
|
-
weight?: string
|
|
40
|
-
className?: string
|
|
41
|
-
}
|
|
2
|
+
import { Body } from './Text.styles'
|
|
3
|
+
import { TextProps } from './Text.types'
|
|
42
4
|
|
|
43
5
|
const Text: React.FC<TextProps> = ({
|
|
44
6
|
align,
|
|
45
7
|
children,
|
|
46
8
|
color = 'neutral1000',
|
|
47
|
-
isTitle,
|
|
9
|
+
isTitle = false,
|
|
48
10
|
tag = 'p',
|
|
49
11
|
size,
|
|
50
12
|
...rest
|
|
51
13
|
}) => {
|
|
52
14
|
return (
|
|
53
15
|
<Body
|
|
54
|
-
as={tag}
|
|
16
|
+
as={isTitle ? 'h2' : tag}
|
|
55
17
|
align={align}
|
|
56
18
|
color={color}
|
|
57
19
|
size={size}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { colorType } from 'types'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
type AlignType = 'left' | 'center' | 'right' | 'justify'
|
|
5
|
+
|
|
6
|
+
type SizeType =
|
|
7
|
+
| 'span01'
|
|
8
|
+
| 'body01'
|
|
9
|
+
| 'body02'
|
|
10
|
+
| 'heading01'
|
|
11
|
+
| 'heading02'
|
|
12
|
+
| 'heading03'
|
|
13
|
+
| 'heading04'
|
|
14
|
+
|
|
15
|
+
type TagType =
|
|
16
|
+
| 'h1'
|
|
17
|
+
| 'h2'
|
|
18
|
+
| 'h3'
|
|
19
|
+
| 'h4'
|
|
20
|
+
| 'h5'
|
|
21
|
+
| 'h6'
|
|
22
|
+
| 'p'
|
|
23
|
+
| 'span'
|
|
24
|
+
| 'label'
|
|
25
|
+
| 'small'
|
|
26
|
+
| 'b'
|
|
27
|
+
| 'i'
|
|
28
|
+
| 'em'
|
|
29
|
+
| 'td'
|
|
30
|
+
| 'div'
|
|
31
|
+
| 'a'
|
|
32
|
+
|
|
33
|
+
export interface TextProps {
|
|
34
|
+
align?: AlignType
|
|
35
|
+
children?: ReactNode
|
|
36
|
+
color?: colorType
|
|
37
|
+
isTitle?: boolean
|
|
38
|
+
tag?: TagType
|
|
39
|
+
size?: SizeType
|
|
40
|
+
weight?: string
|
|
41
|
+
className?: string
|
|
42
|
+
}
|