Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit d2c3e23

Browse files
committed
refactor: space component
1 parent b0a14ca commit d2c3e23

File tree

4 files changed

+43
-65
lines changed

4 files changed

+43
-65
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
indent_style = tab
9+
indent_size = 3
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

@types/cherry.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ interface MinHeightProps {
191191

192192
interface SpaceProps {
193193
size?: number;
194-
xsSize?: number;
195-
smSize?: number;
196-
mdSize?: number;
197-
lgSize?: number;
198-
xlSize?: number;
199-
xxlSize?: number;
200-
xxxlSize?: number;
194+
xs?: number;
195+
sm?: number;
196+
md?: number;
197+
lg?: number;
198+
xl?: number;
199+
xxl?: number;
200+
xxxl?: number;
201201
horizontal?: number;
202202
}
203203

src/Layout/Space/Space.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
import React from "react";
22
import { spaceStyles } from "./Space.styles";
33

4-
function Space({
5-
size,
6-
xsSize,
7-
smSize,
8-
mdSize,
9-
lgSize,
10-
xlSize,
11-
xxlSize,
12-
xxxlSize,
13-
horizontal,
14-
}) {
4+
function Space({ size, xs, sm, md, lg, xl, xxl, xxxl, horizontal }) {
155
return (
166
<div
17-
css={spaceStyles(
18-
size,
19-
xsSize,
20-
smSize,
21-
mdSize,
22-
lgSize,
23-
xlSize,
24-
xxlSize,
25-
xxxlSize,
26-
horizontal,
27-
)}
7+
css={spaceStyles(size, xs, sm, md, lg, xl, xxl, xxxl, horizontal)}
288
/>
299
);
3010
}

src/Layout/Space/Space.styles.js

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,7 @@ const localStyle = (size, horizontal) =>
1313
height: ${size}px;
1414
`;
1515

16-
const spaceStyles = (
17-
size,
18-
xsSize,
19-
smSize,
20-
mdSize,
21-
lgSize,
22-
xlSize,
23-
xxlSize,
24-
xxxlSize,
25-
horizontal,
26-
) => css`
16+
const spaceStyles = (size, xs, sm, md, lg, xl, xxl, xxxl, horizontal) => css`
2717
${size &&
2818
css`
2919
${horizontal ? localStyle(size, true) : localStyle(size, false)}
@@ -34,102 +24,98 @@ const spaceStyles = (
3424
display: none;
3525
`}
3626
37-
${xsSize &&
27+
${xs &&
3828
css`
3929
${mq(Breakpoints.xs)} {
40-
${horizontal ? localStyle(xsSize, true) : localStyle(xsSize, false)}
30+
${horizontal ? localStyle(xs, true) : localStyle(xs, false)}
4131
}
4232
`}
4333
44-
${xsSize === "none" &&
34+
${xs === "none" &&
4535
css`
4636
${mq(Breakpoints.xs)} {
4737
display: none;
4838
}
4939
`}
5040
51-
${smSize &&
41+
${sm &&
5242
css`
5343
${mq(Breakpoints.sm)} {
54-
${horizontal ? localStyle(smSize, true) : localStyle(smSize, false)}
44+
${horizontal ? localStyle(sm, true) : localStyle(sm, false)}
5545
}
5646
`}
5747
58-
${smSize === "none" &&
48+
${sm === "none" &&
5949
css`
6050
${mq(Breakpoints.sm)} {
6151
display: none;
6252
}
6353
`}
6454
65-
${mdSize &&
55+
${md &&
6656
css`
6757
${mq(Breakpoints.md)} {
68-
${horizontal ? localStyle(mdSize, true) : localStyle(mdSize, false)}
58+
${horizontal ? localStyle(md, true) : localStyle(md, false)}
6959
}
7060
`}
7161
72-
${mdSize === "none" &&
62+
${md === "none" &&
7363
css`
7464
${mq(Breakpoints.md)} {
7565
display: none;
7666
}
7767
`}
7868
79-
${lgSize &&
69+
${lg &&
8070
css`
8171
${mq(Breakpoints.lg)} {
82-
${horizontal ? localStyle(lgSize, true) : localStyle(lgSize, false)}
72+
${horizontal ? localStyle(lg, true) : localStyle(lg, false)}
8373
}
8474
`}
8575
86-
${lgSize === "none" &&
76+
${lg === "none" &&
8777
css`
8878
${mq(Breakpoints.lg)} {
8979
display: none;
9080
}
9181
`}
9282
93-
${xlSize &&
83+
${xl &&
9484
css`
9585
${mq(Breakpoints.xl)} {
96-
${horizontal ? localStyle(xlSize, true) : localStyle(xlSize, false)}
86+
${horizontal ? localStyle(xl, true) : localStyle(xl, false)}
9787
}
9888
`}
9989
100-
${xlSize === "none" &&
90+
${xl === "none" &&
10191
css`
10292
${mq(Breakpoints.xl)} {
10393
display: none;
10494
}
10595
`}
10696
107-
${xxlSize &&
97+
${xxl &&
10898
css`
10999
${mq(Breakpoints.xxl)} {
110-
${horizontal
111-
? localStyle(xxlSize, true)
112-
: localStyle(xxlSize, false)}
100+
${horizontal ? localStyle(xxl, true) : localStyle(xxl, false)}
113101
}
114102
`}
115103
116-
${xxlSize === "none" &&
104+
${xxl === "none" &&
117105
css`
118106
${mq(Breakpoints.xxl)} {
119107
display: none;
120108
}
121109
`}
122110
123-
${xxxlSize &&
111+
${xxxl &&
124112
css`
125113
${mq(Breakpoints.xxxl)} {
126-
${horizontal
127-
? localStyle(xxxlSize, true)
128-
: localStyle(xxxlSize, false)}
114+
${horizontal ? localStyle(xxxl, true) : localStyle(xxxl, false)}
129115
}
130116
`}
131117
132-
${xxxlSize === "none" &&
118+
${xxxl === "none" &&
133119
css`
134120
${mq(Breakpoints.xxxl)} {
135121
display: none;

0 commit comments

Comments
 (0)