@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,36 +1,35 @@
|
|
|
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
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TextFieldStates {
|
|
25
|
+
error: StateInterface
|
|
26
|
+
default: StateInterface
|
|
27
|
+
disabled: StateInterface
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type TextFieldSize = 'sm' | 'md' | 'lg'
|
|
31
|
+
|
|
32
|
+
export type TextFieldSizeType = {
|
|
33
|
+
input: string
|
|
34
|
+
label: string
|
|
35
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './Select'
|
|
1
|
+
export { default } from './Select'
|
|
@@ -1,43 +1,46 @@
|
|
|
1
|
-
import { parseColor } from '../../utils'
|
|
2
|
-
import styled, { css } from 'styled-components'
|
|
3
|
-
import {
|
|
4
|
-
fontSize,
|
|
5
|
-
fontWeight,
|
|
6
|
-
lineHeight,
|
|
7
|
-
fontFamily
|
|
8
|
-
} from '@liguelead/foundation'
|
|
9
|
-
import { TextProps } from './Text.types'
|
|
10
|
-
|
|
11
|
-
type BodyProps = Omit<TextProps, 'tag'>
|
|
12
|
-
|
|
13
|
-
const Body = styled.p.withConfig({
|
|
14
|
-
shouldForwardProp: prop =>
|
|
15
|
-
!['color', 'margin', 'isTitle', 'size', 'align', 'weight'].includes(
|
|
16
|
-
prop
|
|
17
|
-
)
|
|
18
|
-
})<BodyProps>`
|
|
19
|
-
position: relative;
|
|
20
|
-
|
|
21
|
-
${({
|
|
22
|
-
align = 'left',
|
|
23
|
-
color = '
|
|
24
|
-
isTitle,
|
|
25
|
-
theme,
|
|
26
|
-
size = 'body01'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
import { parseColor } from '../../utils'
|
|
2
|
+
import styled, { css } from 'styled-components'
|
|
3
|
+
import {
|
|
4
|
+
fontSize,
|
|
5
|
+
fontWeight,
|
|
6
|
+
lineHeight,
|
|
7
|
+
fontFamily
|
|
8
|
+
} from '@liguelead/foundation'
|
|
9
|
+
import { TextProps } from './Text.types'
|
|
10
|
+
|
|
11
|
+
type BodyProps = Omit<TextProps, 'tag'>
|
|
12
|
+
|
|
13
|
+
const Body = styled.p.withConfig({
|
|
14
|
+
shouldForwardProp: prop =>
|
|
15
|
+
!['color', 'margin', 'isTitle', 'size', 'align', 'weight'].includes(
|
|
16
|
+
prop
|
|
17
|
+
)
|
|
18
|
+
})<BodyProps>`
|
|
19
|
+
position: relative;
|
|
20
|
+
|
|
21
|
+
${({
|
|
22
|
+
align = 'left',
|
|
23
|
+
color = 'textMedium',
|
|
24
|
+
isTitle,
|
|
25
|
+
theme,
|
|
26
|
+
size = 'body01',
|
|
27
|
+
weight
|
|
28
|
+
}) => css`
|
|
29
|
+
text-align: ${align};
|
|
30
|
+
color: ${parseColor(theme.colors[color] || theme.colors.textMedium)};
|
|
31
|
+
font-family: '${isTitle
|
|
32
|
+
? fontFamily[theme.fonts?.headings as keyof typeof fontFamily]
|
|
33
|
+
: fontFamily[theme.fonts?.default as keyof typeof fontFamily]}',
|
|
34
|
+
sans-serif;
|
|
35
|
+
font-weight: ${weight
|
|
36
|
+
? fontWeight[weight as keyof typeof fontWeight]
|
|
37
|
+
: fontWeight[theme.typography[size]?.fontWeight as keyof typeof fontWeight] ||
|
|
38
|
+
'normal'};
|
|
39
|
+
font-size: ${fontSize[theme.typography[size]?.fontSize as keyof typeof fontSize] ||
|
|
40
|
+
fontSize.fontSize16}px;
|
|
41
|
+
line-height: ${lineHeight[theme.typography[size]?.lineHeight as keyof typeof lineHeight] ||
|
|
42
|
+
lineHeight.lineHeight24}px;
|
|
43
|
+
`}
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
export { Body }
|
package/components/Text/Text.tsx
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Body } from './Text.styles'
|
|
3
|
-
import { TextProps } from './Text.types'
|
|
4
|
-
|
|
5
|
-
const Text: React.FC<TextProps> = ({
|
|
6
|
-
align,
|
|
7
|
-
children,
|
|
8
|
-
color = '
|
|
9
|
-
isTitle = false,
|
|
10
|
-
tag = 'p',
|
|
11
|
-
size,
|
|
12
|
-
...rest
|
|
13
|
-
}) => {
|
|
14
|
-
return (
|
|
15
|
-
<Body
|
|
16
|
-
as={isTitle ? 'h2' : tag}
|
|
17
|
-
align={align}
|
|
18
|
-
color={color}
|
|
19
|
-
size={size}
|
|
20
|
-
isTitle={isTitle}
|
|
21
|
-
{...rest}>
|
|
22
|
-
{children}
|
|
23
|
-
</Body>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default Text
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Body } from './Text.styles'
|
|
3
|
+
import { TextProps } from './Text.types'
|
|
4
|
+
|
|
5
|
+
const Text: React.FC<TextProps> = ({
|
|
6
|
+
align,
|
|
7
|
+
children,
|
|
8
|
+
color = 'textDark',
|
|
9
|
+
isTitle = false,
|
|
10
|
+
tag = 'p',
|
|
11
|
+
size,
|
|
12
|
+
...rest
|
|
13
|
+
}) => {
|
|
14
|
+
return (
|
|
15
|
+
<Body
|
|
16
|
+
as={isTitle ? 'h2' : tag}
|
|
17
|
+
align={align}
|
|
18
|
+
color={color as string}
|
|
19
|
+
size={size}
|
|
20
|
+
isTitle={isTitle}
|
|
21
|
+
{...rest}>
|
|
22
|
+
{children}
|
|
23
|
+
</Body>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default Text
|
|
@@ -1,42 +1,44 @@
|
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
type WeightType = 'fontWeight400' | 'fontWeight500' | 'fontWeight600' | 'fontWeight700'
|
|
34
|
+
|
|
35
|
+
export interface TextProps {
|
|
36
|
+
align?: AlignType
|
|
37
|
+
children?: ReactNode
|
|
38
|
+
color?: colorType
|
|
39
|
+
isTitle?: boolean
|
|
40
|
+
tag?: TagType
|
|
41
|
+
size?: SizeType
|
|
42
|
+
weight?: WeightType
|
|
43
|
+
className?: string
|
|
44
|
+
}
|
package/components/Text/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from './Text'
|
|
1
|
+
export { default } from './Text'
|
|
@@ -1,58 +1,52 @@
|
|
|
1
|
-
import { fontSize, lineHeight, spacing } from '@liguelead/foundation'
|
|
2
|
-
|
|
3
|
-
export type TextFieldSize = 'sm' | 'md' | 'lg'
|
|
4
|
-
|
|
5
|
-
export type TextFieldSizeType = {
|
|
6
|
-
input: string
|
|
7
|
-
label: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const textFieldSizes = (size: TextFieldSize, leftIcon: boolean, rightIcon: boolean) => {
|
|
11
|
-
const withIconMargin = Number(spacing.spacing8) + 20
|
|
12
|
-
const withIconPadding = {
|
|
13
|
-
sm: Number(spacing.spacing12) + Number(withIconMargin),
|
|
14
|
-
md: Number(spacing.spacing16) + Number(withIconMargin),
|
|
15
|
-
lg: Number(spacing.spacing16) + Number(withIconMargin)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const sizes = {
|
|
19
|
-
sm: {
|
|
20
|
-
input: `
|
|
21
|
-
font-size: ${fontSize.fontSize14}px;
|
|
22
|
-
line-height: ${lineHeight.lineHeight22}px;
|
|
23
|
-
padding: ${spacing.spacing8}px ${spacing.spacing12}px;
|
|
24
|
-
padding-left: ${leftIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
25
|
-
padding-right: ${rightIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
26
|
-
`,
|
|
27
|
-
label: `font-size: ${fontSize.fontSize14}px
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
padding: ${
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return sizes[size]
|
|
58
|
-
}
|
|
1
|
+
import { fontSize, lineHeight, spacing } from '@liguelead/foundation'
|
|
2
|
+
|
|
3
|
+
export type TextFieldSize = 'sm' | 'md' | 'lg'
|
|
4
|
+
|
|
5
|
+
export type TextFieldSizeType = {
|
|
6
|
+
input: string
|
|
7
|
+
label: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const textFieldSizes = (size: TextFieldSize, leftIcon: boolean, rightIcon: boolean) => {
|
|
11
|
+
const withIconMargin = Number(spacing.spacing8) + 20
|
|
12
|
+
const withIconPadding = {
|
|
13
|
+
sm: Number(spacing.spacing12) + Number(withIconMargin),
|
|
14
|
+
md: Number(spacing.spacing16) + Number(withIconMargin),
|
|
15
|
+
lg: Number(spacing.spacing16) + Number(withIconMargin)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const sizes = {
|
|
19
|
+
sm: {
|
|
20
|
+
input: `
|
|
21
|
+
font-size: ${fontSize.fontSize14}px;
|
|
22
|
+
line-height: ${lineHeight.lineHeight22}px;
|
|
23
|
+
padding: ${spacing.spacing8}px ${spacing.spacing12}px;
|
|
24
|
+
padding-left: ${leftIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
25
|
+
padding-right: ${rightIcon ? withIconPadding.sm : spacing.spacing12}px;
|
|
26
|
+
`,
|
|
27
|
+
label: `font-size: ${fontSize.fontSize14}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
|
+
},
|
|
39
|
+
lg: {
|
|
40
|
+
input: `
|
|
41
|
+
font-size: ${fontSize.fontSize16}px;
|
|
42
|
+
line-height: ${lineHeight.lineHeight24}px;
|
|
43
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
44
|
+
padding-left: ${leftIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
45
|
+
padding-right: ${rightIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
46
|
+
`,
|
|
47
|
+
label: `font-size: ${fontSize.fontSize16}px;`
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return sizes[size]
|
|
52
|
+
}
|
|
@@ -1,76 +1,53 @@
|
|
|
1
|
-
import {parseColor} from '../../utils'
|
|
2
|
-
import {useTheme} from 'styled-components'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
&:focus
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
color: ${parseColor(theme.colors.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
label: `color: ${parseColor(theme.colors.neutral800)};`,
|
|
55
|
-
helperText: `color: ${parseColor(theme.colors.neutral700)};`,
|
|
56
|
-
animation: `
|
|
57
|
-
&:focus + label,
|
|
58
|
-
&:not(:placeholder-shown) + label {
|
|
59
|
-
top: 0px;
|
|
60
|
-
left: 12px;
|
|
61
|
-
font-size: ${fontSize.fontSize12}px;
|
|
62
|
-
}`
|
|
63
|
-
},
|
|
64
|
-
disabled: {
|
|
65
|
-
input: `
|
|
66
|
-
border: 1px solid ${parseColor(theme.colors.neutral500)};
|
|
67
|
-
color: ${parseColor(theme.colors.neutral600)};
|
|
68
|
-
`,
|
|
69
|
-
label: `color: ${parseColor(theme.colors.neutral500)};
|
|
70
|
-
background: transparent;`,
|
|
71
|
-
helperText: `color: ${parseColor(theme.colors.neutral500)};`,
|
|
72
|
-
animation: ``
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return states[state]
|
|
76
|
-
}
|
|
1
|
+
import { parseColor } from '../../utils'
|
|
2
|
+
import { useTheme } from 'styled-components'
|
|
3
|
+
import { shadow } from '@liguelead/foundation'
|
|
4
|
+
export interface StateInterface {
|
|
5
|
+
input: string
|
|
6
|
+
label?: string
|
|
7
|
+
helperText: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TextFieldStates {
|
|
11
|
+
error: StateInterface
|
|
12
|
+
default: StateInterface
|
|
13
|
+
disabled: StateInterface
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const TextFieldStates = (state: keyof TextFieldStates) => {
|
|
17
|
+
const theme = useTheme()
|
|
18
|
+
const states: TextFieldStates = {
|
|
19
|
+
error: {
|
|
20
|
+
input: `
|
|
21
|
+
border: 1px solid ${parseColor(theme.colors.danger200)};
|
|
22
|
+
color: ${parseColor(theme.colors.textDark)};
|
|
23
|
+
&:focus {
|
|
24
|
+
border-color: ${parseColor(theme.colors.danger200)};
|
|
25
|
+
box-shadow: ${shadow.errorShadow};
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
label: `color: ${parseColor(theme.colors.danger100)};`,
|
|
29
|
+
helperText: `color: ${parseColor(theme.colors.danger100)};`,
|
|
30
|
+
},
|
|
31
|
+
default: {
|
|
32
|
+
input: `
|
|
33
|
+
border: 1px solid ${parseColor(theme.colors.neutral400)};
|
|
34
|
+
color: ${parseColor(theme.colors.textDark)};
|
|
35
|
+
&:focus {
|
|
36
|
+
border-color: ${parseColor(theme.colors.neutral700)};
|
|
37
|
+
box-shadow: ${shadow.focusShadow};
|
|
38
|
+
}
|
|
39
|
+
`,
|
|
40
|
+
label: `color: ${parseColor(theme.colors.textDark)};`,
|
|
41
|
+
helperText: `color: ${parseColor(theme.colors.textMedium)};`,
|
|
42
|
+
},
|
|
43
|
+
disabled: {
|
|
44
|
+
input: `
|
|
45
|
+
color: ${parseColor(theme.colors.textDark)};
|
|
46
|
+
box-shadow: 0 1px 2px 0 #0000000D;
|
|
47
|
+
opacity: 0.5;
|
|
48
|
+
`,
|
|
49
|
+
helperText: `color: ${parseColor(theme.colors.neutral500)};`,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return states[state]
|
|
53
|
+
}
|