Skip to content

Commit

Permalink
fix(tag): allow data attributes on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Lee committed Sep 22, 2022
1 parent bc32a2c commit 5aeaa9c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/components/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ export const ColorVariants: StoryObj<Args> = {
render: (args) => (
<div className={styles.tagList}>
{VARIANTS.map((variant) => {
return <Tag key={variant} {...args} text={variant} variant={variant} />;
return (
<Tag
data-testid="test"
key={variant}
{...args}
text={variant}
variant={variant}
/>
);
})}
</div>
),
Expand Down
9 changes: 8 additions & 1 deletion src/components/Tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const Tag = ({
icon,
text,
hasOutline = false,
...other
}: Props) => {
const componentClassName = clsx(
styles['tag'],
Expand All @@ -61,7 +62,13 @@ export const Tag = ({
);

return (
<Text as="span" className={componentClassName} size="sm" weight="bold">
<Text
as="span"
className={componentClassName}
size="sm"
weight="bold"
{...other}
>
{icon}
{text && <span className={styles['tag__body']}>{text}</span>}
</Text>
Expand Down
6 changes: 6 additions & 0 deletions src/components/Tag/__snapshots__/Tag.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
>
<span
class="text text--sm text--bold-weight tag tag--neutral"
data-testid="test"
>
<span
class="tag__body"
Expand All @@ -15,6 +16,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
</span>
<span
class="text text--sm text--bold-weight tag tag--error"
data-testid="test"
>
<span
class="tag__body"
Expand All @@ -24,6 +26,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
</span>
<span
class="text text--sm text--bold-weight tag tag--success"
data-testid="test"
>
<span
class="tag__body"
Expand All @@ -33,6 +36,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
</span>
<span
class="text text--sm text--bold-weight tag tag--warning"
data-testid="test"
>
<span
class="tag__body"
Expand All @@ -42,6 +46,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
</span>
<span
class="text text--sm text--bold-weight tag tag--yield"
data-testid="test"
>
<span
class="tag__body"
Expand All @@ -51,6 +56,7 @@ exports[`<Tag /> ColorVariants story renders snapshot 1`] = `
</span>
<span
class="text text--sm text--bold-weight tag tag--brand"
data-testid="test"
>
<span
class="tag__body"
Expand Down

0 comments on commit 5aeaa9c

Please sign in to comment.