-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
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
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}/>; | ||
}; |
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,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; |
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,5 @@ | ||
import * as Icons from "@phosphor-icons/react"; | ||
|
||
export interface IconProps extends Icons.IconProps { | ||
iconKey: keyof typeof Icons | ||
} |
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