-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gmmq 147 feat: Badge 공통 컴포넌트 개발 (#9)
* feat: 차크라UI 스토리북 애드온 설치 및 적용 * chore: 예시 스토리북 컴포넌트 Button 제거 * feat: Badge 컴포넌트 차크라UI + 스토리북 테스트 * feat: Badge 공통 컴포넌트 * fix: eslint 설정 - react/no-unescaped-entities 비활성화 * feat: Badge 컴포넌트 내보내기
- Loading branch information
Showing
11 changed files
with
130 additions
and
96 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,45 @@ | ||
import { Badge as ChakraBadge, BadgeProps as ChakraBadgeProps, Text } from '@chakra-ui/react'; | ||
import { ReactNode } from 'react'; | ||
|
||
type BadgeProps = ChakraBadgeProps & { | ||
children: ReactNode; | ||
type?: 'mentor' | 'mentee' | 'default'; | ||
}; | ||
|
||
const Badge = ({ | ||
children, | ||
px = '1.5', | ||
py = '1', | ||
bg = 'gray.300', | ||
color = 'gray.800', | ||
type = 'default', | ||
...props | ||
}: BadgeProps) => { | ||
const BADGE_TYPE_COLOR = { | ||
default: { | ||
color, | ||
bg, | ||
}, | ||
mentor: { | ||
color: 'gray.100', | ||
bg: 'highlight.500', | ||
}, | ||
mentee: { | ||
color: 'primary.800', | ||
bg: 'primary.100', | ||
}, | ||
}; | ||
return ( | ||
<ChakraBadge | ||
bg={BADGE_TYPE_COLOR[type].bg} | ||
px={px} | ||
py={py} | ||
borderRadius={'base'} | ||
{...props} | ||
> | ||
<Text color={BADGE_TYPE_COLOR[type].color}>{children}</Text> | ||
</ChakraBadge> | ||
); | ||
}; | ||
|
||
export default Badge; |
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 type { Meta, StoryObj } from '@storybook/react'; | ||
import Badge from './Badge'; | ||
|
||
const meta = { | ||
title: 'Resumeme/Components/Badge', | ||
component: Badge, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
color: { control: 'color' }, | ||
bg: { control: 'color' }, | ||
children: { control: 'text' }, | ||
}, | ||
} satisfies Meta<typeof Badge>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: '기본', | ||
type: 'default', | ||
}, | ||
}; | ||
|
||
export const DefaultCustom: Story = { | ||
args: { | ||
children: '기본2', | ||
type: 'default', | ||
bg: '#191F28', | ||
color: '#FFFFFF', | ||
}, | ||
}; | ||
|
||
export const Mentee: Story = { | ||
args: { | ||
children: '멘티', | ||
type: 'mentee', | ||
}, | ||
}; | ||
|
||
export const Mentor: Story = { | ||
args: { | ||
children: '멘토', | ||
type: 'mentor', | ||
}, | ||
}; |
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 { default as Badge } from './Badge'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.