Skip to content

Instantly share code, notes, and snippets.

@ltrademark
Created June 1, 2022 17:07
Show Gist options
  • Save ltrademark/3ea06e3ff4d6cb0c701819cd2e677fda to your computer and use it in GitHub Desktop.
Save ltrademark/3ea06e3ff4d6cb0c701819cd2e677fda to your computer and use it in GitHub Desktop.
A simple icon template to use in a vue project. Pulls content from the SVG in a sub-direectory and insterts it into the item.
<template>
<div class="z-icon" v-html="require(`./icons/${this.fixedName}.svg?raw`)"></div>
</template>
<script>
export default {
props: {
name: {
type: String
}
},
mounted() {},
computed: {
fixedName() {
return this.name.toLowerCase();
}
}
}
</script>
<style lang="scss">
.z-icon {
display: inline-flex;
align-items: center;
justify-content: center;
}
svg {
display: block;
color: inherit;
height: 1em;
width: auto;
transition: 335ms ease-in-out all;
.st0 {
fill: none;
stroke: currentColor;
stroke-width:2;
stroke-linecap:round;
stroke-linejoin:round;
&.fl {
fill: currentColor;
}
}
.fl0 {
fill: currentColor;
stroke: none;
&.st {
stroke: currentColor;
stroke-width:2;
stroke-linecap:round;
stroke-linejoin:round;
}
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment