Skip to content

Commit 9806e1b

Browse files
committed
Refactor Box to use styled components
1 parent 46dc72e commit 9806e1b

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/components/Box/Box.scss

Whitespace-only changes.

src/components/Box/Box.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./Box.scss";
1+
import { StyledBox } from "./styles";
22

33
interface BoxProps {
44
flow?: "horizontal" | "vertical";
@@ -11,19 +11,9 @@ function Box({
1111
children,
1212
}: React.PropsWithChildren<BoxProps>) {
1313
return (
14-
<div
15-
className="box"
16-
style={{
17-
display: "flex",
18-
alignItems: "center",
19-
flexDirection: flow == "horizontal" ? "row" : "column",
20-
gap,
21-
padding: gap,
22-
boxSizing: "border-box",
23-
}}
24-
>
14+
<StyledBox flow={flow} gap={gap}>
2515
{children}
26-
</div>
16+
</StyledBox>
2717
);
2818
}
2919

src/components/Box/styles.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import styled from "@emotion/styled";
2+
3+
interface StyledBoxProps {
4+
flow?: "horizontal" | "vertical";
5+
gap?: number;
6+
}
7+
8+
export const StyledBox = styled.div<StyledBoxProps>`
9+
display: "flex";
10+
align-items: "center";
11+
flex-direction: ${(props) => (props.flow == "horizontal" ? "row" : "column")};
12+
gap: ${(props) => props.gap}px;
13+
padding: ${(props) => props.gap}px;
14+
box-sizing: "border-box";
15+
`;

0 commit comments

Comments
 (0)