Skip to content
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 11 commits into from
Aug 10, 2024

Conversation

Pyotato
Copy link
Collaborator

@Pyotato Pyotato commented Aug 9, 2024

PULL REQUEST TEMPLATE

PR ์„ค๋ช…

@appear ์ง€๋„๋‚˜ ์ƒ์„ธ๋ณด๊ธฐ ๋“ฑ ์™ผ์ชฝ ๋ชจ๋‹ฌ๋กœ ๋„์›Œ์ฃผ๋Š” drawer ์ปดํฌ๋„ŒํŠธ์ž…๋‹ˆ๋‹น.

์Šคํฌ๋ฆฐ์ƒท & URL

  • ๋‹คํฌ๋ชจ๋“œ
image
  • ๋ผ์ดํŠธ ๋ชจ๋“œ
image

Copy link

github-actions bot commented Aug 9, 2024

Comment on lines 21 to 25
{overlay ? (
<div
className={style(isOpen ? "is-open" : null)}
onClick={() => close()}
/>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ง€๋„์™€ ๊ฐ™์ด ์ƒํ˜ธ์ž‘์šฉ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ overlay๋ฅผ ์ถ”๊ฐ€ํ•˜์ง€ ์•Š๋Š” ์˜ต์…˜์ด ์žˆ์Šต๋‹ˆ๋‹น

image

Comment on lines 1 to 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;
open: () => void;
close: () => 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),
};
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drawer ๋ฅผ ์—ฌ๋‹ซ๋Š” ์ปค์Šคํ…€ ํ›… useDrawer์ž…๋‹ˆ๋‹ค.

isOpen์—ฌ๋ถ€์— ๋”ฐ๋ผ drawer๊ฐ€ ์—ด๋ ค ์žˆ๊ฑฐ๋‚˜ ๋‹ซํ˜€ ์žˆ๊ณ ,
toggle์„ ํ†ตํ•ด์„œ ์—ฌ๋‹ซ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
close๋Š” ๋ชจ๋‹ฌ์„ ๋‹ซ๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€๋กœ ์ œ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link

github-actions bot commented Aug 9, 2024

Copy link

github-actions bot commented Aug 9, 2024


return (
<>
<MyButton onClick={toggle}>Open</MyButton>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์–˜๋Š” ํ…Œ์ŠคํŠธ์šฉ์ธ๊ฐ€์š” ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต๋„ต! ๋ณ€๊ฒฝํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค ๋ฒ„ํŠผ ์•„์ด์ฝ˜ ์ปดํฌ๋„ŒํŠธ (x ํ‘œ์‹œ)๋กœ ๋Œ€์ฒด ํ•  ์˜ˆ์ •์ž…๋‹ˆ๋‹น

const style = classNames.bind(Style);

const Drawer = ({ children, overlay = true }: DrawerProps) => {
const { isOpen, toggle, close } = useDrawer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์˜คํ”ˆ ์ œ์–ด๊ถŒ์„ ์‚ฌ์šฉ์ฒ˜์—๊ฒŒ ์ฃผ๋Š”๊ฒŒ ์ข‹์ง€ ์•ˆํฅใ„น๊นŒ์š” ?
์ƒํ™ฉ์—๋”ฐ๋ผ ์™ธ๋ถ€์—์„œ ๋‹ซ๊ณ  ์—ด๊ณ ๋ฅผ ์ปจํŠธ๋กคํ•˜๊ณ  ์‹ถ์„๋•Œ๊ฐ€ ์žˆ์„๊ฒƒ ๊ฐ™๊ตฌ์š”
๋‹ซํ˜”์„๋•Œ ์•ก์…˜, ์—ด๋ฆด๋•Œ ์•ก์…˜์„ ์ œ์–ดํ•˜๊ณ  ์‹ถ์„์ˆ˜๋„์žˆ๊ตฌ์š”

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ˜น์‹œ ๊ทธ๋Ÿผ ์•„๋ž˜์˜ useDrawer ํ˜ธ์ถœ์€ ์‚ฌ์šฉํ•˜๋Š” ์™ธ๋ถ€์—์„œ ํ•˜๊ณ  Drawer ์ปดํฌ๋„ŒํŠธ๋กœ ์ „๋‹ฌํ•˜๋Š” ์‹์œผ๋กœ ํ•˜๋Š”๊ฒŒ ์ข‹์„๊นŒ์š”?๐Ÿค”

  const { isOpen, toggle, close, open } = useDrawer();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useDrawer ์ž์ฒด๊ฐ€ ์‚ฌ์šฉ์ฒ˜์—์„œ ๊ณ ๋ คํ•ด์•ผ๋˜๋Š”๋ถ€๋ถ„ ์•„๋‹๊นŒ์šฉ?

Drawer์—์„œ๋Š” ์–ด๋–ค ๊ฐ’์„ ๋„˜๊ฒจ์ฃผ๋ฉด ์—ด๋ฆด๊ฑฐ๋‹ค, ๋‹ซ์„๋•Œ๋Š” onDimmedClick (๋ฐ”๊นฅ ๋ฐฐ๊ฒฝํด๋ฆญ), onClose(x ๋ฒ„ํŠผํด๋ฆญ) ํ–ˆ์„๋•Œ๋“ฑ ์ธํ„ฐํŽ˜์ด์Šค๋งŒ ๋šซ์–ด์ฃผ๋ฉด๋˜์ง€์•Š์„๊นŒ์š” ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„ํ•˜

@@ -8,8 +14,9 @@ import ThemeButton from "../components/ThemeButton";
export default function Home() {
const text =
"Lorem, ipsum dolor sit amet consectetur adipisicing elit. Omnis\npariatur, ab voluptates saepe eum at excepturi, eaque accusamus labore\ntemporibus ex nostrum in hic iure porro quod doloribus deleniti! Qui.\ntemporibus ex nostrum in hic iure porro quod doloribus deleniti!";
const { isOpen, toggle, close, open } = useDrawer();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์™ธ๋ถ€ ์‚ฌ์šฉ์ฒ˜์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋„๋ก ๋บด์คฌ์Šต๋‹ˆ๋‹ค

Copy link

Copy link

Copy link
Collaborator

@appear appear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ•œ๋ฒˆ ์„œ๋น„์Šค์—์„œ ์จ๋ณด์‹œ๋ฉด์„œ ๋””๋ฒจ๋กญํ•ด๋ณด์‹œ์ฃต !

@Pyotato Pyotato merged commit e07477a into 21-design-system Aug 10, 2024
1 check passed
@Pyotato Pyotato deleted the 51-design-system-component-drawer branch August 10, 2024 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants