Skip to content

Commit

Permalink
[#8] Feat: Icon 컴포넌트 구현 (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
HoberMin authored Apr 24, 2024
1 parent fea6bae commit d607ac5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
21 changes: 21 additions & 0 deletions public/icon-sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
'use client';

import Icon from '../components/Icon';

const Home = () => {
return <main></main>;
return (
// 아래는 예시 사용방법입니다.
<div className='flex w-full flex-row items-center justify-center gap-4 px-4'>
<Icon id='chat' />
<Icon id='home' />
<Icon id='user' />
<Icon id='add' />
<Icon id='comment' size={16} />
<Icon id='heart' size={16} />
</div>
);
};

export default Home;
18 changes: 18 additions & 0 deletions src/components/Icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { ComponentProps } from 'react';

import { IconName } from './type';

interface IconProps extends Omit<ComponentProps<'svg'>, 'width' | 'height'> {
id: IconName;
size?: number;
}

const Icon = ({ id, size = 20, ...props }: IconProps) => {
return (
<svg width={size} height={size} {...props}>
<use href={`/icon-sprite.svg#${id}`} />
</svg>
);
};

export default Icon;
1 change: 1 addition & 0 deletions src/components/Icon/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type IconName = 'heart' | 'home' | 'user' | 'comment' | 'chat' | 'add';

0 comments on commit d607ac5

Please sign in to comment.