File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ describe('DsfrTag', () => {
3131 const firstTagEl = getByText ( label )
3232
3333 // Then
34- expect ( firstTagEl . parentNode ) . toHaveClass ( 'fr-tag' )
34+ expect ( firstTagEl ) . toHaveClass ( 'fr-tag' )
3535 } )
3636
3737 it ( 'should render small simple tag' , ( ) => {
@@ -56,8 +56,8 @@ describe('DsfrTag', () => {
5656 const firstTagEl = getByText ( label )
5757
5858 // Then
59- expect ( firstTagEl . parentNode ) . toHaveClass ( 'fr-tag' )
60- expect ( firstTagEl . parentNode ) . toHaveClass ( 'fr-tag--sm' )
59+ expect ( firstTagEl ) . toHaveClass ( 'fr-tag' )
60+ expect ( firstTagEl ) . toHaveClass ( 'fr-tag--sm' )
6161 } )
6262} )
6363
@@ -92,7 +92,7 @@ describe('DsfrTags', () => {
9292 const secondTagEl = getByText ( label2 )
9393
9494 // Then
95- expect ( firstTagEl . parentNode ) . toHaveClass ( 'fr-tag' )
96- expect ( secondTagEl . parentNode ) . toHaveClass ( 'fr-tag' )
95+ expect ( firstTagEl ) . toHaveClass ( 'fr-tag' )
96+ expect ( secondTagEl ) . toHaveClass ( 'fr-tag' )
9797 } )
9898} )
Original file line number Diff line number Diff line change 22import { computed } from ' vue'
33import { OhVueIcon as VIcon } from ' oh-vue-icons'
44
5- // TODO: Pourquoi icône 'check' quand on utilise ce js et qu’on clique sur le premier ?
6- // D’autre part, pour les étiquettes sélectionnables posent problème : le JS n’est pas
7- // import '@gouvfr/dsfr/dist/component/tag/tag.module.js'
8-
95import type { DsfrTagProps } from ' ./DsfrTags.types'
106
117export type { DsfrTagProps }
@@ -28,6 +24,10 @@ const is = computed(() => {
2824const linkProps = computed (() => {
2925 return { [isExternalLink .value ? ' href' : ' to' ]: props .link }
3026})
27+
28+ const dsfrIcon = computed (() => typeof props .icon === ' string' && props .icon .startsWith (' fr-icon-' ))
29+ const defaultScale = 0.9
30+ const iconProps = computed (() => typeof props .icon === ' string' ? { name: props .icon , scale: defaultScale } : { scale: defaultScale , ... props .icon })
3131 </script >
3232
3333<template >
@@ -37,16 +37,18 @@ const linkProps = computed(() => {
3737 :disabled =" disabled"
3838 :class =" {
3939 'fr-tag--sm': small,
40+ [icon]: dsfrIcon,
4041 }"
4142 v-bind =" linkProps"
4243 >
4344 <VIcon
4445 v-if =" icon"
45- :name =" icon"
4646 :label =" iconOnly ? label : undefined"
47- :scale = " 0.9 "
47+ v-bind = " iconProps "
4848 />
49- <span v-if =" !iconOnly" >{{ label }}</span >
49+ <template v-if =" ! iconOnly " >
50+ {{ label }}
51+ </template >
5052 <slot />
5153 </component >
5254</template >
You can’t perform that action at this time.
0 commit comments