Skip to content

Commit 82012cf

Browse files
authored
Expand text type of Select component to ReactNode (#2674)
<!-- 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 #2673 ## Summary <!-- Please brief explanation of the changes made --> - text 속성의 타입을 string 에서 ReactNode 로 확장합니다. ## Details <!-- Please elaborate description of the changes --> - None ### Breaking change? (Yes/No) - No <!-- If Yes, please describe the impact and migration path for users --> ## References <!-- Please list any other resources or points the reviewer should be aware of --> - [스레드 (internal)](https://desk.channel.io/root/threads/groups/WebBezier-124831/67fe14f4337dc20e469a/67fe14f4337dc20e469a) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Select 컴포넌트의 `text` 속성이 문자열뿐만 아니라 다양한 React 노드를 지원하도록 확장되었습니다. 이제 텍스트, 숫자, 요소, 프래그먼트 등 다양한 형태로 내용을 전달할 수 있습니다. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8d68bf7 commit 82012cf

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

.changeset/chatty-glasses-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@channel.io/bezier-react': minor
3+
---
4+
5+
Expand type of `text` props to ReactNode

packages/bezier-react/src/components/Select/Select.tsx

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,36 @@ export const Select = forwardRef<SelectRef, SelectProps>(function Select(
115115

116116
const hasContent = !isEmpty(text)
117117

118+
const Content = (() => {
119+
if (!hasContent) {
120+
return (
121+
<Text
122+
data-testid="bezier-select-trigger-text"
123+
typo="14"
124+
truncated
125+
color="txt-black-dark"
126+
>
127+
{placeholder}
128+
</Text>
129+
)
130+
}
131+
132+
if (typeof text === 'string') {
133+
return (
134+
<Text
135+
data-testid="bezier-select-trigger-text"
136+
typo="14"
137+
truncated
138+
color={textColor}
139+
>
140+
{text}
141+
</Text>
142+
)
143+
}
144+
145+
return text
146+
})()
147+
118148
return (
119149
<div
120150
style={style}
@@ -146,14 +176,7 @@ export const Select = forwardRef<SelectRef, SelectProps>(function Select(
146176
leftContent
147177
)}
148178

149-
<Text
150-
data-testid="bezier-select-trigger-text"
151-
typo="14"
152-
truncated
153-
color={hasContent ? textColor : 'txt-black-dark'}
154-
>
155-
{hasContent ? text : placeholder}
156-
</Text>
179+
{Content}
157180

158181
{isBezierIcon(rightContent) ? (
159182
<Icon

packages/bezier-react/src/components/Select/Select.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type ReactNode } from 'react'
2+
13
import { type BezierIcon } from '@channel.io/bezier-icons'
24

35
import type {
@@ -23,7 +25,7 @@ export interface SelectRef {
2325
interface SelectOwnProps {
2426
defaultFocus?: boolean
2527
placeholder?: string
26-
text?: string
28+
text?: ReactNode
2729
withoutChevron?: boolean
2830
dropdownContainer?: HTMLElement | null
2931
dropdownMarginX?: OverlayProps['marginX']

0 commit comments

Comments
 (0)