Commit 9ce3c68a authored by Cole Bemis's avatar Cole Bemis

Import Vue

parent 9cbd7ca2
This diff is collapsed.
......@@ -18,26 +18,24 @@
stroke: currentColor;
}
</style>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<icon-container v-for="icon in icons" :name="icon"></icon-container>
<!-- <icon-container v-for="icon in icons" :name="icon"></icon-container> -->
</div>
<script type="text/x-template" id="icon-template">
<!-- <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>
<a :href="`icons/${name}.svg`" download>
<icon :name="name" size="48"></icon>
</a>
</div>
</script>
</script> -->
<script src="bundle.js"></script>
</body>
......
import Vue from 'vue';
const data = {
icons: [
'square',
......@@ -7,50 +9,50 @@ const data = {
]
};
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);
// 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);
// svgIcon.setAttribute('width', this.size);
// svgIcon.setAttribute('height', this.size);
this.$el.appendChild(svgIcon);
})
.catch(error => {
console.error(error);
});
}
});
// this.$el.appendChild(svgIcon);
// })
// .catch(error => {
// console.error(error);
// });
// }
// });
Vue.component('icon-container', {
props: {
name: {
type: String,
required: true
}
},
template: '#icon-container-template'
})
// Vue.component('icon-container', {
// props: {
// name: {
// type: String,
// required: true
// }
// },
// template: '#icon-container-template'
// })
new Vue({
el: '#app',
......
......@@ -14,5 +14,10 @@ module.exports = {
exclude: /node_modules/
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.common.js'
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment