Skip to content

Commit ddf23cf

Browse files
authored
Merge pull request #103 from Canvas-Diary/hotfix/folder
Hotfix: 폴더 대소문자 구분 설정
2 parents 434ada4 + aff58c2 commit ddf23cf

File tree

10 files changed

+250
-0
lines changed

10 files changed

+250
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { fn } from "@storybook/test";
3+
import Appbar from "./Appbar";
4+
5+
const meta: Meta<typeof Appbar> = {
6+
component: Appbar,
7+
tags: ["autodocs"],
8+
};
9+
10+
export default meta;
11+
type Story = StoryObj<typeof Appbar>;
12+
13+
export const Primary: Story = {
14+
args: {
15+
text: "Text",
16+
menuHandler: fn(),
17+
backHandler: fn(),
18+
},
19+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import BackIcon from "@/assets/svg/back-button.svg?react";
2+
import MenuIcon from "@/assets/svg/menu-dots.svg?react";
3+
import { ReactNode } from "react";
4+
5+
interface AppBarProps {
6+
text?: string;
7+
backHandler?: () => void;
8+
menuHandler?: () => void;
9+
}
10+
11+
/**
12+
* 상단 AppBar
13+
* @param text 가운데 글귀
14+
* @param backHandler 뒤로가기 콜백 함수
15+
* @param menuHandler 메뉴버튼 콜백 함수
16+
* @returns
17+
*/
18+
const Appbar = ({ text, backHandler, menuHandler }: AppBarProps) => {
19+
return (
20+
<div className="relative z-50 flex w-full items-center justify-between bg-transparent px-500 py-300">
21+
<div>{backHandler && <AppbarButton icon={<BackIcon />} onClickHandler={backHandler} />}</div>
22+
{text && <span className="font-Binggrae text-body-1 font-regular">{text}</span>}
23+
<div>{menuHandler && <AppbarButton icon={<MenuIcon />} onClickHandler={menuHandler} />}</div>
24+
</div>
25+
);
26+
};
27+
28+
export default Appbar;
29+
30+
interface AppbarButtonProps {
31+
icon: ReactNode;
32+
onClickHandler: () => void;
33+
}
34+
35+
const AppbarButton = ({ icon, onClickHandler }: AppbarButtonProps) => {
36+
return (
37+
<button className="text-white" onClick={onClickHandler}>
38+
{icon}
39+
</button>
40+
);
41+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { fn } from "@storybook/test";
3+
4+
import Button from "./Button";
5+
6+
const meta: Meta<typeof Button> = {
7+
component: Button,
8+
tags: ["autodocs"],
9+
};
10+
11+
export default meta;
12+
type Story = StoryObj<typeof Button>;
13+
14+
export const Primary: Story = {
15+
args: { size: "big", active: true, text: "Text", onClickHandler: fn(), bgColor: "light" },
16+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
interface ButtonProps {
2+
size: "big" | "small";
3+
active: boolean;
4+
text: string;
5+
bgColor: "light" | "dark" | "gray";
6+
onClickHandler: () => void;
7+
}
8+
9+
const bgColorStyle = {
10+
light: "bg-primary-light-2 text-primary-normal dark:bg-primary-normal dark:text-white",
11+
dark: "bg-primary-normal text-white dark:bg-primary-medium",
12+
gray: "bg-gray-100 text-gray-500 dark:bg-gray-500 dark:text-gray-800",
13+
non: "bg-primary-light-1 text-primary-light-3 dark:bg-gray-700 dark:text-gray-300",
14+
};
15+
16+
/**
17+
* 공통 Button
18+
* @param size 버튼 크기
19+
* @param active 활성화 상태
20+
* @param text 버튼 글귀
21+
* @param bgColor 배경 색상
22+
* @param onClickHandler 버튼 클릭 콜백 함수
23+
* @returns
24+
*/
25+
const Button = ({ size, active, text, bgColor, onClickHandler }: ButtonProps) => {
26+
return (
27+
<button
28+
className={`${size === "big" ? "w-[20.4375rem]" : "w-[9.6875rem]"} ${active ? bgColorStyle[bgColor] : `${bgColorStyle.non} pointer-events-none`} rounded-200 py-600 font-Binggrae text-body-1 font-regular transition duration-200`}
29+
onClick={onClickHandler}
30+
>
31+
{text}
32+
</button>
33+
);
34+
};
35+
36+
export default Button;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
3+
import Divider from "./Divider";
4+
5+
const meta: Meta<typeof Divider> = {
6+
component: Divider,
7+
tags: ["autodocs"],
8+
};
9+
10+
export default meta;
11+
type Story = StoryObj<typeof Divider>;
12+
13+
export const Primary: Story = {
14+
args: {},
15+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
interface DividerProps {
2+
style?: string;
3+
}
4+
5+
const Divider = ({ style }: DividerProps) => {
6+
return <hr className={`w-full border border-gray-100 dark:border-gray-800 ${style && style}`} />;
7+
};
8+
9+
export default Divider;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { MemoryRouter } from "react-router-dom";
3+
import Navbar from "./Navbar";
4+
import Home from "@/assets/svg/home.svg?react";
5+
import Sns from "@/assets/svg/sns.svg?react";
6+
import Album from "@/assets/svg/album.svg?react";
7+
import Who from "@/assets/svg/who.svg?react";
8+
import ROUTE_PATH from "@/constants/ROUTE_PATH";
9+
10+
const meta: Meta<typeof Navbar> = {
11+
component: Navbar,
12+
tags: ["autodocs"],
13+
decorators: [
14+
(Story) => (
15+
<MemoryRouter initialEntries={["/"]}>
16+
<Story />
17+
</MemoryRouter>
18+
),
19+
],
20+
};
21+
22+
export default meta;
23+
type Story = StoryObj<typeof Navbar>;
24+
25+
export const Primary: Story = {
26+
args: {
27+
NavList: [
28+
{ icon: <Home />, label: "홈", path: ROUTE_PATH.HOME },
29+
{ icon: <Sns />, label: "일기 공유", path: ROUTE_PATH.EXPLORE },
30+
{ icon: <Album />, label: "앨범", path: ROUTE_PATH.ALBUM },
31+
{ icon: <Who />, label: "마이페이지", path: ROUTE_PATH.MYPAGE },
32+
],
33+
},
34+
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { ReactNode } from "react";
2+
import { Link, useLocation } from "react-router-dom";
3+
4+
interface NavBarProps {
5+
NavList: {
6+
icon: ReactNode;
7+
path: string;
8+
label: string;
9+
}[];
10+
}
11+
12+
/**
13+
* 하단 공통 NavBar
14+
* @param NavList nav배열
15+
* @returns
16+
*/
17+
const Navbar = ({ NavList }: NavBarProps) => {
18+
const location = useLocation();
19+
const currentPath = location.pathname;
20+
21+
return (
22+
<nav className="h-[5.25rem] flex-shrink-0 border-t-[1px] border-gray-100 bg-background dark:border-gray-800">
23+
<ul className="flex flex-row justify-center gap-600 px-800 pt-500">
24+
{NavList.map((element) => (
25+
<li
26+
key={element.label}
27+
className={`w-[4.375rem] ${
28+
currentPath === element.path ||
29+
(element.path !== "/" && currentPath.startsWith(element.path))
30+
? "text-primary-normal"
31+
: "text-gray-100 dark:text-gray-700"
32+
}`}
33+
>
34+
<Link to={element.path} className="flex flex-col items-center justify-center gap-200">
35+
<div className="flex h-7 w-7 items-center justify-center">{element.icon}</div>
36+
<span className="font-Binggrae text-detail-2 font-regular">{element.label}</span>
37+
</Link>
38+
</li>
39+
))}
40+
</ul>
41+
</nav>
42+
);
43+
};
44+
45+
export default Navbar;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { fn } from "@storybook/test";
3+
4+
import Toggle from "./Toggle";
5+
6+
const meta: Meta<typeof Toggle> = {
7+
component: Toggle,
8+
tags: ["autodocs"],
9+
};
10+
11+
export default meta;
12+
type Story = StoryObj<typeof Toggle>;
13+
14+
export const Primary: Story = {
15+
args: { onClickHandler: fn(), isChecked: true },
16+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
interface ToggleProps {
2+
onClickHandler: (isChecked: boolean) => void;
3+
isChecked: boolean;
4+
}
5+
6+
const Toggle = ({ onClickHandler, isChecked }: ToggleProps) => {
7+
const handleToggle = () => {
8+
onClickHandler(!isChecked);
9+
};
10+
11+
return (
12+
<label className="inline-flex cursor-pointer items-center">
13+
<input type="checkbox" className="peer sr-only" checked={isChecked} onChange={handleToggle} />
14+
<div className="peer relative h-[1.75rem] w-[3.25rem] rounded-full bg-gray-200 shadow-default after:absolute after:start-[2px] after:top-[2px] after:h-6 after:w-[1.48rem] after:rounded-full after:border after:border-gray-300 after:bg-white after:transition-all after:content-[''] peer-checked:bg-primary-medium peer-checked:after:translate-x-full peer-checked:after:border-white rtl:peer-checked:after:-translate-x-full"></div>
15+
</label>
16+
);
17+
};
18+
19+
export default Toggle;

0 commit comments

Comments
 (0)