Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ“ฆ chore: Icon ์ •๋ฆฌ ๋ฐ @svgr/cli ์ ์šฉ #38

Merged
merged 19 commits into from
Jan 28, 2024

Conversation

bbearcookie
Copy link
Member

@bbearcookie bbearcookie commented Jan 27, 2024

๐Ÿงฉ ์ด์Šˆ ๋ฒˆํ˜ธ

โœ… ์ž‘์—… ์‚ฌํ•ญ

  • ๊ธฐ์กด์˜ vite-plugin-svgr ์ œ๊ฑฐ
  • @svgr/cli ์„ค์น˜ ๋ฐ ์„ค์ •
    • svg ํŒŒ์ผ์„ ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๋„๊ตฌ์—์š”.
  • ๊ธฐ์กด ๋ฐฉ์‹์œผ๋กœ svg๋ฅผ ์‚ฌ์šฉํ•˜๋˜ ๋ถ€๋ถ„์— ์ƒˆ๋กœ์šด SVG ์ปดํฌ๋„ŒํŠธ ์ ์šฉ
  • ํ˜„์žฌ ์•ฑ์— ์กด์žฌํ•˜๋Š” ์•„์ด์ฝ˜์„ ํ•œ ๋ˆˆ์— ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ์Šคํ† ๋ฆฌ๋ถ ์ž‘์„ฑ
  • ๊ธฐ์กด์˜ svg ํŒŒ์ผ์„ /src/assets/icons/raw ๋กœ ์ด๋™

#37 ์ด์Šˆ์—์„œ svg๋ฅผ ๋‹ค๋ฃจ๋Š”๋ฐ ์žˆ์–ด์„œ์˜ ์–ด๋ ค์›€์„ ์ ์–ด ๋†“์•˜์–ด์š”..
์ด ๋ถ€๋ถ„์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ๋กœ SVG๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ฐฉ๋ฒ•์„ ์ƒ๊ฐํ–ˆ๊ณ ,
๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์— ์–ด๋Š ์ •๋„๋Š” ์ž๋™ํ™”ํ•  ์ˆ˜ ์žˆ๋„๋ก @svgr/cli ๋ฅผ ์ ์šฉํ–ˆ์–ด์š”.
(๊ทธ๋ž˜๋„ width, height๋ฅผ props๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๋ถ€๋ถ„๊ณผ fill, stroke ๋“ฑ์˜ ์ƒ‰์ƒ์„ currentColor ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •์€ ์ง์ ‘ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•˜๋Š” ๋“ฏ ํ•ด์š”!!)

๐Ÿ‘ฉโ€๐Ÿ’ป ๊ณต์œ  ํฌ์ธํŠธ ๋ฐ ๋…ผ์˜ ์‚ฌํ•ญ

SVG ์ปดํฌ๋„ŒํŠธ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•

1. /src/assets/icons/raw ๊ฒฝ๋กœ์— svg ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ•ด์š”.

2. npm run svgr ์ปค๋งจ๋“œ๋ฅผ ์ž…๋ ฅํ•ด์š”.

  • raw ๋””๋ ‰ํ† ๋ฆฌ์— ์กด์žฌํ•˜๋Š” ๋ชจ๋“  svg ํŒŒ์ผ์ด ๋ฆฌ์•กํŠธ ์ปดํฌ๋„ŒํŠธ๋กœ ๋ณ€ํ™˜๋œ ํ˜•ํƒœ๋กœ assets/icons ๋””๋ ‰ํ† ๋ฆฌ์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ช…๋ น์–ด์—์š”.
  • ์ด๋ฏธ ์ถ”๊ฐ€๋œ ํŒŒ์ผ์ด ์žˆ๋‹ค๋ฉด ๋™์ผํ•œ ์ด๋ฆ„์˜ ๊ธฐ์กด์˜ ํŒŒ์ผ์„ ๋ฎ์–ด ์“ฐ์ง€๋Š” ์•Š๋„๋ก ์„ค์ • ํ•ด ๋†“์•˜์–ด์š”. (ignoreExisting ์˜ต์…˜)

3. width, height, fill, stroke ๋“ฑ์˜ ์†์„ฑ์„ ์ ์ ˆํ•˜๊ฒŒ props๋กœ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•ด์š”.

  • ์ƒ์„ฑ๋œ ๊ฒฐ๊ณผ
    image

  • ์ˆ˜์ •ํ•œ ๋‚ด์šฉ

