-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from zoopi-palette/feat/icon
Feat/icon
- Loading branch information
Showing
16 changed files
with
468 additions
and
21 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
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,44 @@ | ||
import {ComponentStory, ComponentMeta} from "@storybook/react"; | ||
import React from "react"; | ||
|
||
import {Icon, IconName} from "./icon"; | ||
|
||
const iconNames: IconName[] = ["arrow-back", "arrow-right", "check-circle", "circle", "close-circle", "close", "eye", "search"] | ||
|
||
export default { | ||
title: "atoms/Icon", | ||
component: Icon, | ||
argTypes: { | ||
name: { | ||
options: iconNames, | ||
control: {type: "radio"}, | ||
}, | ||
}, | ||
args: { | ||
name: "close", | ||
}, | ||
} as ComponentMeta<typeof Icon>; | ||
|
||
const Template: ComponentStory<typeof Icon> = (args) => <Icon {...args} />; | ||
|
||
export const Close = Template.bind({}); | ||
Close.args = { | ||
name: "close", | ||
}; | ||
|
||
export const AllIcons: ComponentStory<typeof Icon> = (props) => { | ||
return ( | ||
<div css={{ | ||
display: "flex", | ||
flexDirection: "row", | ||
flexWrap: "wrap", | ||
}}> | ||
{iconNames.map(name=>( | ||
<div key={name} css={{padding: "4px"}}> | ||
<Icon {...props} name={name}/> | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
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,49 @@ | ||
import {useTheme} from "@emotion/react" | ||
import React, {ReactElement, SVGProps} from "react" | ||
|
||
import ArrowBack from "../../public/icons/arrow-back.svg" | ||
import ArrowRight from "../../public/icons/arrow-right.svg" | ||
import CheckCircle from "../../public/icons/check-circle.svg" | ||
import Circle from "../../public/icons/circle.svg" | ||
import CloseCircle from "../../public/icons/close-circle.svg" | ||
import Close from "../../public/icons/close.svg" | ||
import Eye from "../../public/icons/eye.svg" | ||
import Search from "../../public/icons/search.svg" | ||
|
||
const nameIconMap = { | ||
"arrow-back": ArrowBack, | ||
"arrow-right": ArrowRight, | ||
"check-circle": CheckCircle, | ||
"circle": Circle, | ||
"close-circle": CloseCircle, | ||
"close": Close, | ||
"eye": Eye, | ||
"search": Search, | ||
} | ||
|
||
export type IconName = keyof typeof nameIconMap | ||
|
||
export type IconProps = { | ||
name: IconName | ||
color?: string | ||
size?: number | ||
} | ||
|
||
export const Icon = ({ | ||
color, | ||
size = 24, | ||
name, | ||
}: IconProps) => { | ||
const theme = useTheme() | ||
|
||
const Icon = nameIconMap[name] as (props: SVGProps<SVGElement>) => ReactElement | ||
|
||
return ( | ||
<span css={{ | ||
color: color ? color : theme.colors["grey-90"], | ||
fontSize: 0, | ||
}}> | ||
<Icon width={size} height={size}/> | ||
</span> | ||
) | ||
} |
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 @@ | ||
export * from "./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 |
---|---|---|
@@ -1,6 +1,29 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
webpack(config) { | ||
// ref: https://stackoverflow.com/a/61706308/11681543 | ||
const fileLoaderRule = config.module.rules.find(rule => rule.test && rule.test.test(".svg")); | ||
fileLoaderRule.exclude = /\.svg$/; | ||
|
||
config.module.rules.push({ | ||
test: /\.svg$/, | ||
enforce: "pre", | ||
use: [{ | ||
loader: "@svgr/webpack", | ||
options: { | ||
// ref: https://stackoverflow.com/a/71127131/11681543 | ||
svgoConfig: { | ||
plugins: [ | ||
{removeViewBox: false}, | ||
], | ||
}, | ||
}, | ||
}], | ||
}); | ||
|
||
return config; | ||
} | ||
} | ||
|
||
module.exports = nextConfig |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.