@liguelead/design-system 0.0.1
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 +62 -0
- package/components/Button/Button.sizes.ts +41 -0
- package/components/Button/Button.styles.ts +50 -0
- package/components/Button/Button.tsx +70 -0
- package/components/Button/Button.types.ts +22 -0
- package/components/Button/index.ts +1 -0
- package/components/IconButton/IconButton.sizes.ts +41 -0
- package/components/IconButton/IconButton.tsx +67 -0
- package/components/IconButton/index.ts +1 -0
- package/components/PageWrapper/PageWrapper.tsx +31 -0
- package/components/PageWrapper/index.ts +1 -0
- package/components/Text/Text.styles.ts +43 -0
- package/components/Text/Text.tsx +65 -0
- package/components/Text/index.ts +1 -0
- package/components/TextField/TextField.sizes.ts +58 -0
- package/components/TextField/TextField.states.tsx +76 -0
- package/components/TextField/TextField.styles.ts +98 -0
- package/components/TextField/TextField.tsx +87 -0
- package/components/TextField/TextField.types.ts +21 -0
- package/components/TextField/index.ts +2 -0
- package/components/ThemeProvider/ThemeProvider.tsx +30 -0
- package/components/ThemeProvider/index.ts +1 -0
- package/components/ThemeProvider/style.ts +200 -0
- package/components/Wizard/StepContent.tsx +28 -0
- package/components/Wizard/StepMenuItem.tsx +33 -0
- package/components/Wizard/Wizard.context.tsx +76 -0
- package/components/Wizard/Wizard.styles.ts +126 -0
- package/components/Wizard/Wizard.tsx +55 -0
- package/components/Wizard/index.ts +1 -0
- package/components/index.ts +7 -0
- package/package.json +32 -0
- package/utils/colorDarken.ts +10 -0
- package/utils/colorLighten.ts +10 -0
- package/utils/darkenOrLighen.ts +19 -0
- package/utils/getTextColor.ts +12 -0
- package/utils/index.ts +5 -0
- package/utils/parseColor.ts +7 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {ButtonAppearanceTypes} from './Button.types'
|
|
2
|
+
import {colorType} from 'types'
|
|
3
|
+
import {useTheme} from 'styled-components'
|
|
4
|
+
import {darkenOrLighten, getTextColor, parseColor} from '../../utils'
|
|
5
|
+
|
|
6
|
+
export const ButtonAppearance = (
|
|
7
|
+
color: colorType,
|
|
8
|
+
appearance: ButtonAppearanceTypes
|
|
9
|
+
) => {
|
|
10
|
+
const theme = useTheme()
|
|
11
|
+
const parsedColor = parseColor(theme.colors[color])
|
|
12
|
+
|
|
13
|
+
const solidtextColor = parseColor(theme.colors[getTextColor(parsedColor)])
|
|
14
|
+
|
|
15
|
+
const colorHover = darkenOrLighten(0.2, parsedColor)
|
|
16
|
+
|
|
17
|
+
const appearances = {
|
|
18
|
+
solid: `
|
|
19
|
+
background-color: ${parsedColor};
|
|
20
|
+
color: ${solidtextColor};
|
|
21
|
+
border: 1px solid ${parsedColor};
|
|
22
|
+
&:hover {
|
|
23
|
+
background-color: ${colorHover};
|
|
24
|
+
border-color: ${colorHover};
|
|
25
|
+
}
|
|
26
|
+
&:disabled {
|
|
27
|
+
background-color: ${parseColor(theme.colors.neutral200)};
|
|
28
|
+
color: ${parseColor(theme.colors.neutral500)};
|
|
29
|
+
border-color: ${parseColor(theme.colors.neutral200)};
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
outline: `
|
|
33
|
+
background-color: transparent;
|
|
34
|
+
color: ${parsedColor};
|
|
35
|
+
border: 1px solid ${parsedColor};
|
|
36
|
+
&:hover {
|
|
37
|
+
background-color: ${parsedColor};
|
|
38
|
+
border-color: ${parsedColor};
|
|
39
|
+
color: white;
|
|
40
|
+
}
|
|
41
|
+
&:disabled {
|
|
42
|
+
background-color: transparent;
|
|
43
|
+
color: ${parseColor(theme.colors.neutral500)};
|
|
44
|
+
border-color: ${parseColor(theme.colors.neutral500)};
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
ghost: `
|
|
48
|
+
background-color: transparent;
|
|
49
|
+
color: ${parsedColor};
|
|
50
|
+
border: 1px solid transparent;
|
|
51
|
+
&:hover {
|
|
52
|
+
background-color: rgba(0,0,0,0.05)
|
|
53
|
+
}
|
|
54
|
+
&:disabled {
|
|
55
|
+
background-color: transparent;
|
|
56
|
+
color: ${parseColor(theme.colors.neutral500)};
|
|
57
|
+
}
|
|
58
|
+
`
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return appearances[appearance]
|
|
62
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { fontSize, fontWeight, lineHeight, spacing } from '@liguelead/foundation'
|
|
2
|
+
import { ButtonSizeTypes } from './Button.types'
|
|
3
|
+
|
|
4
|
+
export const ButtonSizes = (size: ButtonSizeTypes) => {
|
|
5
|
+
const sizes = {
|
|
6
|
+
xs: `
|
|
7
|
+
padding: ${spacing.spacing4}px ${spacing.spacing8}px;
|
|
8
|
+
font-size: ${fontSize.fontSize10}px;
|
|
9
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
10
|
+
line-height: ${lineHeight.lineHeight14}px;
|
|
11
|
+
gap: ${spacing.spacing8}px;
|
|
12
|
+
border-radius: ${spacing.spacing4}px;
|
|
13
|
+
`,
|
|
14
|
+
sm: `
|
|
15
|
+
padding: ${spacing.spacing8}px ${spacing.spacing12}px;
|
|
16
|
+
font-size: ${fontSize.fontSize14}px;
|
|
17
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
18
|
+
line-height: ${lineHeight.lineHeight22}px;
|
|
19
|
+
gap: ${spacing.spacing8}px;
|
|
20
|
+
border-radius: ${spacing.spacing4}px;
|
|
21
|
+
`,
|
|
22
|
+
md: `
|
|
23
|
+
padding: ${spacing.spacing12}px ${spacing.spacing20}px;
|
|
24
|
+
font-size: ${fontSize.fontSize14}px;
|
|
25
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
26
|
+
line-height: ${lineHeight.lineHeight22}px;
|
|
27
|
+
gap: ${spacing.spacing8}px;
|
|
28
|
+
border-radius: ${spacing.spacing4}px;
|
|
29
|
+
`,
|
|
30
|
+
lg: `
|
|
31
|
+
padding: ${spacing.spacing16}px ${spacing.spacing24}px;
|
|
32
|
+
font-size: ${fontSize.fontSize16}px;
|
|
33
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
34
|
+
line-height: ${lineHeight.lineHeight24}px;
|
|
35
|
+
gap: ${spacing.spacing8}px;
|
|
36
|
+
border-radius: ${spacing.spacing4}px;
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return sizes[size]
|
|
41
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import { ButtonProps } from './Button.types'
|
|
3
|
+
|
|
4
|
+
interface StyledButtonProps extends ButtonProps {
|
|
5
|
+
$appearance: string
|
|
6
|
+
$buttonSize: string
|
|
7
|
+
$fluid: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const StyledButton = styled.button<StyledButtonProps>`
|
|
11
|
+
position: relative;
|
|
12
|
+
display: flex;
|
|
13
|
+
outline: none !important;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
16
|
+
width: ${({ $fluid }) => ($fluid ? '100%' : 'auto')};
|
|
17
|
+
${({ $buttonSize }) => $buttonSize}
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
outline: none;
|
|
21
|
+
transition: background-color 0.3s, box-shadow 0.3s;
|
|
22
|
+
${({ $appearance }) => $appearance}
|
|
23
|
+
|
|
24
|
+
&:focus {
|
|
25
|
+
outline: none;
|
|
26
|
+
box-shadow: 0px 0px 0px var(--2, 2px) rgba(255, 255, 255, 0.1),
|
|
27
|
+
0px 0px 0px var(--4, 4px) rgba(255, 255, 255, 0.1);
|
|
28
|
+
}
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export const RippleContainer = styled.span<{
|
|
32
|
+
appearance: string
|
|
33
|
+
}>`
|
|
34
|
+
position: absolute;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
transform: scale(0);
|
|
37
|
+
animation: ripple 0.4s linear;
|
|
38
|
+
background-color: ${({ appearance }) =>
|
|
39
|
+
appearance === 'solid'
|
|
40
|
+
? 'rgba(255, 255, 255, 0.5)'
|
|
41
|
+
: 'rgba(0, 0, 0, 0.2)'};
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
|
|
44
|
+
@keyframes ripple {
|
|
45
|
+
to {
|
|
46
|
+
transform: scale(9);
|
|
47
|
+
opacity: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { StyledButton, RippleContainer } from './Button.styles'
|
|
4
|
+
import { RippleInterface, ButtonProps } from './Button.types'
|
|
5
|
+
import { ButtonSizes } from './Button.sizes'
|
|
6
|
+
import { ButtonAppearance } from './Button.appearance';
|
|
7
|
+
|
|
8
|
+
const Button: React.FC<ButtonProps> = ({
|
|
9
|
+
appearance = "solid",
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
color = "primary",
|
|
13
|
+
disabled,
|
|
14
|
+
fluid = false,
|
|
15
|
+
size = "md",
|
|
16
|
+
onClick,
|
|
17
|
+
type = "button",
|
|
18
|
+
...rest
|
|
19
|
+
}) => {
|
|
20
|
+
|
|
21
|
+
const [ripples, setRipples] = useState<RippleInterface[]>([]);
|
|
22
|
+
|
|
23
|
+
const buttonSize = ButtonSizes(size)
|
|
24
|
+
const buttonAppearance = ButtonAppearance(color, appearance)
|
|
25
|
+
|
|
26
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
27
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
28
|
+
const x = e.clientX - rect.left;
|
|
29
|
+
const y = e.clientY - rect.top;
|
|
30
|
+
|
|
31
|
+
const newRipple: RippleInterface = { id: `${Date.now()}-${Math.random()}`, x, y };
|
|
32
|
+
setRipples((prev) => [...prev, newRipple]);
|
|
33
|
+
|
|
34
|
+
// Chama o onClick fornecido
|
|
35
|
+
if (onClick) {
|
|
36
|
+
onClick(e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<StyledButton
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
className={className}
|
|
44
|
+
$fluid={fluid}
|
|
45
|
+
$appearance={buttonAppearance}
|
|
46
|
+
onClick={handleClick}
|
|
47
|
+
$buttonSize={buttonSize}
|
|
48
|
+
type={type}
|
|
49
|
+
{...rest}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
{ripples.map((ripple) => (
|
|
53
|
+
<RippleContainer appearance={appearance}
|
|
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 Button;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {colorType} from 'types'
|
|
2
|
+
|
|
3
|
+
export type ButtonSizeTypes = 'xs' | 'sm' | 'md' | 'lg'
|
|
4
|
+
export type ButtonAppearanceTypes = 'solid' | 'outline' | 'ghost'
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps {
|
|
7
|
+
appearance?: ButtonAppearanceTypes
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
className?: string
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
fluid?: boolean
|
|
12
|
+
size?: ButtonSizeTypes
|
|
13
|
+
color?: colorType
|
|
14
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
15
|
+
type?: 'button' | 'submit' | 'reset'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RippleInterface {
|
|
19
|
+
id: string
|
|
20
|
+
x: number
|
|
21
|
+
y: number
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Button'
|
|
@@ -0,0 +1,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
|
+
xs: `
|
|
7
|
+
padding: ${spacing.spacing8}px ${spacing.spacing8}px;
|
|
8
|
+
border-radius: ${spacing.spacing4}px;
|
|
9
|
+
& svg {
|
|
10
|
+
width: ${spacing.spacing12}px !important;
|
|
11
|
+
height: ${spacing.spacing12}px;
|
|
12
|
+
}
|
|
13
|
+
`,
|
|
14
|
+
sm: `
|
|
15
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
16
|
+
border-radius: ${spacing.spacing4}px;
|
|
17
|
+
& svg {
|
|
18
|
+
width: ${spacing.spacing16}px !important;
|
|
19
|
+
height: ${spacing.spacing16}px;
|
|
20
|
+
}
|
|
21
|
+
`,
|
|
22
|
+
md: `
|
|
23
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
24
|
+
border-radius: ${spacing.spacing4}px;
|
|
25
|
+
& svg {
|
|
26
|
+
width: ${spacing.spacing20}px;
|
|
27
|
+
height: ${spacing.spacing20}px;
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
lg: `
|
|
31
|
+
padding: ${spacing.spacing12}px ${spacing.spacing12}px;
|
|
32
|
+
border-radius: ${spacing.spacing4}px;
|
|
33
|
+
& svg {
|
|
34
|
+
width: ${spacing.spacing32}px;
|
|
35
|
+
height: ${spacing.spacing32}px;
|
|
36
|
+
}
|
|
37
|
+
`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return sizes[size]
|
|
41
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { ButtonProps, RippleInterface } from "../Button/Button.types";
|
|
3
|
+
import { ButtonAppearance } 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
|
+
appearance = "solid",
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
color ="primary",
|
|
12
|
+
disabled,
|
|
13
|
+
fluid = false,
|
|
14
|
+
size = "md",
|
|
15
|
+
onClick,
|
|
16
|
+
...rest
|
|
17
|
+
}) => {
|
|
18
|
+
|
|
19
|
+
const [ripples, setRipples] = useState<RippleInterface[]>([]);
|
|
20
|
+
|
|
21
|
+
const buttonSize = IconButtonSizes(size)
|
|
22
|
+
const buttonAppearance = ButtonAppearance(color, appearance)
|
|
23
|
+
|
|
24
|
+
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
25
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
26
|
+
const x = e.clientX - rect.left;
|
|
27
|
+
const y = e.clientY - rect.top;
|
|
28
|
+
|
|
29
|
+
const newRipple: RippleInterface = { id: `${Date.now()}-${Math.random()}`, x, y };
|
|
30
|
+
setRipples((prev) => [...prev, newRipple]);
|
|
31
|
+
|
|
32
|
+
// Chama o onClick fornecido
|
|
33
|
+
if (onClick) {
|
|
34
|
+
onClick(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<StyledButton
|
|
40
|
+
disabled={disabled}
|
|
41
|
+
className={className}
|
|
42
|
+
$fluid={fluid}
|
|
43
|
+
$appearance={buttonAppearance}
|
|
44
|
+
onClick={handleClick}
|
|
45
|
+
$buttonSize={buttonSize}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
{ripples.map((ripple) => (
|
|
50
|
+
<RippleContainer appearance={appearance}
|
|
51
|
+
key={ripple.id}
|
|
52
|
+
style={{
|
|
53
|
+
top: ripple.y - 10,
|
|
54
|
+
left: ripple.x - 10,
|
|
55
|
+
width: 20,
|
|
56
|
+
height: 20,
|
|
57
|
+
}}
|
|
58
|
+
onAnimationEnd={() =>
|
|
59
|
+
setRipples((prev) => prev.filter((r) => r.id !== ripple.id))
|
|
60
|
+
}
|
|
61
|
+
/>
|
|
62
|
+
))}
|
|
63
|
+
</StyledButton>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default IconButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './IconButton'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {parseColor} from '../../utils'
|
|
2
|
+
import styled from 'styled-components'
|
|
3
|
+
import {colorType} from 'types'
|
|
4
|
+
import {spacing, SpacingInterface} from '@liguelead/foundation'
|
|
5
|
+
|
|
6
|
+
type SpacingType = keyof SpacingInterface
|
|
7
|
+
|
|
8
|
+
interface WrapperProps {
|
|
9
|
+
width?: string
|
|
10
|
+
bgColor?: colorType
|
|
11
|
+
padding?: SpacingType
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const PageWrapper = styled.div.withConfig({
|
|
15
|
+
shouldForwardProp: prop => !['bgColor', 'width', 'padding'].includes(prop)
|
|
16
|
+
})<WrapperProps>`
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
max-width: ${({width}) => width + 'px' || '100%'};
|
|
20
|
+
margin: 0 auto;
|
|
21
|
+
padding: ${({padding}) =>
|
|
22
|
+
padding ? spacing[padding] + 'px' : spacing.spacing16 + 'px'};
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
background: ${({bgColor, theme}) =>
|
|
25
|
+
bgColor
|
|
26
|
+
? parseColor(theme.colors[bgColor])
|
|
27
|
+
: parseColor(theme.colors.white)};
|
|
28
|
+
border: 1px solid ${({theme}) => parseColor(theme.colors.neutral300)};
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export default PageWrapper
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './PageWrapper'
|
|
@@ -0,0 +1,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'
|
|
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 = 'neutral800',
|
|
24
|
+
isTitle = false,
|
|
25
|
+
theme,
|
|
26
|
+
size = 'body01'
|
|
27
|
+
}) => css`
|
|
28
|
+
text-align: ${align};
|
|
29
|
+
color: ${parseColor(theme.colors[color] || theme.colors.neutral800)};
|
|
30
|
+
font-family: '${isTitle
|
|
31
|
+
? fontFamily[theme.fonts.headings]
|
|
32
|
+
: fontFamily[theme.fonts.default]}',
|
|
33
|
+
sans-serif;
|
|
34
|
+
font-weight: ${fontWeight[theme.typography[size]?.fontWeight] ||
|
|
35
|
+
'normal'};
|
|
36
|
+
font-size: ${fontSize[theme.typography[size]?.fontSize] ||
|
|
37
|
+
fontSize.fontSize16}px;
|
|
38
|
+
line-height: ${lineHeight[theme.typography[size]?.lineHeight] ||
|
|
39
|
+
lineHeight.lineHeight24}px;
|
|
40
|
+
`}
|
|
41
|
+
`
|
|
42
|
+
|
|
43
|
+
export {Body}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {Body} from './Text.styles'
|
|
3
|
+
import {colorType} from 'types'
|
|
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
|
+
}
|
|
42
|
+
|
|
43
|
+
const Text: React.FC<TextProps> = ({
|
|
44
|
+
align,
|
|
45
|
+
children,
|
|
46
|
+
color = 'neutral1000',
|
|
47
|
+
isTitle,
|
|
48
|
+
tag = 'p',
|
|
49
|
+
size,
|
|
50
|
+
...rest
|
|
51
|
+
}) => {
|
|
52
|
+
return (
|
|
53
|
+
<Body
|
|
54
|
+
as={tag}
|
|
55
|
+
align={align}
|
|
56
|
+
color={color}
|
|
57
|
+
size={size}
|
|
58
|
+
isTitle={isTitle}
|
|
59
|
+
{...rest}>
|
|
60
|
+
{children}
|
|
61
|
+
</Body>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default Text
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Text'
|
|
@@ -0,0 +1,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
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
29
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
30
|
+
},
|
|
31
|
+
md: {
|
|
32
|
+
input: `
|
|
33
|
+
font-size: ${fontSize.fontSize14}px;
|
|
34
|
+
line-height: ${lineHeight.lineHeight20}px;
|
|
35
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
36
|
+
padding-left: ${leftIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
37
|
+
padding-right: ${rightIcon ? withIconPadding.md : spacing.spacing16}px;
|
|
38
|
+
`,
|
|
39
|
+
label: `font-size: ${fontSize.fontSize14}px;
|
|
40
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
41
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
42
|
+
},
|
|
43
|
+
lg: {
|
|
44
|
+
input: `
|
|
45
|
+
font-size: ${fontSize.fontSize16}px;
|
|
46
|
+
line-height: ${lineHeight.lineHeight24}px;
|
|
47
|
+
padding: ${spacing.spacing12}px ${spacing.spacing16}px;
|
|
48
|
+
padding-left: ${leftIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
49
|
+
padding-right: ${rightIcon ? withIconPadding.lg : spacing.spacing16}px;
|
|
50
|
+
`,
|
|
51
|
+
label: `font-size: ${fontSize.fontSize16}px;
|
|
52
|
+
margin-left: ${leftIcon ? withIconMargin : 0}px;
|
|
53
|
+
margin-right: ${rightIcon ? withIconMargin : 0}px;`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return sizes[size]
|
|
58
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {parseColor} from '../../utils'
|
|
2
|
+
import {useTheme} from 'styled-components'
|
|
3
|
+
import {fontWeight, fontSize} from '@liguelead/foundation'
|
|
4
|
+
|
|
5
|
+
export interface StateInterface {
|
|
6
|
+
input: string
|
|
7
|
+
label: string
|
|
8
|
+
helperText: string
|
|
9
|
+
animation?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface TextFieldStates {
|
|
13
|
+
error: StateInterface
|
|
14
|
+
default: StateInterface
|
|
15
|
+
disabled: StateInterface
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const TextFieldStates = (state: keyof TextFieldStates) => {
|
|
19
|
+
const theme = useTheme()
|
|
20
|
+
const states: TextFieldStates = {
|
|
21
|
+
error: {
|
|
22
|
+
input: `
|
|
23
|
+
border: 1px solid ${parseColor(theme.colors.danger100)};
|
|
24
|
+
color: ${parseColor(theme.colors.neutral1000)};
|
|
25
|
+
&:focus {
|
|
26
|
+
border-color: ${parseColor(theme.colors.danger100)};
|
|
27
|
+
}
|
|
28
|
+
&:focus + label {
|
|
29
|
+
color: ${parseColor(theme.colors.danger100)};
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
label: `color: ${parseColor(theme.colors.danger100)};`,
|
|
33
|
+
helperText: `color: ${parseColor(theme.colors.danger100)};`,
|
|
34
|
+
animation: `
|
|
35
|
+
&:focus + label,
|
|
36
|
+
&:not(:placeholder-shown) + label {
|
|
37
|
+
top: 0px;
|
|
38
|
+
left: 12px;
|
|
39
|
+
font-size: ${fontSize.fontSize12}px;
|
|
40
|
+
}`
|
|
41
|
+
},
|
|
42
|
+
default: {
|
|
43
|
+
input: `
|
|
44
|
+
border: 1px solid ${parseColor(theme.colors.neutral700)};
|
|
45
|
+
color: ${parseColor(theme.colors.neutral1000)};
|
|
46
|
+
&:focus {
|
|
47
|
+
border-color: ${parseColor(theme.colors.primary)};
|
|
48
|
+
}
|
|
49
|
+
&:focus + label {
|
|
50
|
+
color: ${parseColor(theme.colors.primary)};
|
|
51
|
+
font-weight: ${fontWeight.fontWeight600};
|
|
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
|
+
}
|