import type { SVGProps } from 'react';
const SvgSoundMaxFill = ({
  width = 24,
  height = 24,
  fill = 'currentColor',
  stroke = 'currentColor',
  ...props
}: SVGProps<SVGSVGElement>) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    fill="none"
    viewBox="0 0 24 24"
    width={width}
    height={height}
    {...props}
  >
    <path
      fill={fill}
      d="M4.158 13.93a3.75 3.75 0 0 1 0-3.86 1.5 1.5 0 0 1 .993-.7l1.693-.34a.45.45 0 0 0 .258-.152L9.17 6.395c1.182-1.42 1.774-2.13 2.301-1.938C12 4.647 12 5.572 12 7.42v9.162c0 1.847 0 2.77-.528 2.962-.527.19-1.119-.52-2.301-1.938L7.1 15.122a.45.45 0 0 0-.257-.153l-1.693-.34a1.5 1.5 0 0 1-.992-.7"
    />
    <path
      stroke={stroke}
      strokeLinecap="round"
      strokeWidth={2}
      d="M14.536 8.464a5 5 0 0 1 .027 7.044m4.094-9.165a8 8 0 0 1 .044 11.27"
    />
  </svg>
);
export default SvgSoundMaxFill;

Icons ์Šคํ† ๋ฆฌ๋ถ

ํ˜„์žฌ ๋“ฑ๋ก๋˜์–ด ์žˆ๋Š” ๋ชจ๋“  svg ์•„์ด์ฝ˜์„ ํ•œ ๋ˆˆ์— ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ณ , ์ƒ‰์ƒ์ด๋‚˜ ํฌ๊ธฐ๋ฅผ ๋ณ€๊ฒฝํ•ด๋ณผ ์ˆ˜ ์žˆ๋Š” ์Šคํ† ๋ฆฌ ๋ถ์„ ์ž‘์„ฑํ–ˆ์–ด์š”.

image

@bbearcookie bbearcookie added the ๐Ÿ“ฆ๏ธ Chore ๋นŒ๋“œ ๋ฐ ํŒจํ‚ค์ง€ ๊ด€๋ จ ์ž‘์—… label Jan 27, 2024
@bbearcookie bbearcookie self-assigned this Jan 27, 2024
Copy link

๐Ÿš€ Storybook Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: https://65a6c73d536a3c43b7c5c9bb-ggjhrcqisn.chromatic.com/
๐Ÿš€ React Preview ๋ณด๋Ÿฌ๊ฐ€๊ธฐ: https://sea-of-my-heart-5mrot2mjz-dnd-sea-of-my-heart.vercel.app

@easyhyun00
Copy link
Collaborator

์™€..์ˆ˜๊ณ ํ•˜์˜€์Šต๋‹ˆ๋‹ค! ๊ทธ๋™์•ˆ svg ์•„์ด์ฝ˜ ์ƒ‰์ƒ์ด๋ž‘ ํฌ๊ธฐ ์กฐ์ ˆํ•˜๋Š” ๊ฒŒ ์–ด๋ ค์› ๋Š”๋ฐ ์ด๋ ‡๊ฒŒ ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๊ตฐ์š”.. ์‹ ๊ธฐํ•˜๊ณ  ๋งŽ์€ ๊ฑฐ ์•Œ์•„๊ฐ€๋„ค์š”! ์ด์ œ svg ์•„์ด์ฝ˜์€ ํฌ๊ธฐ, ์ƒ‰์ƒ์„ ์ž์œ ๋กญ๊ฒŒ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š” ๐Ÿ‘

Copy link
Collaborator

@easyhyun00 easyhyun00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve ํ•ฉ๋‹ˆ๋‹ค

@bbearcookie bbearcookie merged commit 4c631bb into main Jan 28, 2024
8 checks passed
@bbearcookie bbearcookie deleted the chore/#37/icon branch January 28, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
๐Ÿ“ฆ๏ธ Chore ๋นŒ๋“œ ๋ฐ ํŒจํ‚ค์ง€ ๊ด€๋ จ ์ž‘์—…
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Icon ์ •๋ฆฌ
2 participants