-
Notifications
You must be signed in to change notification settings - Fork 48
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
Convert enum type of component props to string literal type - Button, Banner, etc #1984
Convert enum type of component props to string literal type - Button, Banner, etc #1984
Conversation
🦋 Changeset detectedLatest commit: 38c5495 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Chromatic Report🚀 Congratulations! Your build was successful! |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## alpha #1984 +/- ##
==========================================
- Coverage 84.23% 84.04% -0.19%
==========================================
Files 142 134 -8
Lines 2277 2250 -27
Branches 606 606
==========================================
- Hits 1918 1891 -27
Misses 282 282
Partials 77 77 ☔ View full report in Codecov by Sentry. |
👍
저도 케밥 케이스로 통일하는 편이 좋을 거 같아요. |
.changeset/sharp-donuts-dance.md
Outdated
"@channel.io/bezier-react": major | ||
--- | ||
|
||
## "@channel.io/bezier-react": major |
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.
## "@channel.io/bezier-react": major |
@@ -75,7 +71,7 @@ export const Avatar = forwardRef<HTMLDivElement, AvatarProps>(function Avatar({ | |||
return null | |||
} | |||
|
|||
const statusSize = size >= AvatarSize.Size90 ? StatusSize.L : StatusSize.M | |||
const statusSize = Number(size) >= 90 ? 'l' : 'm' |
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.
형변환 하지 않고 명시적으로 맵핑해주는 게 좋을 거 같아요. 이렇게 변경할 경우, 100 as AvatarSize
같은 식으로 사용한 곳에서 제대로 동작하지 않게 될텐데 그건 사용처 잘못이라고 봅니다
@@ -209,7 +212,7 @@ export const AvatarGroup = forwardRef<HTMLDivElement, AvatarGroupProps>(function | |||
)} | |||
style={{ | |||
'--b-avatar-group-spacing': px(spacing), | |||
'--b-avatar-group-size': px(size), | |||
'--b-avatar-group-size': cssDimension(size), |
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.
'--b-avatar-group-size': cssDimension(size), | |
'--b-avatar-group-size': `${size}px` |
스냅샷 변경사항을 참고해주세요!
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.
size 를 css variable 로 받을 이유는 없어 보여서 classname 으로 바꿨습니다!
2b41e5d
to
7da63f9
Compare
@@ -72,7 +72,7 @@ interface ButtonOwnProps { | |||
|
|||
/** | |||
* The style variant. | |||
* @default ButtonStyleVariant.Primary | |||
* @default "primary" |
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.
아쉽게도 string literal type 은 enum 과 달리 이런 jsdoc을 미리보기로 보여줄 수 없네요
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.
네, enum이 jsdoc이나 코드 검색 시에는 확실한 장점이 있어요 (#1568)
7da63f9
to
1124241
Compare
이번 pr 에 포함했습니다! |
1124241
to
be341d6
Compare
@each $size in $avatar-sizes { | ||
@if $size > 24 { | ||
&:where(.size-#{$size}) { | ||
--b-avatar-group-ellipsis-pr: 6px; | ||
} | ||
} |
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.
지금 보니 &:where(.size-30, .size-36...)
한 줄로 할 수 있을 거 같네요
@@ -15,4 +15,4 @@ The properties that change are: | |||
- `ListItemVariant`, `ListItemSize` | |||
- `StatusType`, `StatusSize` | |||
|
|||
When changed to string literal type, it is changed to the value of enum. e.g. `ButtonStyleVariant.MonoChrome` -> `monochrome` | |||
When changed to string literal type, it is changed to the kebab-cased value of enum. e.g. `ButtonStyleVariant.MonoChromeDark` -> `monochrome-dark`, `StatusType.OnlineCrescent` -> `online-crescent` |
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.
👍
…ize enum to string literal
…use" This reverts commit 31d757b.
be341d6
to
38c5495
Compare
…Tooltip, etc (#1990) <!-- 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 #0000 --> - Fixes #1815 - Fixes #1568 ## Summary <!-- Please brief explanation of the changes made --> - #1984 의 후속 작업입니다. - 컴포넌트의 enum 타입을 string literal 타입으로 변경하고, codemod 에 변경사항을 추가하여 마이그레이션을 지원합니다. ## Details <!-- Please elaborate description of the changes --> - 대부분의 경우는 이전 pr과 동일하게 PascalCase 의 enum 을 kebab-case 의 string literal 타입으로 변환하는 작업입니다. 여기서 2가지 경우만 약간의 예외적인 상황이 있었습니다. - `IconSize`의 경우 `IconSize.Normal = 24`와 같이 size value 를 그대로 사용하던 것을 `'normal'` 을 받고 컴포넌트 내부에서 size 로 맵핑하는 형식으로 변경했습니다. number literal 을 그대로 받는 것보다 이렇게 하는 게 다른 컴포넌트와의 일관성이 유지된다고 생각하였습니다. - 한편 `TextAreaHeight` enum 은 `TextAreaHeight.Row16` 처럼 쓰이고 있어서 이를 `'row16'` 으로 바꾸는 것보다는 `16`으로 받는게 깔끔한 것 같아서 예외적으로 number literal 을 받도록 했습니다. ### Breaking change? (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> - Yes (changeset 참고) ## References <!-- Please list any other resources or points the reviewer should be aware of --> - None
Self Checklist
Related Issue
Summary
Details
v2-enum-member-to-string-literal
codemod 를 사용해서 하나씩 변환했습니다.Breaking change? (Yes/No)
References