@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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
import { RadioButtonProps } from './RadioButton.types'
|
|
3
|
+
import {
|
|
4
|
+
RadioWrapper,
|
|
5
|
+
RadioInput,
|
|
6
|
+
RadioContent,
|
|
7
|
+
RadioContentWithIcon,
|
|
8
|
+
RadioLabel,
|
|
9
|
+
RadioDescription,
|
|
10
|
+
RadioIconWrapper
|
|
11
|
+
} from './RadioButton.styles'
|
|
12
|
+
|
|
13
|
+
const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
className,
|
|
17
|
+
disabled = false,
|
|
18
|
+
error,
|
|
19
|
+
label,
|
|
20
|
+
description,
|
|
21
|
+
value,
|
|
22
|
+
checked,
|
|
23
|
+
onChange,
|
|
24
|
+
name,
|
|
25
|
+
register,
|
|
26
|
+
rightIcon,
|
|
27
|
+
variant = 'default',
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
30
|
+
ref
|
|
31
|
+
) => {
|
|
32
|
+
const hasError = !!error
|
|
33
|
+
|
|
34
|
+
const contentElement = (
|
|
35
|
+
<RadioContent>
|
|
36
|
+
<RadioLabel $error={hasError}>
|
|
37
|
+
{label}
|
|
38
|
+
</RadioLabel>
|
|
39
|
+
{description && (
|
|
40
|
+
<RadioDescription $error={hasError}>
|
|
41
|
+
{description}
|
|
42
|
+
</RadioDescription>
|
|
43
|
+
)}
|
|
44
|
+
</RadioContent>
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<RadioWrapper
|
|
49
|
+
className={className}
|
|
50
|
+
$disabled={disabled}
|
|
51
|
+
$error={hasError}
|
|
52
|
+
$variant={variant}
|
|
53
|
+
$checked={checked}
|
|
54
|
+
>
|
|
55
|
+
<RadioInput
|
|
56
|
+
ref={ref}
|
|
57
|
+
type="radio"
|
|
58
|
+
value={value}
|
|
59
|
+
$variant={variant}
|
|
60
|
+
checked={checked}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
name={name}
|
|
63
|
+
$error={hasError}
|
|
64
|
+
{...props}
|
|
65
|
+
{...register}
|
|
66
|
+
onChange={(e) => {
|
|
67
|
+
register?.onChange(e)
|
|
68
|
+
onChange?.(e)
|
|
69
|
+
}}
|
|
70
|
+
/>
|
|
71
|
+
{rightIcon ? (
|
|
72
|
+
<RadioContentWithIcon>
|
|
73
|
+
{contentElement}
|
|
74
|
+
<RadioIconWrapper $error={hasError}>
|
|
75
|
+
{rightIcon}
|
|
76
|
+
</RadioIconWrapper>
|
|
77
|
+
</RadioContentWithIcon>
|
|
78
|
+
) : (
|
|
79
|
+
contentElement
|
|
80
|
+
)}
|
|
81
|
+
</RadioWrapper>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
RadioButton.displayName = 'RadioButton'
|
|
87
|
+
|
|
88
|
+
export default RadioButton
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FieldValues, UseFormRegisterReturn } from 'react-hook-form'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export type RadioButtonVariant = 'default' | 'box'
|
|
5
|
+
|
|
6
|
+
export interface RadioButtonProps<TFieldValues extends FieldValues = FieldValues>
|
|
7
|
+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
8
|
+
label: string
|
|
9
|
+
description?: string
|
|
10
|
+
value: string
|
|
11
|
+
checked?: boolean
|
|
12
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
className?: string
|
|
15
|
+
name?: string
|
|
16
|
+
error?: TFieldValues
|
|
17
|
+
register?: UseFormRegisterReturn<string>
|
|
18
|
+
rightIcon?: React.ReactNode
|
|
19
|
+
variant?: RadioButtonVariant
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RadioButtonVariantProps {
|
|
23
|
+
$disabled?: boolean
|
|
24
|
+
$error?: boolean
|
|
25
|
+
$checked?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface RadioWrapperProps {
|
|
29
|
+
$disabled?: boolean
|
|
30
|
+
$error?: boolean
|
|
31
|
+
$variant?: 'default' | 'box'
|
|
32
|
+
$checked?: boolean
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { css } from 'styled-components'
|
|
2
|
+
import { parseColor } from '../../utils'
|
|
3
|
+
import { RadioButtonVariantProps } from './RadioButton.types'
|
|
4
|
+
import { spacing, radius} from "@liguelead/foundation"
|
|
5
|
+
|
|
6
|
+
export const RadioButtonVariant = (variant: 'default' | 'box') => {
|
|
7
|
+
const variants = {
|
|
8
|
+
default: css<RadioButtonVariantProps>`
|
|
9
|
+
/* Estilo padrão - sem bordas adicionais no wrapper */
|
|
10
|
+
`,
|
|
11
|
+
|
|
12
|
+
box: css<RadioButtonVariantProps>`
|
|
13
|
+
padding: ${spacing.spacing12}px;
|
|
14
|
+
border: 1px solid ${({ theme, $error }) =>
|
|
15
|
+
$error
|
|
16
|
+
? parseColor(theme.colors.danger200)
|
|
17
|
+
: parseColor(theme.colors.neutral400)
|
|
18
|
+
};
|
|
19
|
+
border-radius: ${radius.radius8}px;
|
|
20
|
+
background: ${({ theme }) => parseColor(theme.colors.white)};
|
|
21
|
+
|
|
22
|
+
/* Quando o input interno está checked, muda o estilo do wrapper */
|
|
23
|
+
input[type="radio"]:checked ~ * {
|
|
24
|
+
/* Força re-render no wrapper quando input muda */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Usa seletor CSS para detectar radio checked */
|
|
28
|
+
&:has(input[type="radio"]:checked) {
|
|
29
|
+
border-color: ${({ theme, $error }) =>
|
|
30
|
+
$error
|
|
31
|
+
? parseColor(theme.colors.danger200)
|
|
32
|
+
: parseColor(theme.colors.primary)
|
|
33
|
+
};
|
|
34
|
+
background: ${({ theme, $error }) =>
|
|
35
|
+
$error
|
|
36
|
+
? parseColor(theme.colors.white)
|
|
37
|
+
: `${parseColor(theme.colors.primaryLight)}`
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
border-color: ${({ theme, $error }) =>
|
|
43
|
+
$error
|
|
44
|
+
? parseColor(theme.colors.danger200)
|
|
45
|
+
: parseColor(theme.colors.primary)
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
&:has(input[type="radio"]:checked) {
|
|
49
|
+
background: ${({ theme, $error }) =>
|
|
50
|
+
$error
|
|
51
|
+
? parseColor(theme.colors.white)
|
|
52
|
+
: `${parseColor(theme.colors.primaryLight)}`
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:not(:has(input[type="radio"]:checked)) {
|
|
57
|
+
background: ${({ theme, $error }) =>
|
|
58
|
+
$error
|
|
59
|
+
? `${parseColor(theme.colors.danger200)}10`
|
|
60
|
+
: `${parseColor(theme.colors.white)}`
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}`
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return variants[variant] || variants.default
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RadioButton'
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import Button from '../Button'
|
|
3
|
-
import { parseColor } from '../../utils'
|
|
4
|
-
|
|
5
|
-
export const WrapperSegmentedButton = styled.div`
|
|
6
|
-
display: flex;
|
|
7
|
-
justify-content: center;
|
|
8
|
-
align-items: center;
|
|
9
|
-
border-radius: 8px;
|
|
10
|
-
width: fit-content;
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
export const LeftButton = styled(Button)`
|
|
14
|
-
border-radius: 4px 0 0 4px;
|
|
15
|
-
box-shadow: none;
|
|
16
|
-
border-right: none;
|
|
17
|
-
|
|
18
|
-
&:disabled {
|
|
19
|
-
border-color: ${({ theme }) => parseColor(theme.colors.neutral500)};
|
|
20
|
-
}
|
|
21
|
-
`
|
|
22
|
-
|
|
23
|
-
export const RightButton = styled(Button)`
|
|
24
|
-
border-radius: 0 4px 4px 0;
|
|
25
|
-
border-left: none;
|
|
26
|
-
&:focus {
|
|
27
|
-
box-shadow: none;
|
|
28
|
-
}
|
|
29
|
-
`
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import Button from '../Button'
|
|
3
|
+
import { parseColor } from '../../utils'
|
|
4
|
+
|
|
5
|
+
export const WrapperSegmentedButton = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
width: fit-content;
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const LeftButton = styled(Button)`
|
|
14
|
+
border-radius: 4px 0 0 4px;
|
|
15
|
+
box-shadow: none;
|
|
16
|
+
border-right: none;
|
|
17
|
+
|
|
18
|
+
&:disabled {
|
|
19
|
+
border-color: ${({ theme }) => parseColor(theme.colors.neutral500)};
|
|
20
|
+
}
|
|
21
|
+
`
|
|
22
|
+
|
|
23
|
+
export const RightButton = styled(Button)`
|
|
24
|
+
border-radius: 0 4px 4px 0;
|
|
25
|
+
border-left: none;
|
|
26
|
+
&:focus {
|
|
27
|
+
box-shadow: none;
|
|
28
|
+
}
|
|
29
|
+
`
|
|
@@ -1,49 +1,43 @@
|
|
|
1
|
-
import { SegmentedButtonProps } from './SegmentedButton.types'
|
|
2
|
-
import {
|
|
3
|
-
LeftButton,
|
|
4
|
-
RightButton,
|
|
5
|
-
WrapperSegmentedButton
|
|
6
|
-
} from './SegmentedButton.styles'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
</RightButton>
|
|
45
|
-
</WrapperSegmentedButton>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default SegmentedButton
|
|
1
|
+
import { SegmentedButtonProps } from './SegmentedButton.types'
|
|
2
|
+
import {
|
|
3
|
+
LeftButton,
|
|
4
|
+
RightButton,
|
|
5
|
+
WrapperSegmentedButton
|
|
6
|
+
} from './SegmentedButton.styles'
|
|
7
|
+
|
|
8
|
+
const SegmentedButton: React.FC<SegmentedButtonProps> = ({
|
|
9
|
+
options,
|
|
10
|
+
disabled = false,
|
|
11
|
+
color = 'primary',
|
|
12
|
+
size = 'md',
|
|
13
|
+
...rest
|
|
14
|
+
}) => {
|
|
15
|
+
const { leftButton, rightButton } = options
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<WrapperSegmentedButton {...rest}>
|
|
19
|
+
<LeftButton
|
|
20
|
+
color={color}
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
size={size}
|
|
23
|
+
onClick={() => {
|
|
24
|
+
leftButton.action?.()
|
|
25
|
+
}}
|
|
26
|
+
type="button">
|
|
27
|
+
{leftButton.label}
|
|
28
|
+
</LeftButton>
|
|
29
|
+
<RightButton
|
|
30
|
+
color={color}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
onClick={() => {
|
|
33
|
+
rightButton.action?.()
|
|
34
|
+
}}
|
|
35
|
+
size={size}
|
|
36
|
+
type="button">
|
|
37
|
+
{rightButton.label}
|
|
38
|
+
</RightButton>
|
|
39
|
+
</WrapperSegmentedButton>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default SegmentedButton
|
|
@@ -1,20 +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'
|
|
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'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './SegmentedButton'
|
|
1
|
+
export { default } from './SegmentedButton'
|
|
@@ -1,56 +1,55 @@
|
|
|
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: `
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
padding
|
|
35
|
-
padding-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
1
|
+
import { fontSize, lineHeight, spacing, fontWeight } 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: `
|
|
26
|
+
font-size: ${fontSize.fontSize14}px;
|
|
27
|
+
font-weight: ${fontWeight.fontWeight500};
|
|
28
|
+
`
|
|
29
|
+
},
|
|
30
|
+
md: {
|
|
31
|
+
input: `
|
|
32
|
+
font-size: ${fontSize.fontSize14}px;
|
|
33
|
+
line-height: ${lineHeight.lineHeight20}px;
|
|
34
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
35
|
+
padding-left: ${leftIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
36
|
+
padding-right: ${rightIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
37
|
+
`,
|
|
38
|
+
label: `font-size: ${fontSize.fontSize14}px;
|
|
39
|
+
font-weight: ${fontWeight.fontWeight500}`
|
|
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
|
+
font-weight: ${fontWeight.fontWeight500}`
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return sizes[size]
|
|
55
|
+
}
|
|
@@ -1,69 +1,40 @@
|
|
|
1
|
-
import { parseColor } from '../../utils'
|
|
2
|
-
import { useTheme } from 'styled-components'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
&:focus
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
input: `
|
|
32
|
-
border: 1px solid ${parseColor(theme.colors.
|
|
33
|
-
color: ${parseColor(theme.colors.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
}
|
|
1
|
+
import { parseColor } from '../../utils'
|
|
2
|
+
import { useTheme } from 'styled-components'
|
|
3
|
+
import { TextFieldStates } from './Select.types'
|
|
4
|
+
|
|
5
|
+
export const SelectStates = (state: keyof TextFieldStates) => {
|
|
6
|
+
const theme = useTheme()
|
|
7
|
+
const states: TextFieldStates = {
|
|
8
|
+
error: {
|
|
9
|
+
input: `
|
|
10
|
+
border: 1px solid ${parseColor(theme.colors.danger100)};
|
|
11
|
+
color: ${parseColor(theme.colors.textDark)};
|
|
12
|
+
&:focus {
|
|
13
|
+
border-color: ${parseColor(theme.colors.danger100)};
|
|
14
|
+
}
|
|
15
|
+
`,
|
|
16
|
+
label: `color: ${parseColor(theme.colors.danger100)};`,
|
|
17
|
+
helperText: `color: ${parseColor(theme.colors.danger100)};`
|
|
18
|
+
},
|
|
19
|
+
default: {
|
|
20
|
+
input: `
|
|
21
|
+
border: 1px solid ${parseColor(theme.colors.neutral700)};
|
|
22
|
+
color: ${parseColor(theme.colors.textDark)};
|
|
23
|
+
&:focus {
|
|
24
|
+
border-color: ${parseColor(theme.colors.primary)};
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
28
|
+
helperText: `color: ${parseColor(theme.colors.textMedium)};`
|
|
29
|
+
},
|
|
30
|
+
disabled: {
|
|
31
|
+
input: `
|
|
32
|
+
border: 1px solid ${parseColor(theme.colors.neutral400)};
|
|
33
|
+
color: ${parseColor(theme.colors.neutral600)};
|
|
34
|
+
`,
|
|
35
|
+
label: `color: ${parseColor(theme.colors.neutral1100)};`,
|
|
36
|
+
helperText: `color: ${parseColor(theme.colors.textMedium)};`
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return states[state]
|
|
40
|
+
}
|