-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/11/icon component #25
Changes from 7 commits
be6b9ef
3d9ebc4
78824a6
c07a166
85b8515
2b67568
63874af
742a46f
e2e1f5d
313e327
6df349a
1205d41
d50f24b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ic_back from "./ic_back.svg?react"; | ||
|
||
export { ic_back }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기에 아이콘을 선언해두고 사용하는 방식이군요!! 제가 슬랙에 캐싱에 대해서 여쭈어 본 이유가 아이콘이 써질 때마다 가져오는거라면 뒤로가기 이미지 같은 경우는 계속 쓰여 조금 비효율적이니, 해당 부분에 캐싱 코드를 적용한다면 최적화 면에서 좋지 않을까? 했던 생각 때문이었습니다. 이 내용은 후순위인것 같아 나중에 최적화 작업할 때 진행해봐도 좋을 것 같습니다!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제가 알기론 해당 방식으로 svg파일을 import 했을 때는 빌드 시점에 번들링 되고, React Component로 변환되어 사용 됩니다. 그래서 매번 웹서버에서 이미지를 가져오는 방식은 아니라고 알고 있습니다. 만약에 public 폴더에서 svg 파일을 url로 참조 하는 경우에는 이미지가 로드 될 때 마다 매번 웹서버에서 해당 파일을 가져오는 방식으로 알고 있습니다. 그래서 이 경우에는 캐싱이 필요한 경우라고 생각합니다. 그리고 svg 파일을 최적화 시키는 방법 중에 sprite 기법을 사용하는 방법도 있는데, 이는 추후에 디자인 확정된 후에 시도해보면 재밌을 것 같습니다:) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다름이 아니라, 조금의 건의사항입니다! 🙋🏻♂️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋은 의견 감사합니다~!! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { memo } from "react"; | ||
|
||
import * as icons from "@/assets/svgs"; | ||
import { css } from "@emotion/react"; | ||
|
||
type IconType = keyof typeof icons; | ||
|
||
type Props = { | ||
icon: IconType; | ||
color?: string; | ||
size?: string | number; | ||
onClick?: () => void; | ||
}; | ||
|
||
const DEFAULT_ICON_COLOR = "#000000"; | ||
|
||
function icon({ icon, color = DEFAULT_ICON_COLOR, size = "0.2rem", onClick }: Props) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희 컴포넌트는 파스칼로 작성하기로 했는데 확인 부탁드립니다 !! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아이고 체크 감사합니다:) |
||
const SVGIcon = icons[icon]; | ||
const widthRem = typeof size === "number" ? `${size}rem` : size; | ||
|
||
return ( | ||
<SVGIcon | ||
onClick={onClick} | ||
css={css` | ||
color: ${color}; | ||
cursor: ${onClick ? "pointer" : "default"}; | ||
width: ${widthRem}; | ||
height: auto; | ||
`} | ||
/> | ||
); | ||
} | ||
|
||
export default memo(icon); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 쓰기 너무너무 좋은데요?! ✨