Skip to content

Commit e638d81

Browse files
committed
feat: icon 컴포넌트, storybook 추가
1 parent 28d2526 commit e638d81

File tree

8 files changed

+115
-61
lines changed

8 files changed

+115
-61
lines changed

.storybook/preview.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.Wrapper {
2+
display: flex;
3+
flex-flow: row wrap;
4+
align-items: center;
5+
justify-content: center;
6+
width: 100%;
7+
height: 100%;
8+
}
9+
10+
.Story {
11+
height: 100%;
12+
padding: 2.5rem;
13+
background-color: gray;
14+
}

.storybook/preview.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

.storybook/preview.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Preview } from "@storybook/react";
2+
3+
import styles from "./preview.module.scss";
4+
5+
const preview: Preview = {
6+
parameters: {
7+
layout: "centered",
8+
options: {
9+
storySort: {
10+
order: ["ReadMe", "Changelog", "*", "components"],
11+
},
12+
},
13+
},
14+
15+
decorators: [
16+
(Story) => (
17+
<div className={styles.Wrapper}>
18+
<div className={styles.Story}>
19+
<Story />
20+
</div>
21+
</div>
22+
),
23+
],
24+
};
25+
26+
export default preview;

src/App.tsx

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
1-
import CameraIcon from "@/assets/svg/ic-camera.svg?react";
2-
import CloseIcon from "@/assets/svg/ic-close.svg?react";
3-
import GalleryIcon from "@/assets/svg/ic-gallery.svg?react";
4-
import LeftArrowIcon from "@/assets/svg/ic-left-arrow.svg?react";
5-
import PasteIcon from "@/assets/svg/ic-paste.svg?react";
6-
import PlusIcon from "@/assets/svg/ic-plus.svg?react";
7-
81
const App = () => {
9-
return (
10-
<div
11-
style={{
12-
width: "300px",
13-
height: "300px",
14-
backgroundColor: "gray",
15-
display: "flex",
16-
flexDirection: "column",
17-
gap: "16px",
18-
}}
19-
>
20-
<GalleryIcon />
21-
<CameraIcon />
22-
<CloseIcon />
23-
<LeftArrowIcon />
24-
<PasteIcon />
25-
<PlusIcon />
26-
<img src="/src/assets/img/img-logo.png" style={{ width: "52px", height: "28px" }} />
27-
</div>
28-
);
2+
return <div>App</div>;
293
};
304

315
export default App;

src/components/Button.module.scss

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/components/Button.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import Icon from "@/components/ui/Icon/Icon";
2+
import { ICONS } from "@/components/ui/Icon/Icon";
3+
import type { IconNameType } from "@/components/ui/Icon/Icon";
4+
5+
import type { Meta, StoryObj } from "@storybook/react";
6+
7+
const meta: Meta<typeof Icon> = {
8+
title: "Example/Icon",
9+
component: Icon,
10+
parameters: {
11+
layout: "centered",
12+
},
13+
argTypes: {
14+
name: {
15+
control: {
16+
type: "select",
17+
options: ["camera", "close", "gallery", "leftArrow", "paste", "plus"],
18+
},
19+
},
20+
},
21+
};
22+
23+
export default meta;
24+
25+
export const AllIcons: StoryObj<typeof Icon> = {
26+
render: () => (
27+
<div style={{ display: "flex", alignItems: "center", gap: "4rem" }}>
28+
{(Object.keys(ICONS) as IconNameType[]).map((iconName) => (
29+
<div
30+
style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "1rem" }}
31+
>
32+
<div
33+
style={{
34+
width: "1.5rem",
35+
height: "1.5rem",
36+
display: "flex",
37+
justifyContent: "center",
38+
alignItems: "center",
39+
}}
40+
>
41+
<Icon name={iconName} />
42+
</div>
43+
<p>{iconName}</p>
44+
</div>
45+
))}
46+
</div>
47+
),
48+
};

src/components/ui/Icon/Icon.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import CameraIcon from "@/assets/svg/ic-camera.svg?react";
2+
import CloseIcon from "@/assets/svg/ic-close.svg?react";
3+
import GalleryIcon from "@/assets/svg/ic-gallery.svg?react";
4+
import LeftArrowIcon from "@/assets/svg/ic-left-arrow.svg?react";
5+
import PasteIcon from "@/assets/svg/ic-paste.svg?react";
6+
import PlusIcon from "@/assets/svg/ic-plus.svg?react";
7+
8+
type IconNameType = "camera" | "close" | "gallery" | "leftArrow" | "paste" | "plus";
9+
10+
export const ICONS = {
11+
camera: CameraIcon,
12+
close: CloseIcon,
13+
gallery: GalleryIcon,
14+
leftArrow: LeftArrowIcon,
15+
paste: PasteIcon,
16+
plus: PlusIcon,
17+
};
18+
19+
// 추후 사이즈, 컬러등 추가 가능
20+
const Icon = ({ name }: { name: IconNameType }) => {
21+
const SvgIcon = ICONS[name];
22+
23+
return <SvgIcon />;
24+
};
25+
26+
export default Icon;

0 commit comments

Comments
 (0)