2018-03-17 18:26:18 +05:30
|
|
|
<script>
|
2018-10-15 14:42:47 +05:30
|
|
|
/* This is a re-usable vue component for rendering a svg sprite
|
|
|
|
icon
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
Sample configuration:
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
<icon
|
|
|
|
name="retry"
|
|
|
|
:size="32"
|
|
|
|
css-classes="top"
|
|
|
|
/>
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
*/
|
|
|
|
// only allow classes in images.scss e.g. s12
|
|
|
|
const validSizes = [8, 12, 16, 18, 24, 32, 48, 72];
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
size: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 16,
|
|
|
|
validator(value) {
|
|
|
|
return validSizes.includes(value);
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
cssClasses: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
width: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
height: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
y: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
x: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: null,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
computed: {
|
|
|
|
spriteHref() {
|
|
|
|
return `${gon.sprite_icons}#${this.name}`;
|
|
|
|
},
|
|
|
|
iconTestClass() {
|
|
|
|
return `ic-${this.name}`;
|
|
|
|
},
|
|
|
|
iconSizeClass() {
|
|
|
|
return this.size ? `s${this.size}` : '';
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2018-10-15 14:42:47 +05:30
|
|
|
},
|
|
|
|
};
|
2018-03-17 18:26:18 +05:30
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<svg
|
2018-10-15 14:42:47 +05:30
|
|
|
:class="[iconSizeClass, iconTestClass, cssClasses]"
|
2018-03-17 18:26:18 +05:30
|
|
|
:width="width"
|
|
|
|
:height="height"
|
|
|
|
:x="x"
|
2018-10-15 14:42:47 +05:30
|
|
|
:y="y"
|
|
|
|
>
|
2018-03-17 18:26:18 +05:30
|
|
|
<use v-bind="{ 'xlink:href':spriteHref }" />
|
|
|
|
</svg>
|
|
|
|
</template>
|