@liguelead/design-system 0.0.9 → 0.0.11
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.appearance.ts +66 -62
- package/components/Button/Button.sizes.ts +42 -41
- package/components/Button/Button.styles.ts +46 -50
- package/components/Button/Button.tsx +76 -76
- package/components/Button/Button.types.ts +23 -23
- package/components/Button/index.ts +1 -1
- package/components/Checkbox/Checkbox.styles.ts +115 -66
- package/components/Checkbox/Checkbox.tsx +97 -40
- package/components/Checkbox/Checkbox.types.ts +12 -11
- package/components/Checkbox/index.tsx +2 -2
- package/components/DatePicker/DatePicker.styles.ts +66 -66
- package/components/DatePicker/DatePicker.tsx +135 -135
- package/components/DatePicker/DatePicker.types.ts +29 -29
- package/components/DatePicker/index.ts +1 -1
- package/components/IconButton/IconButton.sizes.ts +34 -41
- package/components/IconButton/IconButton.tsx +70 -70
- package/components/IconButton/index.ts +1 -1
- package/components/InputOpt/InputOpt.styles.ts +75 -0
- package/components/InputOpt/InputOpt.tsx +153 -0
- package/components/InputOpt/InputOpt.types.ts +14 -0
- package/components/InputOpt/index.ts +1 -0
- package/components/InputOpt/utils/focusManagement.ts +31 -0
- package/components/InputOpt/utils/index.ts +2 -0
- package/components/InputOpt/utils/inputValidation.ts +14 -0
- package/components/LinkButton/LinkButton.size.ts +39 -0
- package/components/LinkButton/LinkButton.style.ts +45 -0
- package/components/LinkButton/LinkButton.tsx +75 -0
- package/components/LinkButton/LinkButton.types.ts +11 -0
- package/components/LinkButton/index.ts +1 -0
- package/components/PageWrapper/PageWrapper.tsx +31 -31
- package/components/PageWrapper/index.ts +1 -1
- package/components/RadioButton/RadioButton.inputVariants.ts +133 -0
- package/components/RadioButton/RadioButton.styles.ts +78 -0
- package/components/RadioButton/RadioButton.tsx +88 -0
- package/components/RadioButton/RadioButton.types.ts +33 -0
- package/components/RadioButton/RadioButton.variants.ts +67 -0
- package/components/RadioButton/index.ts +1 -0
- package/components/SegmentedButton/SegmentedButton.styles.ts +29 -29
- package/components/SegmentedButton/SegmentedButton.tsx +43 -49
- package/components/SegmentedButton/SegmentedButton.types.ts +20 -20
- package/components/SegmentedButton/index.ts +1 -1
- package/components/Select/Select.sizes.ts +55 -56
- package/components/Select/Select.states.tsx +40 -69
- package/components/Select/Select.styles.ts +162 -148
- package/components/Select/Select.tsx +152 -144
- package/components/Select/Select.types.ts +35 -36
- package/components/Select/index.ts +1 -1
- package/components/Text/Text.styles.ts +46 -43
- package/components/Text/Text.tsx +27 -27
- package/components/Text/Text.types.ts +44 -42
- package/components/Text/index.ts +1 -1
- package/components/TextField/TextField.sizes.ts +52 -58
- package/components/TextField/TextField.states.tsx +53 -76
- package/components/TextField/TextField.styles.ts +85 -98
- package/components/TextField/TextField.tsx +108 -108
- package/components/TextField/TextField.types.ts +22 -21
- package/components/TextField/index.ts +2 -2
- package/components/TextField/utils/getState.ts +7 -0
- package/components/ThemeProvider/ThemeProvider.tsx +21 -21
- package/components/ThemeProvider/index.ts +1 -1
- package/components/ThemeProvider/style.ts +969 -969
- package/components/Wizard/StepContent.tsx +28 -28
- package/components/Wizard/StepMenuItem.tsx +33 -33
- package/components/Wizard/Wizard.context.tsx +76 -76
- package/components/Wizard/Wizard.styles.ts +126 -126
- package/components/Wizard/Wizard.tsx +55 -55
- package/components/Wizard/index.ts +1 -1
- package/components/index.ts +14 -11
- package/package.json +41 -41
- package/scripts/createTypes.js +70 -70
- package/utils/colorDarken.ts +10 -10
- package/utils/colorLighten.ts +10 -10
- package/utils/darkenOrLighen.ts +19 -19
- package/utils/getTextColor.ts +12 -12
- package/utils/index.ts +5 -5
- package/utils/parseColor.ts +7 -7
|
@@ -1,135 +1,135 @@
|
|
|
1
|
-
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
2
|
-
import {
|
|
3
|
-
Calendar,
|
|
4
|
-
CaretLeft,
|
|
5
|
-
CaretRight,
|
|
6
|
-
CaretDown
|
|
7
|
-
} from '@phosphor-icons/react'
|
|
8
|
-
import { getYear, getMonth } from 'date-fns'
|
|
9
|
-
import { range } from 'lodash'
|
|
10
|
-
import { ptBR } from 'date-fns/locale'
|
|
11
|
-
import { forwardRef, useState } from 'react'
|
|
12
|
-
import TextField from '../TextField'
|
|
13
|
-
import { DatePickerProps, Months } from './DatePicker.types'
|
|
14
|
-
import {
|
|
15
|
-
ButtonDatePicker,
|
|
16
|
-
HeaderSelectWrapper,
|
|
17
|
-
DropdownContent,
|
|
18
|
-
DropdownItem,
|
|
19
|
-
ArrownDatePicker
|
|
20
|
-
} from './DatePicker.styles'
|
|
21
|
-
import DatePicker from 'react-datepicker'
|
|
22
|
-
|
|
23
|
-
const DatePickerCustom = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
24
|
-
(
|
|
25
|
-
{
|
|
26
|
-
label,
|
|
27
|
-
error,
|
|
28
|
-
startYear = 1990,
|
|
29
|
-
endYear = 0,
|
|
30
|
-
startDate = new Date(),
|
|
31
|
-
icon = false,
|
|
32
|
-
onChange,
|
|
33
|
-
size = 'md',
|
|
34
|
-
register,
|
|
35
|
-
...rest
|
|
36
|
-
}: DatePickerProps,
|
|
37
|
-
ref
|
|
38
|
-
) => {
|
|
39
|
-
const [pickerStartDate, setPickerStartDate] = useState<Date | null>(
|
|
40
|
-
startDate
|
|
41
|
-
)
|
|
42
|
-
const lastYear =
|
|
43
|
-
endYear > startYear ? endYear + 1 : getYear(new Date()) + 1
|
|
44
|
-
const years = range(startYear, lastYear, 1)
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<DatePicker
|
|
48
|
-
{...register}
|
|
49
|
-
{...rest}
|
|
50
|
-
locale={ptBR}
|
|
51
|
-
renderCustomHeader={({
|
|
52
|
-
date,
|
|
53
|
-
changeYear,
|
|
54
|
-
changeMonth,
|
|
55
|
-
decreaseMonth,
|
|
56
|
-
increaseMonth,
|
|
57
|
-
prevMonthButtonDisabled,
|
|
58
|
-
nextMonthButtonDisabled
|
|
59
|
-
}) => (
|
|
60
|
-
<HeaderSelectWrapper>
|
|
61
|
-
<ArrownDatePicker
|
|
62
|
-
onClick={decreaseMonth}
|
|
63
|
-
disabled={prevMonthButtonDisabled}>
|
|
64
|
-
<CaretLeft size={24} weight="bold" />
|
|
65
|
-
</ArrownDatePicker>
|
|
66
|
-
<DropdownMenu.Root modal={false}>
|
|
67
|
-
<DropdownMenu.Trigger asChild>
|
|
68
|
-
<ButtonDatePicker>
|
|
69
|
-
{getYear(date)} <CaretDown size={16} />
|
|
70
|
-
</ButtonDatePicker>
|
|
71
|
-
</DropdownMenu.Trigger>
|
|
72
|
-
<DropdownContent>
|
|
73
|
-
{years.map(option => (
|
|
74
|
-
<DropdownItem
|
|
75
|
-
key={option}
|
|
76
|
-
onSelect={() => {
|
|
77
|
-
changeYear(option)
|
|
78
|
-
}}>
|
|
79
|
-
{option}
|
|
80
|
-
</DropdownItem>
|
|
81
|
-
))}
|
|
82
|
-
</DropdownContent>
|
|
83
|
-
</DropdownMenu.Root>
|
|
84
|
-
<DropdownMenu.Root modal={false}>
|
|
85
|
-
<DropdownMenu.Trigger asChild>
|
|
86
|
-
<ButtonDatePicker>
|
|
87
|
-
{Months[getMonth(date)]}{' '}
|
|
88
|
-
<CaretDown size={16} />
|
|
89
|
-
</ButtonDatePicker>
|
|
90
|
-
</DropdownMenu.Trigger>
|
|
91
|
-
<DropdownContent>
|
|
92
|
-
{Months.map((month, index) => (
|
|
93
|
-
<DropdownItem
|
|
94
|
-
key={month}
|
|
95
|
-
onSelect={() => {
|
|
96
|
-
changeMonth(index)
|
|
97
|
-
}}>
|
|
98
|
-
{month}
|
|
99
|
-
</DropdownItem>
|
|
100
|
-
))}
|
|
101
|
-
</DropdownContent>
|
|
102
|
-
</DropdownMenu.Root>
|
|
103
|
-
|
|
104
|
-
<ArrownDatePicker
|
|
105
|
-
onClick={increaseMonth}
|
|
106
|
-
disabled={nextMonthButtonDisabled}>
|
|
107
|
-
<CaretRight size={24} weight="bold" />
|
|
108
|
-
</ArrownDatePicker>
|
|
109
|
-
</HeaderSelectWrapper>
|
|
110
|
-
)}
|
|
111
|
-
dateFormat="dd/MM/yyyy"
|
|
112
|
-
selected={pickerStartDate}
|
|
113
|
-
onChange={(date: Date | null) => {
|
|
114
|
-
if (!date) {
|
|
115
|
-
return
|
|
116
|
-
}
|
|
117
|
-
setPickerStartDate(date)
|
|
118
|
-
onChange?.(date)
|
|
119
|
-
}}
|
|
120
|
-
customInput={
|
|
121
|
-
<TextField
|
|
122
|
-
error={error}
|
|
123
|
-
size={size}
|
|
124
|
-
ref={ref}
|
|
125
|
-
leftIcon={icon && <Calendar size={22} weight="bold" />}
|
|
126
|
-
label={label}
|
|
127
|
-
className="example-custom-input"
|
|
128
|
-
/>
|
|
129
|
-
}
|
|
130
|
-
/>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
export default DatePickerCustom
|
|
1
|
+
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
2
|
+
import {
|
|
3
|
+
Calendar,
|
|
4
|
+
CaretLeft,
|
|
5
|
+
CaretRight,
|
|
6
|
+
CaretDown
|
|
7
|
+
} from '@phosphor-icons/react'
|
|
8
|
+
import { getYear, getMonth } from 'date-fns'
|
|
9
|
+
import { range } from 'lodash'
|
|
10
|
+
import { ptBR } from 'date-fns/locale'
|
|
11
|
+
import { forwardRef, useState } from 'react'
|
|
12
|
+
import TextField from '../TextField'
|
|
13
|
+
import { DatePickerProps, Months } from './DatePicker.types'
|
|
14
|
+
import {
|
|
15
|
+
ButtonDatePicker,
|
|
16
|
+
HeaderSelectWrapper,
|
|
17
|
+
DropdownContent,
|
|
18
|
+
DropdownItem,
|
|
19
|
+
ArrownDatePicker
|
|
20
|
+
} from './DatePicker.styles'
|
|
21
|
+
import DatePicker from 'react-datepicker'
|
|
22
|
+
|
|
23
|
+
const DatePickerCustom = forwardRef<HTMLInputElement, DatePickerProps>(
|
|
24
|
+
(
|
|
25
|
+
{
|
|
26
|
+
label,
|
|
27
|
+
error,
|
|
28
|
+
startYear = 1990,
|
|
29
|
+
endYear = 0,
|
|
30
|
+
startDate = new Date(),
|
|
31
|
+
icon = false,
|
|
32
|
+
onChange,
|
|
33
|
+
size = 'md',
|
|
34
|
+
register,
|
|
35
|
+
...rest
|
|
36
|
+
}: DatePickerProps,
|
|
37
|
+
ref
|
|
38
|
+
) => {
|
|
39
|
+
const [pickerStartDate, setPickerStartDate] = useState<Date | null>(
|
|
40
|
+
startDate
|
|
41
|
+
)
|
|
42
|
+
const lastYear =
|
|
43
|
+
endYear > startYear ? endYear + 1 : getYear(new Date()) + 1
|
|
44
|
+
const years = range(startYear, lastYear, 1)
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<DatePicker
|
|
48
|
+
{...register}
|
|
49
|
+
{...rest}
|
|
50
|
+
locale={ptBR}
|
|
51
|
+
renderCustomHeader={({
|
|
52
|
+
date,
|
|
53
|
+
changeYear,
|
|
54
|
+
changeMonth,
|
|
55
|
+
decreaseMonth,
|
|
56
|
+
increaseMonth,
|
|
57
|
+
prevMonthButtonDisabled,
|
|
58
|
+
nextMonthButtonDisabled
|
|
59
|
+
}) => (
|
|
60
|
+
<HeaderSelectWrapper>
|
|
61
|
+
<ArrownDatePicker
|
|
62
|
+
onClick={decreaseMonth}
|
|
63
|
+
disabled={prevMonthButtonDisabled}>
|
|
64
|
+
<CaretLeft size={24} weight="bold" />
|
|
65
|
+
</ArrownDatePicker>
|
|
66
|
+
<DropdownMenu.Root modal={false}>
|
|
67
|
+
<DropdownMenu.Trigger asChild>
|
|
68
|
+
<ButtonDatePicker>
|
|
69
|
+
{getYear(date)} <CaretDown size={16} />
|
|
70
|
+
</ButtonDatePicker>
|
|
71
|
+
</DropdownMenu.Trigger>
|
|
72
|
+
<DropdownContent>
|
|
73
|
+
{years.map(option => (
|
|
74
|
+
<DropdownItem
|
|
75
|
+
key={option}
|
|
76
|
+
onSelect={() => {
|
|
77
|
+
changeYear(option)
|
|
78
|
+
}}>
|
|
79
|
+
{option}
|
|
80
|
+
</DropdownItem>
|
|
81
|
+
))}
|
|
82
|
+
</DropdownContent>
|
|
83
|
+
</DropdownMenu.Root>
|
|
84
|
+
<DropdownMenu.Root modal={false}>
|
|
85
|
+
<DropdownMenu.Trigger asChild>
|
|
86
|
+
<ButtonDatePicker>
|
|
87
|
+
{Months[getMonth(date)]}{' '}
|
|
88
|
+
<CaretDown size={16} />
|
|
89
|
+
</ButtonDatePicker>
|
|
90
|
+
</DropdownMenu.Trigger>
|
|
91
|
+
<DropdownContent>
|
|
92
|
+
{Months.map((month, index) => (
|
|
93
|
+
<DropdownItem
|
|
94
|
+
key={month}
|
|
95
|
+
onSelect={() => {
|
|
96
|
+
changeMonth(index)
|
|
97
|
+
}}>
|
|
98
|
+
{month}
|
|
99
|
+
</DropdownItem>
|
|
100
|
+
))}
|
|
101
|
+
</DropdownContent>
|
|
102
|
+
</DropdownMenu.Root>
|
|
103
|
+
|
|
104
|
+
<ArrownDatePicker
|
|
105
|
+
onClick={increaseMonth}
|
|
106
|
+
disabled={nextMonthButtonDisabled}>
|
|
107
|
+
<CaretRight size={24} weight="bold" />
|
|
108
|
+
</ArrownDatePicker>
|
|
109
|
+
</HeaderSelectWrapper>
|
|
110
|
+
)}
|
|
111
|
+
dateFormat="dd/MM/yyyy"
|
|
112
|
+
selected={pickerStartDate}
|
|
113
|
+
onChange={(date: Date | null) => {
|
|
114
|
+
if (!date) {
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
setPickerStartDate(date)
|
|
118
|
+
onChange?.(date)
|
|
119
|
+
}}
|
|
120
|
+
customInput={
|
|
121
|
+
<TextField
|
|
122
|
+
error={error}
|
|
123
|
+
size={size}
|
|
124
|
+
ref={ref}
|
|
125
|
+
leftIcon={icon && <Calendar size={22} weight="bold" />}
|
|
126
|
+
label={label}
|
|
127
|
+
className="example-custom-input"
|
|
128
|
+
/>
|
|
129
|
+
}
|
|
130
|
+
/>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
export default DatePickerCustom
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { FieldValues, UseFormRegister } from 'react-hook-form'
|
|
2
|
-
|
|
3
|
-
export const Months = [
|
|
4
|
-
'Janeiro',
|
|
5
|
-
'Fevereiro',
|
|
6
|
-
'Março',
|
|
7
|
-
'Abril',
|
|
8
|
-
'Maio',
|
|
9
|
-
'Junho',
|
|
10
|
-
'Julho',
|
|
11
|
-
'Agosto',
|
|
12
|
-
'Setembro',
|
|
13
|
-
'Outubro',
|
|
14
|
-
'Novembro',
|
|
15
|
-
'Dezembro'
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
export type DatePickerProps = {
|
|
19
|
-
endYear?: number
|
|
20
|
-
label: string
|
|
21
|
-
startYear?: number
|
|
22
|
-
onChange?: (date: Date) => void
|
|
23
|
-
error?: FieldValues
|
|
24
|
-
startDate?: Date
|
|
25
|
-
className?: string
|
|
26
|
-
icon?: boolean
|
|
27
|
-
size?: 'sm' | 'md' | 'lg'
|
|
28
|
-
register?: UseFormRegister<Date>
|
|
29
|
-
}
|
|
1
|
+
import { FieldValues, UseFormRegister } from 'react-hook-form'
|
|
2
|
+
|
|
3
|
+
export const Months = [
|
|
4
|
+
'Janeiro',
|
|
5
|
+
'Fevereiro',
|
|
6
|
+
'Março',
|
|
7
|
+
'Abril',
|
|
8
|
+
'Maio',
|
|
9
|
+
'Junho',
|
|
10
|
+
'Julho',
|
|
11
|
+
'Agosto',
|
|
12
|
+
'Setembro',
|
|
13
|
+
'Outubro',
|
|
14
|
+
'Novembro',
|
|
15
|
+
'Dezembro'
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
export type DatePickerProps = {
|
|
19
|
+
endYear?: number
|
|
20
|
+
label: string
|
|
21
|
+
startYear?: number
|
|
22
|
+
onChange?: (date: Date) => void
|
|
23
|
+
error?: FieldValues
|
|
24
|
+
startDate?: Date
|
|
25
|
+
className?: string
|
|
26
|
+
icon?: boolean
|
|
27
|
+
size?: 'sm' | 'md' | 'lg'
|
|
28
|
+
register?: UseFormRegister<Date>
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './DatePicker'
|
|
1
|
+
export { default } from './DatePicker'
|
|
@@ -1,41 +1,34 @@
|
|
|
1
|
-
import { spacing } from '@liguelead/foundation'
|
|
2
|
-
import { ButtonSizeTypes } from '../Button/Button.types'
|
|
3
|
-
|
|
4
|
-
export const IconButtonSizes = (size: ButtonSizeTypes) => {
|
|
5
|
-
const sizes = {
|
|
6
|
-
|
|
7
|
-
padding: ${spacing.
|
|
8
|
-
border-radius: ${spacing.spacing4}px;
|
|
9
|
-
& svg {
|
|
10
|
-
width: ${spacing.
|
|
11
|
-
height: ${spacing.
|
|
12
|
-
}
|
|
13
|
-
`,
|
|
14
|
-
|
|
15
|
-
padding: ${spacing.
|
|
16
|
-
border-radius: ${spacing.spacing4}px;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
height: ${spacing.spacing32}px;
|
|
36
|
-
}
|
|
37
|
-
`
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return sizes[size]
|
|
41
|
-
}
|
|
1
|
+
import { spacing } from '@liguelead/foundation'
|
|
2
|
+
import { ButtonSizeTypes } from '../Button/Button.types'
|
|
3
|
+
|
|
4
|
+
export const IconButtonSizes = (size: ButtonSizeTypes) => {
|
|
5
|
+
const sizes = {
|
|
6
|
+
sm: `
|
|
7
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
8
|
+
border-radius: ${spacing.spacing4}px;
|
|
9
|
+
& svg {
|
|
10
|
+
width: ${spacing.spacing16}px !important;
|
|
11
|
+
height: ${spacing.spacing16}px;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
md: `
|
|
15
|
+
padding: ${spacing.spacing8}px ${spacing.spacing4}px;
|
|
16
|
+
border-radius: ${spacing.spacing4}px;
|
|
17
|
+
min-width: ${spacing.spacing36}px;
|
|
18
|
+
& svg {
|
|
19
|
+
width: ${spacing.spacing16}px;
|
|
20
|
+
height: ${spacing.spacing16}px;
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
lg: `
|
|
24
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
25
|
+
border-radius: ${spacing.spacing4}px;
|
|
26
|
+
& svg {
|
|
27
|
+
width: ${spacing.spacing16}px;
|
|
28
|
+
height: ${spacing.spacing16}px;
|
|
29
|
+
}
|
|
30
|
+
`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return sizes[size]
|
|
34
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import { ButtonProps, RippleInterface } from '../Button/Button.types'
|
|
3
|
-
import {
|
|
4
|
-
import { IconButtonSizes } from './IconButton.sizes'
|
|
5
|
-
import { RippleContainer, StyledButton } from '../Button/Button.styles'
|
|
6
|
-
|
|
7
|
-
const IconButton: React.FC<ButtonProps> = ({
|
|
8
|
-
|
|
9
|
-
children,
|
|
10
|
-
className,
|
|
11
|
-
color = 'primary',
|
|
12
|
-
disabled,
|
|
13
|
-
fluid = false,
|
|
14
|
-
size = 'md',
|
|
15
|
-
onClick,
|
|
16
|
-
...rest
|
|
17
|
-
}) => {
|
|
18
|
-
const [ripples, setRipples] = useState<RippleInterface[]>([])
|
|
19
|
-
|
|
20
|
-
const buttonSize = IconButtonSizes(size)
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
24
|
-
const rect = e.currentTarget.getBoundingClientRect()
|
|
25
|
-
const x = e.clientX - rect.left
|
|
26
|
-
const y = e.clientY - rect.top
|
|
27
|
-
|
|
28
|
-
const newRipple: RippleInterface = {
|
|
29
|
-
id: `${Date.now()}-${Math.random()}`,
|
|
30
|
-
x,
|
|
31
|
-
y
|
|
32
|
-
}
|
|
33
|
-
setRipples(prev => [...prev, newRipple])
|
|
34
|
-
|
|
35
|
-
// Chama o onClick fornecido
|
|
36
|
-
if (onClick) {
|
|
37
|
-
onClick(e)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<StyledButton
|
|
43
|
-
disabled={disabled}
|
|
44
|
-
className={className}
|
|
45
|
-
$fluid={fluid}
|
|
46
|
-
$
|
|
47
|
-
onClick={handleClick}
|
|
48
|
-
$buttonSize={buttonSize}
|
|
49
|
-
{...rest}>
|
|
50
|
-
{children}
|
|
51
|
-
{ripples.map(ripple => (
|
|
52
|
-
<RippleContainer
|
|
53
|
-
$
|
|
54
|
-
key={ripple.id}
|
|
55
|
-
style={{
|
|
56
|
-
top: ripple.y - 10,
|
|
57
|
-
left: ripple.x - 10,
|
|
58
|
-
width: 20,
|
|
59
|
-
height: 20
|
|
60
|
-
}}
|
|
61
|
-
onAnimationEnd={() =>
|
|
62
|
-
setRipples(prev => prev.filter(r => r.id !== ripple.id))
|
|
63
|
-
}
|
|
64
|
-
/>
|
|
65
|
-
))}
|
|
66
|
-
</StyledButton>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default IconButton
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { ButtonProps, RippleInterface } from '../Button/Button.types'
|
|
3
|
+
import { ButtonVariant } from '../Button/Button.appearance'
|
|
4
|
+
import { IconButtonSizes } from './IconButton.sizes'
|
|
5
|
+
import { RippleContainer, StyledButton } from '../Button/Button.styles'
|
|
6
|
+
|
|
7
|
+
const IconButton: React.FC<ButtonProps> = ({
|
|
8
|
+
variant = 'solid',
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
color = 'primary',
|
|
12
|
+
disabled,
|
|
13
|
+
fluid = false,
|
|
14
|
+
size = 'md',
|
|
15
|
+
onClick,
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
18
|
+
const [ripples, setRipples] = useState<RippleInterface[]>([])
|
|
19
|
+
|
|
20
|
+
const buttonSize = IconButtonSizes(size)
|
|
21
|
+
const buttonVariant = ButtonVariant(color, variant)
|
|
22
|
+
|
|
23
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
24
|
+
const rect = e.currentTarget.getBoundingClientRect()
|
|
25
|
+
const x = e.clientX - rect.left
|
|
26
|
+
const y = e.clientY - rect.top
|
|
27
|
+
|
|
28
|
+
const newRipple: RippleInterface = {
|
|
29
|
+
id: `${Date.now()}-${Math.random()}`,
|
|
30
|
+
x,
|
|
31
|
+
y
|
|
32
|
+
}
|
|
33
|
+
setRipples(prev => [...prev, newRipple])
|
|
34
|
+
|
|
35
|
+
// Chama o onClick fornecido
|
|
36
|
+
if (onClick) {
|
|
37
|
+
onClick(e)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<StyledButton
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
className={className}
|
|
45
|
+
$fluid={fluid}
|
|
46
|
+
$variant={buttonVariant}
|
|
47
|
+
onClick={handleClick}
|
|
48
|
+
$buttonSize={buttonSize}
|
|
49
|
+
{...rest}>
|
|
50
|
+
{children}
|
|
51
|
+
{ripples.map(ripple => (
|
|
52
|
+
<RippleContainer
|
|
53
|
+
$variant={variant}
|
|
54
|
+
key={ripple.id}
|
|
55
|
+
style={{
|
|
56
|
+
top: ripple.y - 10,
|
|
57
|
+
left: ripple.x - 10,
|
|
58
|
+
width: 20,
|
|
59
|
+
height: 20
|
|
60
|
+
}}
|
|
61
|
+
onAnimationEnd={() =>
|
|
62
|
+
setRipples(prev => prev.filter(r => r.id !== ripple.id))
|
|
63
|
+
}
|
|
64
|
+
/>
|
|
65
|
+
))}
|
|
66
|
+
</StyledButton>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default IconButton
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './IconButton'
|
|
1
|
+
export { default } from './IconButton'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
import { spacing, fontSize, fontWeight, shadow, lineHeight } from '@liguelead/foundation'
|
|
3
|
+
import { parseColor } from '../../utils'
|
|
4
|
+
|
|
5
|
+
export const OptWrapper = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: ${spacing.spacing16}px;
|
|
8
|
+
`
|
|
9
|
+
|
|
10
|
+
interface OptBoxProps {
|
|
11
|
+
$disabled?: boolean;
|
|
12
|
+
$error?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const OptBox = styled.input<OptBoxProps>`
|
|
16
|
+
width: ${spacing.spacing36}px;
|
|
17
|
+
height: ${spacing.spacing36}px;
|
|
18
|
+
text-align: center;
|
|
19
|
+
font-size: ${fontSize.fontSize14}px;
|
|
20
|
+
font-weight: ${fontWeight.fontWeight400};
|
|
21
|
+
border: 1px solid ${({ theme }) => parseColor(theme.colors.neutral400)};
|
|
22
|
+
background: ${({ theme }) => parseColor(theme.colors.white)};
|
|
23
|
+
color: ${({ theme }) => parseColor(theme.colors.neutral1100)};
|
|
24
|
+
border-radius: 4px;
|
|
25
|
+
outline: none;
|
|
26
|
+
transition: border-color .15s ease, box-shadow .15s ease;
|
|
27
|
+
|
|
28
|
+
${({ $error, theme }) =>
|
|
29
|
+
$error &&
|
|
30
|
+
css`
|
|
31
|
+
border-color: ${parseColor(theme.colors.danger100)};
|
|
32
|
+
`}
|
|
33
|
+
|
|
34
|
+
&:focus {
|
|
35
|
+
${({ $error, theme }) =>
|
|
36
|
+
$error
|
|
37
|
+
? css`
|
|
38
|
+
border-color: ${parseColor(theme.colors.danger200)};
|
|
39
|
+
box-shadow: 0 0 0 3px ${parseColor(theme.colors.danger100)}40;
|
|
40
|
+
`
|
|
41
|
+
: css`
|
|
42
|
+
border-color: ${parseColor(theme.colors.neutral700)};
|
|
43
|
+
box-shadow: ${shadow.focusShadow};
|
|
44
|
+
`}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
${({ $disabled, theme }) =>
|
|
48
|
+
$disabled &&
|
|
49
|
+
css`
|
|
50
|
+
opacity: 0.5;
|
|
51
|
+
cursor: not-allowed;
|
|
52
|
+
border-color: ${parseColor(theme.colors.neutral400)};
|
|
53
|
+
background: ${parseColor(theme.colors.neutral100)};
|
|
54
|
+
`}
|
|
55
|
+
`
|
|
56
|
+
|
|
57
|
+
export const OtpSeparator = styled.span`
|
|
58
|
+
color: ${({ theme }) => parseColor(theme.colors.neutral700)};
|
|
59
|
+
font-size: 20px;
|
|
60
|
+
user-select: none;
|
|
61
|
+
`
|
|
62
|
+
|
|
63
|
+
export const OtpSeparatorContainer = styled.div`
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
`
|
|
67
|
+
|
|
68
|
+
export const OptHelperText = styled.span<{ $error?: boolean }>`
|
|
69
|
+
display: block;
|
|
70
|
+
margin-top: ${spacing.spacing8}px;
|
|
71
|
+
font-size: ${fontSize.fontSize12}px;
|
|
72
|
+
line-height: ${lineHeight.lineHeight16}px;
|
|
73
|
+
color: ${({ theme, $error }) =>
|
|
74
|
+
$error ? parseColor(theme.colors.danger100) : parseColor(theme.colors.neutral700)};
|
|
75
|
+
`
|