-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[๐ design system] drawer ์ปดํฌ๋ํธ ์์ฑ #52
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2842648
feat: add useDrawer hook
Pyotato 0aa13bb
feat: export useDrawer hook
Pyotato 032dfe6
feat: create drawer component
Pyotato 2706e24
feat: add no margin container option
Pyotato 1fcca7d
feat: add no margin container option (none)
Pyotato 6d98d6e
feat: export drawer component
Pyotato d7895dc
feat: add drawer component
Pyotato e7c30b1
chore: rename type
Pyotato 426444b
chore: remove unused open func
Pyotato 36379f6
feat: hand over drawer control where component is used
Pyotato 3ade040
feat: remove open button control in drawer component
Pyotato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
32 changes: 32 additions & 0 deletions
32
packages/design-system/src/components/drawer/_drawer.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,32 @@ | ||
@use "../../functions/" as *; | ||
@use "../../mixins/" as *; | ||
@use "sass:map"; | ||
|
||
.drawer-menu { | ||
position: fixed; | ||
z-index: z-index("modal"); | ||
width: min(100%, 32rem); | ||
height: 100vh; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); | ||
background-color: color(default, 50); | ||
display: grid; | ||
} | ||
|
||
.drawer-menu.is-closed { | ||
transform: translateX(-100%); | ||
} | ||
|
||
.is-open { | ||
top: 0; | ||
left: 0; | ||
position: fixed; | ||
background-color: color(default, 800); | ||
width: 100vw; | ||
height: 100vh; | ||
z-index: z-index("overlay"); | ||
bottom: 0; | ||
opacity: 0.85; | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/design-system/src/components/drawer/_drawer.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,55 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { useEffect } from "react"; | ||
import { useAppTheme } from "../../hooks"; | ||
import Drawer from "./_drawer"; | ||
|
||
const meta: Meta<typeof Drawer> = { | ||
title: "tripie-ui/Drawer", | ||
component: Drawer, | ||
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}`} | ||
style={{ height: "100vh", overflow: "hidden" }} | ||
> | ||
{story()} | ||
</div> | ||
); | ||
}, | ||
], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: "Default", | ||
args: { | ||
children: "default Drawer", | ||
}, | ||
}; | ||
|
||
export const NoOverLayDrawer: Story = { | ||
name: "No OverLay", | ||
args: { | ||
children: "Drawer No OverLay", | ||
overlay: false, | ||
}, | ||
}; | ||
|
||
export const NoCloseButtonDrawer: Story = { | ||
name: "No Close Button", | ||
args: { | ||
children: "Drawer No Close Button", | ||
withCloseButton: false, | ||
}, | ||
}; |
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,49 @@ | ||
import classNames from "classnames/bind"; | ||
import { ReactNode } from "react"; | ||
import { useDrawerOutput } from "../../hooks"; | ||
import Container from "../container"; | ||
import MyButton from "../myButton"; | ||
import Style from "./_drawer.module.scss"; | ||
|
||
export type DrawerProps = { | ||
children?: ReactNode; | ||
overlay?: boolean; | ||
|
||
withCloseButton?: boolean; | ||
} & Omit<React.ComponentProps<"div">, "children"> & | ||
Partial<useDrawerOutput>; | ||
|
||
const style = classNames.bind(Style); | ||
|
||
const Drawer = ({ | ||
children, | ||
overlay = true, | ||
withCloseButton = true, | ||
isOpen, | ||
|
||
close, | ||
}: DrawerProps) => { | ||
return ( | ||
<> | ||
{overlay ? ( | ||
<div className={style(isOpen ? "is-open" : null)} onClick={close} /> | ||
) : null} | ||
|
||
<aside className={style("drawer-menu", !isOpen && "is-closed")}> | ||
<nav className={style("menu")}> | ||
<Container className={style("menu-item")}> | ||
{withCloseButton && close != null ? ( | ||
<Container align="right" margin="none"> | ||
<MyButton onClick={() => close()}>Close</MyButton> | ||
{/* !! ์์ด์ฝ์ผ๋ก ๋ณ๊ฒฝํ๊ธฐ */} | ||
</Container> | ||
) : null} | ||
{children} | ||
</Container> | ||
</nav> | ||
</aside> | ||
</> | ||
); | ||
}; | ||
|
||
export default Drawer; |
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 "./_drawer"; | ||
export { default } from "./_drawer"; |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { default as Body } from "./body"; | ||
export { default as Drawer } from "./drawer"; | ||
export { default as MyButton } from "./myButton"; | ||
export { default as Headers } from "./typography"; | ||
export { default as Text } from "./typography/text"; |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./useAppTheme"; | ||
export * from "./useDrawer"; |
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,28 @@ | ||
import { useState } from "react"; | ||
|
||
const DRAWER_MODE = { | ||
OPEN: true, | ||
CLOSE: false, | ||
} as const; | ||
|
||
type DrawerMode = (typeof DRAWER_MODE)[keyof typeof DRAWER_MODE]; | ||
|
||
export type useDrawerOutput = { | ||
isOpen: DrawerMode; | ||
toggle: () => void; | ||
close: () => void; | ||
open: () => void; | ||
}; | ||
|
||
export const useDrawer = (): useDrawerOutput => { | ||
const [isOpen, setIsOpen] = useState<DrawerMode>(DRAWER_MODE.CLOSE); | ||
|
||
return { | ||
isOpen, | ||
toggle: () => { | ||
setIsOpen((previous) => !previous); | ||
}, | ||
open: () => setIsOpen(DRAWER_MODE.OPEN), | ||
close: () => setIsOpen(DRAWER_MODE.CLOSE), | ||
}; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ธ๋ถ ์ฌ์ฉ์ฒ์์ ์ฌ์ฉ๊ฐ๋ฅํ๋๋ก ๋บด์คฌ์ต๋๋ค