diff --git a/README.md b/README.md index 9203226..69ac9fd 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ Then we add the file path inside the plugins key in `nuxt.config.js`, and set `m | `width` | Width of icon | `string` | - | - | | `height` | Height of icon | `string` | - | - | | `fill` | Fill color of icon | `string` | HEX or color name | - | +| `hover-fill` | Fill color on hover| `string` | HEX or color name | - | | `icon-style` | Icon style | `string` | line / monochrome | line | ## Events diff --git a/src/components/Unicon.vue b/src/components/Unicon.vue index 6a5835f..ebb271e 100644 --- a/src/components/Unicon.vue +++ b/src/components/Unicon.vue @@ -6,9 +6,11 @@ :width="width" :height="height" :viewBox.camel="viewBox" - :fill="fill" + :fill="localFill" v-bind="$attrs" @click="$emit('click')" + @mouseover="onHover" + @mouseout="onLeave" v-html="icon" /> @@ -41,6 +43,10 @@ export default { type: String, default: 'inherit' }, + hoverFill: { + type: String, + default: null + }, viewBox: { type: String, default: '0 0 24 24' @@ -57,6 +63,12 @@ export default { } }, + data () { + return { + localFill: this.fill + } + }, + computed: { icon () { const icon = this.$options.lib.find( @@ -66,10 +78,22 @@ export default { if (icon) { return icon.path } else { - console.error(`Name '${ this.name }' of the icon is not correct`) + console.error(`Name '${this.name}' of the icon is not correct`) return undefined } } + }, + methods: { + onHover () { + if (this.hoverFill) { + this.localFill = this.hoverFill + } + }, + onLeave () { + if (this.hoverFill) { + this.localFill = this.fill + } + } } } @@ -77,7 +101,9 @@ export default {