25.06.2018 Views

Full-Stack Vue.js 2 and Laravel 5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CarouselControl<br />

Let's now abstract our CarouselControl component into an SFC, <strong>and</strong> move any<br />

relevant CSS rules from resources/assets/css/style.css as well.<br />

resources/assets/components/CarouselControl.vue: export default { props: [ 'dir' ],<br />

computed: { classes() { return 'carousel-control fa fa-2x fa-chevron-' + this.dir; }<br />

}, methods: { clicked() { this.$emit('change-image', this.dir === 'left' ? -1 : 1); }<br />

} } .carousel-control { padding: 1rem; color: #ffffff; opacity:<br />

0.85<br />

}<br />

@media (min-width: 744px) { .carousel-control { font-size: 3rem; } } <br />

This file can now be imported by the ImageCarousel component.<br />

resources/assets/components/ImageCarousel.vue: ... import<br />

CarouselControl from '../components/CarouselControl.vue';<br />

export default { ... components: { CarouselControl<br />

} } ...<br />

With that done, our existing components have been refactored to SFCs. This has<br />

not made any obvious difference to the functionality of our app (although it is<br />

slightly faster, as I'll explain later), but it will make development easier as we<br />

continue.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!