Skip to content

Commit 038a1c9

Browse files
committed
refactor: simplify variation & spacing declaration
1 parent f3701be commit 038a1c9

File tree

1 file changed

+11
-5
lines changed
  • packages/components/all/src/container

1 file changed

+11
-5
lines changed

packages/components/all/src/container/index.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,31 @@ import React from "react";
22
import styles from "./index.module.scss";
33
import classNames from "classnames";
44

5-
type ContainerVariation = "horizontal" | "vertical" | "small";
5+
type ContainerVariation = "small";
66

7-
interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
7+
export interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
88
variation?: ContainerVariation | ContainerVariation[];
9+
spacingX?: boolean;
10+
spacingY?: boolean;
911
}
1012

1113
export const Container = ({
12-
variation = "horizontal",
14+
variation,
15+
spacingX = true,
16+
spacingY,
1317
className,
1418
...otherProps
1519
}: Readonly<ContainerProps>): React.ReactElement => {
16-
const computedVariations = Array.isArray(variation) ? variation : [variation];
20+
const computedVariations =
21+
Array.isArray(variation) || variation === undefined ? variation : [variation];
1722

1823
return (
1924
<div
2025
className={classNames(
2126
styles.root,
27+
{ [`${styles.horizontal}`]: spacingX, [`${styles.vertical}`]: spacingY },
28+
computedVariations?.map((i) => styles[i]),
2229
className,
23-
computedVariations.map((i) => styles[i]),
2430
)}
2531
{...otherProps}
2632
/>

0 commit comments

Comments
 (0)