-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from f-lab-edu/46-design-system-component-cont…
…ainer [💅 design system] 레이아웃 컴포넌트 생성 default(left), center, right
- Loading branch information
Showing
9 changed files
with
216 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/design-system/src/components/container/_container.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@use "../../functions/" as *; | ||
@use "sass:map"; | ||
|
||
.layout-fill-available { | ||
width: -moz-available; | ||
width: -webkit-fill-available; | ||
width: fill-available; | ||
} | ||
.align-center { | ||
display: inline-flex; | ||
justify-content: center; | ||
align-content: stretch; | ||
flex-wrap: nowrap; | ||
} | ||
.align-right { | ||
display: inline-flex; | ||
justify-content: flex-end; | ||
align-content: stretch; | ||
flex-wrap: nowrap; | ||
} | ||
|
||
$space-map: ( | ||
xl: space(4rem), | ||
l: space(2rem), | ||
m: space(1rem), | ||
sm: space(0.6rem), | ||
xsm: space(0.2rem), | ||
); | ||
|
||
@mixin margins($direction, $size) { | ||
@if ($direction == "top-bottom") { | ||
margin: $size 0; | ||
} @else if ($direction == "left-right") { | ||
margin: 0 $size; | ||
} @else if ($direction == "left") { | ||
margin: 0; | ||
margin-left: $size; | ||
} @else if ($direction == "right") { | ||
margin: 0; | ||
margin-right: $size; | ||
} @else if ($direction == "top") { | ||
margin: 0; | ||
margin-top: $size; | ||
} @else if ($direction == "bottom") { | ||
margin: 0; | ||
margin-bottom: $size; | ||
} @else if ($direction == "all") { | ||
margin: $size; | ||
} | ||
} | ||
|
||
@each $key, $value in $space-map { | ||
.container.all.#{$key} { | ||
@include margins("all", $value); | ||
} | ||
.container.top-bottom.#{$key} { | ||
@include margins("top-bottom", $value); | ||
} | ||
.container.left-right.#{$key} { | ||
@include margins("left-right", $value); | ||
} | ||
.container.left.#{$key} { | ||
@include margins("left", $value); | ||
} | ||
.container.right.#{$key} { | ||
@include margins("right", $value); | ||
} | ||
.container.top.#{$key} { | ||
@include margins("top", $value); | ||
} | ||
.container.bottom.#{$key} { | ||
@include margins("bottom", $value); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/design-system/src/components/container/_container.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { useEffect } from "react"; | ||
import { useAppTheme } from "../../hooks"; | ||
import Container from "./_container"; | ||
|
||
const meta: Meta<typeof Container> = { | ||
title: "tripie-ui/Container", | ||
component: Container, | ||
tags: ["autodocs"], | ||
decorators: [ | ||
(story, context) => { | ||
const { mode, setMode } = useAppTheme(); | ||
const selectedTheme = context.globals.theme || mode; | ||
|
||
useEffect(() => { | ||
setMode(selectedTheme); | ||
}, [selectedTheme]); | ||
|
||
return <div className={`${context.globals.theme}`}>{story()}</div>; | ||
}, | ||
], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: "Margin-Default", | ||
args: { | ||
children: "default container", | ||
}, | ||
}; | ||
|
||
export const AllDefault: Story = { | ||
name: "Margin-m", | ||
args: { | ||
children: "MarginAll m container", | ||
margin: "m", | ||
}, | ||
}; | ||
|
||
export const AllXsm: Story = { | ||
name: "Margin-xm", | ||
args: { | ||
children: "m container", | ||
|
||
margin: "xsm", | ||
}, | ||
}; | ||
|
||
export const AllSm: Story = { | ||
name: "Margin-sm", | ||
args: { | ||
children: "sm container", | ||
|
||
margin: "sm", | ||
}, | ||
}; | ||
|
||
export const AllL: Story = { | ||
name: "Margin-l", | ||
args: { | ||
children: " l container", | ||
margin: "l", | ||
}, | ||
}; | ||
|
||
export const AllXl: Story = { | ||
name: "Margin-xl", | ||
args: { | ||
children: " xl container", | ||
margin: "xl", | ||
}, | ||
}; |
46 changes: 46 additions & 0 deletions
46
packages/design-system/src/components/container/_container.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import classNames from "classnames/bind"; | ||
import { ReactNode } from "react"; | ||
import Style from "./_container.module.scss"; | ||
|
||
export type ContainerProps = { | ||
margin?: "xl" | "l" | "m" | "sm" | "xsm"; | ||
align?: "left" | "center" | "right"; | ||
children?: ReactNode; | ||
applyMargin?: | ||
| "top-bottom" | ||
| "left-right" | ||
| "all" | ||
| "left" | ||
| "right" | ||
| "top" | ||
| "bottom"; | ||
} & Omit<React.ComponentProps<"div">, "children">; | ||
|
||
const style = classNames.bind(Style); | ||
|
||
const Container = ({ | ||
children, | ||
className, | ||
align = "left", | ||
margin = "m", | ||
applyMargin = "all", | ||
...props | ||
}: ContainerProps) => { | ||
return ( | ||
<div | ||
className={style( | ||
"layout-fill-available", | ||
`align-${align}`, | ||
"container", | ||
applyMargin, | ||
margin, | ||
className | ||
)} | ||
{...props} | ||
> | ||
<div>{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Container; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./_container"; | ||
export { default } from "./_container"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
.button { | ||
background-color: variables.$primary-color; | ||
padding: 0.2rem; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters