Skip to content

Commit 8fa44a8

Browse files
authored
Merge pull request #742 from glints-dev/feature/add-text-color-prop-to-tag
feat: add text color prop to Tag component
2 parents 7f46b04 + 9ecad32 commit 8fa44a8

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

src/@next/RadioButton/RadioButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { HtmlHTMLAttributes } from 'react';
1+
import React from 'react';
22
import {
33
LabelWrapper,
44
RadioButtonInput,

src/@next/Tag/Tag.stories.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export default {
2525
type: null,
2626
},
2727
},
28+
textColor: {
29+
description: 'Text color of the tag',
30+
control: 'color',
31+
},
2832
},
2933

3034
parameters: {
@@ -37,8 +41,8 @@ export default {
3741
},
3842
} as Meta;
3943

40-
const DefaultTemplate: Story<TagProps> = () => {
41-
return <Tag>Basic Tag</Tag>;
44+
const DefaultTemplate: Story<TagProps> = args => {
45+
return <Tag {...args}>Basic Tag</Tag>;
4246
};
4347

4448
const RemoveableTemplate: Story<TagProps> = () => {

src/@next/Tag/Tag.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@ export interface TagProps extends React.HTMLAttributes<HTMLDivElement> {
1313
children?: React.ReactNode;
1414
value?: string;
1515
onRemove?: (() => void) | null;
16+
textColor?: string;
1617
}
1718

1819
export type TagRemoveContainerProps = React.HTMLAttributes<HTMLDivElement>;
1920

2021
export type TagContentProps = React.HTMLAttributes<HTMLSpanElement> & TagProps;
2122

2223
export const Tag = React.forwardRef<HTMLDivElement, TagProps>(function Tag(
23-
{ children, onRemove, value, ...props }: TagProps,
24+
{ children, onRemove, value, textColor, ...props }: TagProps,
2425
ref
2526
) {
2627
const content =
27-
typeof children === 'string' ? (
28-
<Typography variant="caption" color={Neutral.B18} as={'span'}>
28+
typeof children === 'string' || typeof children === 'number' ? (
29+
<Typography
30+
variant="caption"
31+
color={textColor ?? Neutral.B18}
32+
as={'span'}
33+
>
2934
{children}
3035
</Typography>
3136
) : (

test/e2e/tag/tag.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ test('Tag - small size', async ({ page }) => {
2020
await expect(tagPage.container).toHaveScreenshot('tag-small-size.png');
2121
});
2222

23+
test('Tag - custom text color', async ({ page }) => {
24+
const tagPage = getPage(page);
25+
await tagPage.goto('args=textColor:!hex(3fde00)');
26+
await expect(tagPage.container).toHaveScreenshot('tag-custom-text-color.png');
27+
});
28+
2329
test('removeable tag - standard size', async ({ page }) => {
2430
const tagPage = getRemoveableTagPage(page);
2531
await tagPage.goto();
2.14 KB
Loading
171 Bytes
Loading
197 Bytes
Loading

0 commit comments

Comments
 (0)