Created
May 6, 2017 06:44
-
-
Save TravisMullen/a7c916802aca4af513bf874004e076f0 to your computer and use it in GitHub Desktop.
"Call-to-action" SVG Component Vue.js
This file contains hidden or 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"> | |
router-link.button.large(:to='route') | |
| {{ message }} | |
.svg-icon.postfix.fill-white( | |
v-once='', | |
v-html='icon' | |
) | |
</template> | |
<script> | |
// REQUIRED: npm install svg-inline-loader pug --save-dev | |
export default { | |
name: 'call-to-action', | |
props: { | |
// name of file from `/src/assets/svg/*` | |
iconName: { | |
type: String, | |
required: true | |
}, | |
// text inside button | |
message: { | |
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/svg/${this.iconName}.svg`) | |
return file | |
} | |
} | |
} | |
</script> | |
<style lang="scss" scoped> | |
// call settings for global SCSS access | |
// @import '~@/styles/settings'; | |
.button { | |
// margin: $global-padding*3; | |
filter: drop-shadow(rem-calc(1) rem-calc(2) rem-calc(2) rgba(0, 0, 0, 0.3)); | |
&:hover { | |
filter: drop-shadow(rem-calc(1) rem-calc(2) rem-calc(2) rgba(0, 0, 0, 0.4)); | |
} | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment