Skip to content

Commit

Permalink
feat: add container component
Browse files Browse the repository at this point in the history
  • Loading branch information
abelflopes committed Nov 2, 2023
1 parent 7649f38 commit f474827
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/components/all/src/container/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.root {
--spacing-y: 0;
--spacing-x: 0;

box-sizing: border-box;
max-width: var(--max-width);
padding: var(--spacing-y) var(--spacing-x);
margin: 0 auto;
}

.horizontal {
--max-width: 1300px;
--spacing-x: 50px;

.small {
color: red;
}
}

.vertical {
--spacing-y: 30px;

.small {
--spacing-y: 16px;
}
}
28 changes: 28 additions & 0 deletions packages/components/all/src/container/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import styles from "./index.module.scss";
import classNames from "classnames";

type ContainerVariation = "horizontal" | "vertical" | "small";

interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
variation?: ContainerVariation | ContainerVariation[];
}

export const Container = ({
variation = "horizontal",
className,
...otherProps
}: Readonly<ContainerProps>): React.ReactElement => {
const computedVariations = Array.isArray(variation) ? variation : [variation];

return (
<div
className={classNames(
styles.root,
className,
computedVariations.map((i) => styles[i]),
)}
{...otherProps}
/>
);
};

0 comments on commit f474827

Please sign in to comment.