Skip to content

Commit

Permalink
feat: handle dynamic component for notification
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetansenn committed Jun 9, 2022
1 parent 8dfdf5a commit fc1534f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/components/others/notification/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
@mouseout="$emit('resume')"
@click="to && $emit('close')"
>
<component :is="to ? 'nuxt-link' : 'div'" :to="to" :class="config.fixed">
<component :is="is" v-bind="bind" :class="component ? '' : config.fixed">
<div :class="[config.type.classes, config.type.fixed]" v-html="config.type.icon" />
<div :class="config.body.fixed">
<p v-if="title" :class="config.body.title">
{{ title }}
</p>
<p v-if="title" :class="config.body.title" v-html="title" />
<!-- eslint-disable-next-line -->
<p v-if="description" :class="config.body.description" v-html="description" />
</div>
Expand Down Expand Up @@ -42,6 +40,11 @@ export default {
return ['info', 'success', 'error'].includes(value)
}
},
/* { name: String, bind: any } */
component: {
type: Object,
default: null
},
title: {
type: String,
default: null
Expand All @@ -54,6 +57,14 @@ export default {
type: [String, Object],
default: null
}
},
computed: {
bind () {
return this.component ? this.component.bind : this.to
},
is () {
return this.component?.name || (this.to ? 'NuxtLink' : 'div')
}
}
}
</script>

0 comments on commit fc1534f

Please sign in to comment.