Skip to content

Commit 2ad33dc

Browse files
committed
style(component): structure for UI components
1 parent fc6e25c commit 2ad33dc

File tree

4 files changed

+174
-81
lines changed

4 files changed

+174
-81
lines changed

src/components/Shared/Heading/index.jsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ const Heading = (props) => {
66
const variants = {
77
h1: {
88
fontSize: {
9-
base: '48px',
10-
md: '68px',
9+
base: '32px',
10+
md: '42px',
1111
},
1212
lineHeight: {
13-
base: '48px',
14-
md: '68px',
13+
base: '38px',
14+
md: '50px',
1515
},
1616
},
1717
h2: {
1818
fontSize: {
19-
base: '42px',
20-
md: '54px',
19+
base: '26px',
20+
md: '32px',
2121
},
2222
lineHeight: {
23-
base: '42px',
24-
md: '54px',
23+
base: '32px',
24+
md: '38px',
2525
},
2626
},
2727
h3: {
@@ -38,6 +38,14 @@ const Heading = (props) => {
3838
fontSize: '20px',
3939
lineHeight: '26px',
4040
},
41+
h5: {
42+
fontSize: '18px',
43+
lineHeight: '24px',
44+
},
45+
h6: {
46+
fontSize: '16px',
47+
lineHeight: '22px',
48+
},
4149
};
4250

4351
return (

src/components/Shared/Input/index.jsx

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,65 @@
1-
import { Input as InputBox } from '@chakra-ui/react';
2-
import { style } from './style';
1+
import { Box, Input } from '@chakra-ui/react';
32

4-
const Input = (props) => {
5-
return <InputBox padding='20px' borderRadius='8px' {...props} {...style} />;
3+
import Text from 'src/components/Shared/Text';
4+
5+
const Component = (props) => {
6+
const { ref, iconLeft, disabled } = props;
7+
8+
const boxStyle = {
9+
overflow: 'hiddden',
10+
11+
display: 'flex',
12+
flexDirection: 'row',
13+
justifyContent: 'space-between',
14+
flex: 1,
15+
width: '100%',
16+
17+
backgroundColor: 'gray5',
18+
borderRadius: '10px',
19+
borderWidth: '1px',
20+
borderColor: 'gray5',
21+
22+
color: 'text',
23+
};
24+
25+
const iconLeftStyle = {
26+
display: 'flex',
27+
justifyContent: 'center',
28+
alignItems: 'center',
29+
height: '100%',
30+
minHeight: '60px',
31+
32+
padding: '0 20px',
33+
34+
borderRight: '1px solid gray5',
35+
};
36+
37+
const inputStyle = {
38+
width: '100%',
39+
minHeight: '60px',
40+
41+
padding: '14px 18px',
42+
43+
backgroundColor: 'transparent',
44+
borderRadius: iconLeft ? '0 10px 10px 0' : '10px',
45+
46+
fontSize: '16px',
47+
48+
_placeholder: {
49+
color: 'gray35',
50+
},
51+
};
52+
53+
return (
54+
<Box {...boxStyle}>
55+
{iconLeft && (
56+
<Box {...iconLeftStyle}>
57+
<Text size='small'>{iconLeft}</Text>
58+
</Box>
59+
)}
60+
<Input ref={ref} tabIndex={disabled ? -1 : 1} {...inputStyle} {...props} />
61+
</Box>
62+
);
663
};
764

8-
export default Input;
65+
export default Component;

src/components/Shared/Link/index.jsx

Lines changed: 78 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,97 @@
11
import NextLink from 'next/link';
2-
import { Text } from '@chakra-ui/react';
2+
import { Link } from '@chakra-ui/react';
33

4-
const Link = (props) => {
5-
const { children, isBlock, color = 'primary', size = 'md' } = props;
4+
const Component = (props) => {
5+
const { children, brand = 'primary', size = 'large', type = 'filled' } = props;
6+
7+
const isLarge = size === 'large';
8+
const isSolid = type === 'filled';
9+
10+
const dimensions = {
11+
height: '30px',
12+
largeHeight: '60px',
13+
minWidth: '30px',
14+
largeMinWidth: '200px',
15+
};
16+
17+
const style = {
18+
display: 'flex',
19+
alignItems: 'center',
20+
justifyContent: 'center',
21+
height: isLarge ? dimensions.largeHeight : dimensions.height,
22+
minWidth: isLarge ? dimensions.largeMinWidth : dimensions.minWidth,
23+
width: { base: '100%', md: 'initial' },
24+
25+
padding: '18px 12px',
26+
27+
borderRadius: '8px',
28+
29+
color: isSolid ? 'background' : brand,
30+
fontSize: isLarge ? '16px' : '14px',
31+
fontWeight: 700,
32+
textAlign: 'center',
33+
34+
_hover: {
35+
textDecoration: 'none',
36+
},
37+
};
638

739
const variants = {
8-
primary: {
9-
height: size === 'md' ? '60px' : '40px',
10-
padding: size === 'md' ? '22px' : '16px',
11-
backgroundColor: '#B3E0B8',
12-
border: '2px solid #B3E0B8',
13-
color: '#141318',
14-
fontSize: size === 'md' ? '16px' : '14px',
40+
filled: {
41+
backgroundColor: brand,
42+
1543
_hover: {
16-
backgroundColor: '#8FD196',
17-
textDecoration: 'none',
44+
opacity: 0.85,
45+
backgroundColor: brand,
46+
},
47+
_active: {
48+
opacity: 0.65,
49+
backgroundColor: brand,
50+
},
51+
},
52+
bezeled: {
53+
backgroundColor: `${brand}15`,
54+
55+
_hover: {
56+
opacity: 0.85,
57+
backgroundColor: `${brand}15`,
58+
},
59+
_active: {
60+
opacity: 0.65,
61+
backgroundColor: `${brand}15`,
1862
},
1963
},
20-
default: {
21-
height: size === 'md' ? '60px' : '30px',
22-
padding: size === 'md' ? '22px' : '8px',
23-
backgroundColor: '#111111',
24-
border: '2px solid #2C2C2C',
25-
color: '#fff',
26-
fontSize: size === 'md' ? '16px' : '14px',
64+
bezeledGray: {
65+
backgroundColor: 'gray5',
66+
2767
_hover: {
28-
backgroundColor: '#2C2C2C',
29-
textDecoration: 'none',
68+
opacity: 0.85,
69+
backgroundColor: 'gray5',
70+
},
71+
_active: {
72+
opacity: 0.65,
73+
backgroundColor: 'gray5',
3074
},
3175
},
32-
terciary: {
33-
height: size === 'md' ? '60px' : '30px',
34-
padding: size === 'md' ? '18px' : '8px',
35-
backgroundColor: '#DBA2A3',
36-
border: '1px solid #DBA2A3',
37-
color: '#141318',
38-
fontSize: size === 'md' ? '16px' : '14px',
76+
borderless: {
77+
backgroundColor: 'transparent',
78+
3979
_hover: {
40-
backgroundColor: '#CD7E80',
41-
textDecoration: 'none',
80+
opacity: 0.85,
81+
backgroundColor: 'transparent',
82+
},
83+
_active: {
84+
opacity: 0.65,
85+
backgroundColor: 'transparent',
4286
},
4387
},
4488
};
4589

4690
return (
47-
<NextLink {...props} passHref>
48-
<Text
49-
display='flex'
50-
justifyContent='center'
51-
alignItems='center'
52-
borderRadius='0'
53-
fontWeight={600}
54-
width='100%'
55-
{...variants[color]}
56-
>
57-
{children}
58-
</Text>
59-
</NextLink>
91+
<Link as={NextLink} {...props} {...style} {...variants[type]} passHref>
92+
{children}
93+
</Link>
6094
);
6195
};
6296

63-
export default Link;
97+
export default Component;

src/components/Shared/Text/index.jsx

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
import { Text as TextBox } from '@chakra-ui/react';
1+
import { Text } from '@chakra-ui/react';
22

3-
const Text = (props) => {
4-
const { children, size = 'md' } = props;
3+
const Component = (props) => {
4+
const { children, size = 'medium', opacity = 100, isBold = false, align = 'left' } = props;
55

6-
const variants = {
7-
xl: {
8-
fontSize: '36px',
9-
lineHeight: '46px',
10-
},
11-
lg: {
12-
fontSize: '24px',
13-
lineHeight: '34px',
14-
},
15-
md: {
16-
fontSize: '16px',
17-
lineHeight: '22px',
18-
},
19-
sm: {
20-
opacity: 0.65,
21-
fontSize: '12px',
22-
lineHeight: '18px',
23-
},
6+
const isSmall = size === 'small';
7+
8+
const style = {
9+
opacity,
10+
11+
margin: 0,
12+
13+
color: 'text',
14+
fontSize: `${isSmall ? 14 : 16}px`,
15+
lineHeight: `${isSmall ? 20 : 22}px`,
16+
fontWeight: isBold ? 700 : 400,
17+
textAlign: align,
2418
};
2519

2620
return (
27-
<TextBox m='0px' color='#fff' {...props} {...variants[size]}>
21+
<Text {...style} {...props}>
2822
{children}
29-
</TextBox>
23+
</Text>
3024
);
3125
};
3226

33-
export default Text;
27+
export default Component;

0 commit comments

Comments
 (0)