Skip to content

Commit

Permalink
feat: add data-test to PuikTag
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume60240 committed Oct 31, 2023
1 parent 91b0ef4 commit 29e76ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/components/tag/src/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const tagProps = buildProps({
Required: false,
default: 'bottom',
},
dataTest: {
type: String,
required: false,
default: undefined,
},
} as const)

export type TagProps = ExtractPropTypes<typeof tagProps>
Expand Down
3 changes: 2 additions & 1 deletion packages/components/tag/src/tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
]"
>
<PuikIcon v-if="icon && icon != ''" :icon="icon" class="puik-tag__icon" />
<div class="puik-tag__content">
<div class="puik-tag__content" :data-test="`content-${dataTest}`">
<puik-tooltip
v-if="content?.length >= 30"
:position="(tooltipPosition as PuikTooltipPosition)"
:description="content"
:data-test="`tooltip-${dataTest}`"
>
<template #description>{{ content }}</template>
{{ content }}
Expand Down
5 changes: 5 additions & 0 deletions packages/components/tag/stories/tag.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ export default {
},
},
},
dataTest: {
description:
'Set the data-test attribute `content-${dataTest}` `tooltip-${dataTest}`',
control: 'text',
},
},
args: {
id: 'puik-tag-id',
Expand Down

0 comments on commit 29e76ee

Please sign in to comment.