Skip to content

Commit

Permalink
chore(lib): update Tag
Browse files Browse the repository at this point in the history
- `Tag` migrates to Vue 3. Changes sufficient to render the
  documentation page of `Tag` are made.
- In `src/components/tag/Tag.vue`,
    - The "click", and "close" events are listed in `emits`.
    - `disabled` attribute is bound to a new computed value
      `disabledOrUndefined` that takes `true` or `undefined`. Setting
      a boolean attribute to `false` does not remove it on Vue 3, but
      `null` or `undefined` has to be given to remove it.
    - ESLint fix is applied.
  • Loading branch information
kikuomax committed Jul 7, 2023
1 parent c635a5a commit f694e82
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/components/tag/Tag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@
<div v-if="attached && closable" class="tags has-addons">
<span
class="tag"
:class="[type, size, { 'is-rounded': rounded }]">
:class="[type, size, { 'is-rounded': rounded }]"
>
<b-icon
v-if="icon"
:icon="icon"
:size="size"
:type="iconType"
:pack="iconPack" />
:pack="iconPack"
/>
<span :class="{ 'has-ellipsis': ellipsis }" @click="click">
<slot/>
<slot />
</span>
</span>
<a
class="tag"
role="button"
:aria-label="ariaCloseLabel"
:tabindex="tabstop ? 0 : false"
:disabled="disabled"
:disabled="disabledOrUndefined"
:class="[size,
closeType,
{'is-rounded': rounded},
closeIcon ? 'has-delete-icon' : 'is-delete']"
@click="close"
@keyup.delete.prevent="close">
@keyup.delete.prevent="close"
>
<b-icon
custom-class=""
v-if="closeIcon"
Expand All @@ -38,15 +41,17 @@
<span
v-else
class="tag"
:class="[type, size, { 'is-rounded': rounded }]">
:class="[type, size, { 'is-rounded': rounded }]"
>
<b-icon
v-if="icon"
:icon="icon"
:size="size"
:type="iconType"
:pack="iconPack" />
:pack="iconPack"
/>
<span :class="{ 'has-ellipsis': ellipsis }" @click="click">
<slot/>
<slot />
</span>

<a
Expand All @@ -55,7 +60,7 @@
:aria-label="ariaCloseLabel"
class="delete is-small"
:class="closeType"
:disabled="disabled"
:disabled="disabledOrUndefined"
:tabindex="tabstop ? 0 : false"
@click="close"
@keyup.delete.prevent="close"
Expand Down Expand Up @@ -87,6 +92,14 @@ export default {
closeIconPack: String,
closeIconType: String
},
emits: ['click', 'close'],
computed: {
// setting a boolean attribute `false` does not remove it on Vue 3.
// `null` or `undefined` has to be given to remove it.
disabledOrUndefined() {
return this.disabled || undefined
}
},
methods: {
/**
* Emit close event when delete button is clicked
Expand Down

0 comments on commit f694e82

Please sign in to comment.