Created
August 5, 2017 16:45
-
-
Save TravisMullen/1fc33542b866c027e5ffafc530f37a54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template lang="pug"> | |
a.button.icon-link( | |
target='_blank', | |
:href='route', | |
:title='title' | |
) | |
.svg-icon.small.fill-cream( | |
v-once='', | |
v-html='icon' | |
) | |
</template> | |
<script> | |
// REQUIRED: npm install svg-inline-loader pug --save-dev | |
export default { | |
name: 'icon-link', | |
props: { | |
// name of file from `/src/assets/svg/*` | |
iconName: { | |
type: String, | |
required: true | |
}, | |
// text inside button | |
title: { | |
type: String, | |
required: true | |
}, | |
// named route for `vuejs/vue-router` | |
// https://router.vuejs.org/en/essentials/named-routes.html | |
route: { | |
type: String, | |
required: true | |
} | |
}, | |
computed: { | |
icon () { | |
const file = require(`!svg-inline-loader!@/assets/icons/${this.iconName}.svg`) | |
return file | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment