Skip to content

Instantly share code, notes, and snippets.

@harrybeckwith
harrybeckwith / App.vue
Last active April 2, 2019 16:58
vue js lightbox data
<script>
export default {
data() {
return {
lightbox: {
images: {
thumbnails: ["1.jpg", "2.jpg", "3.jpg"],
large: ["1.jpg", "2.jpg", "3.jpg"]
},
captions: ["surfing", "swimming","running"],
@harrybeckwith
harrybeckwith / lightbox.vue
Created April 2, 2019 16:25
lightbox vue component
<template>
<div>
<img
@click="lightboxEffect(index)"
v-for="(thumbnail, index) in thumbnails"
:key="thumbnail"
:src="thumbnailsPath + thumbnail"
class="light-box__thumbnail"
>
<transition name="fade" mode="out-in">
@harrybeckwith
harrybeckwith / lightbox.vue
Last active April 2, 2019 16:43
lightbox basics template inside lightbox.vue
<template>
<div>
<img
@click="lightboxEffect(index)"
v-for="(thumbnail, index) in thumbnails"
:key="thumbnail"
:src="thumbnailsPath + thumbnail"
class="light-box__thumbnail"
>
@harrybeckwith
harrybeckwith / app.vue
Created April 2, 2019 16:56
Lightbox component inside app.vue showing data being passed in
<template>
<section class="container">
<LightBox
:thumbnails="lightbox.images.thumbnails"
:largeImages="lightbox.images.large"
:thumbnailsPath="lightbox.thumbnailsPath"
:largePath="lightbox.largePath"
:captions="lightbox.captions"
class="lightBox"
/>
@harrybeckwith
harrybeckwith / app.vue
Created April 3, 2019 13:00
app.vue file for full working version
<template>
<section>
<h2>Light box</h2>
<LightBox
:thumbnails="lightbox.images.thumbnails"
:largeImages="lightbox.images.large"
:thumbnailsPath="lightbox.thumbnailsPath"
:largePath="lightbox.largePath"
:captions="lightbox.captions"
class="lightBox"
@harrybeckwith
harrybeckwith / lightbox.vue
Created April 3, 2019 13:01
light vue file complete code
<template>
<div>
<img
@click="lightboxEffect(index)"
v-for="(thumbnail, index) in thumbnails"
:key="thumbnail"
:src="thumbnailsPath + thumbnail"
class="light-box__thumbnail"
>
<transition name="fade" mode="out-in">
@harrybeckwith
harrybeckwith / main.js
Created April 3, 2019 16:18
Adding vue router to main.js
import Vue from 'vue'
import VueRouter from 'vue-router';
import App from './App.vue'
import { routes } from './routes';
Vue.use(VueRouter);
const router = new VueRouter({
routes,
mode: 'history'
@harrybeckwith
harrybeckwith / routes.js
Created April 3, 2019 16:22
routes.js file containing routes
import User from './components/user/User.vue';
import UserStart from './components/user/UserStart.vue';
import UserDetail from './components/user/UserDetail.vue';
import UserEdit from './components/user/UserEdit.vue';
import Home from './components/Home.vue';
import Header from './components/Header.vue';
export const routes = [
{ path: '', name: 'home', components: {
default: Home,
@harrybeckwith
harrybeckwith / store.js
Created July 23, 2019 09:21
store js file with state and getters set up
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
user: { id: 'aaa', name: 'Adsasas' },
events: [
{
@harrybeckwith
harrybeckwith / Component.vue
Created July 23, 2019 09:22
mapGetters and mapState
<template>
<div>
<h1>Create Event {{ userName}}</h1>
<p>There are {{catLength}} categories</p>
<ul>
<li v-for="cat in categories" :key="cat">
{{cat}}
</li>
</ul>
<p>