-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English** and added an appropriate **label** to the PR. - [x] I wrote the commit message in **English** and to follow [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] I [added the **changeset**](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md) about the changes that needed to be released. (or didn't have to) - [x] I wrote or updated **documentation** related to the changes. (or didn't have to) - [x] I wrote or updated **tests** related to the changes. (or didn't have to) - [x] I tested the changes in various browsers. (or didn't have to) - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox ## Related Issue <!-- Please link to issue if one exists --> - Fixes #1879 ## Summary <!-- Please brief explanation of the changes made --> Remove `color` props from `Tag` component & TagBadge common type ## Details - `Tag` 컴포넌트에서 `color` 속성을 제거하고, `variant` 속성을 통해서만 스타일링할 수 있도록 합니다. 마찬가지로 불필요한 `TagBadgeBgColorPreset` 을 제거합니다. - `TagBadgeCommon` 의 스타일을 `Tag` 와 `Badge` 에서 import하여 조립해 사용하는 대신, 스타일이 포함된 `BaseTagBadge` 컴포넌트를 만들고 재사용하도록 했습니다. 또한 Size, Variant type을 각 컴포넌트에서 직접 정의하여 사용하도록 변경했습니다. 이 방식이 현재 components 디렉토리 내부 구성 방식-컴포넌트명이 폴더-에 더 적합하다고 판단했습니다. <!-- Please elaborate description of the changes --> ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> Yes
- Loading branch information
1 parent
6f6d019
commit bc70fdc
Showing
18 changed files
with
175 additions
and
174 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@channel.io/bezier-react": major | ||
--- | ||
|
||
**Breaking changes: Remove TagBadge-related types** | ||
|
||
- Remove `color` prop of `TagProps` and `TagBadgeBgColorPreset`. | ||
- Remove `TagBadgeSize`. Please change it to `TagSize` and `BadgeSize`. | ||
- Remove `TagBadgeVariant`. Please change it to `TagVariant` and `BadgeVariant`. |
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
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,2 +1,2 @@ | ||
export { Badge } from './Badge' | ||
export type { BadgeProps } from './Badge.types' | ||
export type { BadgeProps, BadgeSize, BadgeVariant } from './Badge.types' |
19 changes: 18 additions & 1 deletion
19
...ct/src/components/Badge/Badge.module.scss → ...nts/BaseTagBadge/BaseTagBadge.module.scss
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
63 changes: 63 additions & 0 deletions
63
packages/bezier-react/src/components/BaseTagBadge/BaseTagBadge.tsx
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,63 @@ | ||
import React, { forwardRef } from 'react' | ||
|
||
import classNames from 'classnames' | ||
|
||
import { Text } from '~/src/components/Text' | ||
|
||
import { | ||
type BaseTagBadgeProps, | ||
type BaseTagBadgeSize, | ||
type BaseTagBadgeTextProps, | ||
} from './BaseTagBadge.types' | ||
|
||
import styles from './BaseTagBadge.module.scss' | ||
|
||
function getProperTypo(size: BaseTagBadgeSize) { | ||
return ( | ||
{ | ||
xs: '11', | ||
s: '13', | ||
m: '14', | ||
l: '15', | ||
} as const | ||
)[size] | ||
} | ||
|
||
/** | ||
* `BaseTagBadge` is the component on which `Tag` and `Badge` components are based. | ||
*/ | ||
export const BaseTagBadge = forwardRef<HTMLDivElement, BaseTagBadgeProps>( | ||
function Tag({ size, variant, children, className, ...rest }, forwardedRef) { | ||
return ( | ||
<div | ||
ref={forwardedRef} | ||
className={classNames( | ||
styles.BaseTagBadge, | ||
styles[`size-${size}`], | ||
styles[`variant-${variant}`], | ||
className | ||
)} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
) | ||
|
||
/** | ||
* `BaseTagBadgeText` is the component on which `Tag` and `Badge` components are based. | ||
*/ | ||
export const BaseTagBadgeText = forwardRef< | ||
HTMLDivElement, | ||
BaseTagBadgeTextProps | ||
>(function BaseTagBadgeText({ size, children, ...rest }) { | ||
return ( | ||
<Text | ||
typo={getProperTypo(size)} | ||
{...rest} | ||
> | ||
{children} | ||
</Text> | ||
) | ||
}) |
36 changes: 36 additions & 0 deletions
36
packages/bezier-react/src/components/BaseTagBadge/BaseTagBadge.types.ts
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,36 @@ | ||
import { | ||
type BezierComponentProps, | ||
type ChildrenProps, | ||
type SizeProps, | ||
type VariantProps, | ||
} from '~/src/types/props' | ||
|
||
import { type TextProps } from '~/src/components/Text' | ||
|
||
export type BaseTagBadgeSize = 'xs' | 's' | 'm' | 'l' | ||
|
||
export type BaseTagBadgeVariant = | ||
| 'default' | ||
| 'monochrome-light' | ||
| 'monochrome-dark' | ||
| 'blue' | ||
| 'cobalt' | ||
| 'teal' | ||
| 'green' | ||
| 'olive' | ||
| 'pink' | ||
| 'navy' | ||
| 'yellow' | ||
| 'orange' | ||
| 'red' | ||
| 'purple' | ||
|
||
export interface BaseTagBadgeProps | ||
extends BezierComponentProps<'div'>, | ||
ChildrenProps, | ||
Required<SizeProps<BaseTagBadgeSize>>, | ||
Required<VariantProps<BaseTagBadgeVariant>> {} | ||
|
||
export interface BaseTagBadgeTextProps | ||
extends Omit<TextProps, 'typo'>, | ||
Required<SizeProps<BaseTagBadgeSize>> {} |
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,5 @@ | ||
export { BaseTagBadge, BaseTagBadgeText } from './BaseTagBadge' | ||
export type { | ||
BaseTagBadgeSize, | ||
BaseTagBadgeVariant, | ||
} from './BaseTagBadge.types' |
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
Oops, something went wrong.