Commit 4bb27020 authored by Cole Bemis's avatar Cole Bemis

Move script to main.js

parent 7ce70f6c
...@@ -39,65 +39,6 @@ ...@@ -39,65 +39,6 @@
</div> </div>
</script> </script>
<script> <script src="src/main.js"></script>
const data = {
icons: [
'square',
'circle',
'rectangle-vertical',
'rectangle-horizontal'
]
};
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);
});
}
});
Vue.component('icon-container', {
props: {
name: {
type: String,
required: true
}
},
template: '#icon-container-template'
})
new Vue({
el: '#app',
data: data
});
</script>
</body> </body>
</html> </html>
\ No newline at end of file
const data = {
icons: [
'square',
'circle',
'rectangle-vertical',
'rectangle-horizontal'
]
};
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);
});
}
});
Vue.component('icon-container', {
props: {
name: {
type: String,
required: true
}
},
template: '#icon-container-template'
})
new Vue({
el: '#app',
data: data
});
\ 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