Skip to content

Commit

Permalink
(#0) Icon 컴포넌트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
baegofda committed Dec 1, 2023
1 parent 1e72b20 commit 92bdedd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/core/components/Icon/Icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meta } from "@storybook/react";

import Icon from "./index";
import { IconProps } from "./types";

const meta = {
title: "core/Icon",
component: Icon,
argTypes: {
iconKey: {
control: "text",
description: "Phosphor Icons icon name",
},
size: {
control: "text",
description: "Phosphor Icons icon size",
},
},
} satisfies Meta<typeof Icon>;

export default meta;

export const Default = (props: IconProps) => {
return <Icon iconKey = {props.iconKey ?? "Airplane"} size = {props.size}/>;
};
11 changes: 11 additions & 0 deletions src/core/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import * as Icons from "@phosphor-icons/react";

import { IconProps } from "./types";

const Icon = ({ iconKey, ...props }: IconProps) => {
const IconComponent = Icons[iconKey as keyof typeof Icons] as React.ComponentType<Omit<IconProps, "iconKey">>;

return <IconComponent {...props} />;
};

export default Icon;
5 changes: 5 additions & 0 deletions src/core/components/Icon/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as Icons from "@phosphor-icons/react";

export interface IconProps extends Icons.IconProps {
iconKey: keyof typeof Icons
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export { default as Demo } from "@/core/components/Demo";
export { default as Divider } from "@/core/components/Divider";
export { default as Drawer } from "@/core/components/Drawer";
export { default as FormLabel } from "@/core/components/FormLabel";
export { default as Icon } from "@/core/components/Icon";
export { default as InputBase } from "@/core/components/Input/InputBase";
export { default as InputPassword } from "@/core/components/Input/InputPassword";
export { default as InputSearch } from "@/core/components/Input/InputSearch";
Expand Down

0 comments on commit 92bdedd

Please sign in to comment.