Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/funny-eyes-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@channel.io/bezier-react': patch
---

Add truncated props in the Badge
Copy link
Collaborator

@yangwooseong yangwooseong Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(minor)

Suggested change
Add truncated props in the Badge
Add `truncated` props in the Badge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다!

28 changes: 28 additions & 0 deletions packages/bezier-react/src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { AppleIcon } from '@channel.io/bezier-icons'
import { type Meta, type StoryFn, type StoryObj } from '@storybook/react'

import { Box } from '~/src/components/Box'

import { Badge } from './Badge'
import { type BadgeProps } from './Badge.types'

Expand All @@ -14,6 +16,12 @@ const Template: StoryFn<BadgeProps> = ({ children, ...badgeProps }) => (
<Badge {...badgeProps}>{children}</Badge>
)

const Truncated: StoryFn<BadgeProps> = ({ children, ...badgeProps }) => (
<Box width={200}>
<Badge {...badgeProps}>{children}</Badge>
</Box>
)

export const Primary: StoryObj<BadgeProps> = {
render: Template,

Expand All @@ -23,4 +31,24 @@ export const Primary: StoryObj<BadgeProps> = {
icon: AppleIcon,
variant: 'default',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Primary에서도 배포버전에서 truncated: set object 의 control이 생깁니다. 없앨 예정입니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 작업 중이신가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네네 죄송합니다 제가 요즘 특히 일이 바빠서 주중에는 힘드네요
혹시 언제까지 진행하면 될까요?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

급한건 전혀 아니라 편하게 작업해주셔도 됩니다 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영했습니다~

},
argTypes: {
truncated: {
table: {
disable: true,
},
},
},
}

export const Secondary: StoryObj<BadgeProps> = {
render: Truncated,

args: {
children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
size: 'm',
icon: AppleIcon,
variant: 'default',
truncated: true,
},
name: 'Truncated',
}
3 changes: 2 additions & 1 deletion packages/bezier-react/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const BADGE_TEST_ID = 'bezier-badge'
*/
export const Badge = memo(
forwardRef<HTMLDivElement, BadgeProps>(function Badge(
{ size = 'm', variant = 'default', icon, children, ...rest },
{ size = 'm', variant = 'default', truncated ,icon, children, ...rest },
forwardedRef
) {
return (
Expand All @@ -48,6 +48,7 @@ export const Badge = memo(
<BaseTagBadgeText
size={size}
marginHorizontal={3}
truncated={truncated}
>
{children}
</BaseTagBadgeText>
Expand Down
6 changes: 6 additions & 0 deletions packages/bezier-react/src/components/Badge/Badge.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ interface BadgeOwnProps {
* Icon to be shown on the left side of the badge.
*/
icon?: BezierIcon
/**
* Whether the text is truncated.
* If it is a positive integer, it means the maximum number of lines.
* @default false
*/
truncated?: boolean | number
}

export interface BadgeProps
Expand Down
Loading