2017-01-24 09:57:25 +03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2017-01-26 07:44:58 +03:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>Feather</title>
|
2017-01-26 10:21:52 +03:00
|
|
|
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
display: inline-block;
|
|
|
|
line-height: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon > svg {
|
|
|
|
stroke: currentColor;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script src="https://unpkg.com/vue/dist/vue.js"></script>
|
2017-01-24 09:57:25 +03:00
|
|
|
</head>
|
|
|
|
<body>
|
2017-01-26 07:44:58 +03:00
|
|
|
|
2017-01-26 10:21:52 +03:00
|
|
|
<div id="app">
|
|
|
|
<icon-container v-for="icon in icons" :name="icon"></icon-container>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/x-template" id="icon-template">
|
|
|
|
<div class="icon"></div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/x-template" id="icon-container-template">
|
|
|
|
<div class="icon-container">
|
|
|
|
<a :href="`./icons/${name}.svg`" download>
|
|
|
|
<icon :name="name" size="48"></icon>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</script>
|
2017-01-26 07:44:58 +03:00
|
|
|
|
|
|
|
<script>
|
2017-01-26 10:21:52 +03:00
|
|
|
const data = {
|
|
|
|
icons: [
|
|
|
|
'square',
|
|
|
|
'circle'
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
Vue.component('icon', {
|
|
|
|
props: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
type: String,
|
|
|
|
default: '24'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template: '#icon-template',
|
|
|
|
mounted() {
|
|
|
|
fetch(`./icons/${this.name}.svg`)
|
|
|
|
.then(response => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.text();
|
|
|
|
}
|
|
|
|
throw new Error(`Cannot find ${this.name}.svg`);
|
|
|
|
})
|
|
|
|
.then(svgText => {
|
|
|
|
const svgDocument = new DOMParser().parseFromString(svgText, 'image/svg+xml');
|
|
|
|
const svgIcon = svgDocument.querySelector('svg').cloneNode(true);
|
|
|
|
|
|
|
|
svgIcon.setAttribute('width', this.size);
|
|
|
|
svgIcon.setAttribute('height', this.size);
|
|
|
|
|
|
|
|
this.$el.appendChild(svgIcon);
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
console.error(error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2017-01-26 07:44:58 +03:00
|
|
|
|
2017-01-26 10:21:52 +03:00
|
|
|
Vue.component('icon-container', {
|
|
|
|
props: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
template: '#icon-container-template'
|
|
|
|
})
|
2017-01-26 07:44:58 +03:00
|
|
|
|
2017-01-26 10:21:52 +03:00
|
|
|
new Vue({
|
|
|
|
el: '#app',
|
|
|
|
data: data
|
|
|
|
});
|
2017-01-26 07:44:58 +03:00
|
|
|
</script>
|
2017-01-24 09:57:25 +03:00
|
|
|
</body>
|
|
|
|
</html>
|