Skip to content

Instantly share code, notes, and snippets.

View cristijora's full-sized avatar

Cristi Jora cristijora

View GitHub Profile
export default {
props: {
order: {
type: Object,
default: () => ({})
}
},
computed:{
grandTotal() {
let total = (this.order.total + this.order.tax) * (1 - this.order.discount);
@cristijora
cristijora / computed-effects.js
Created June 30, 2019 16:38
Computed side effects
export default {
data() {
return {
array: [1, 2, 3]
};
},
computed: {
reversedArray() {
return this.array.reverse(); // SIDE EFFECT - mutates a data property
}
@cristijora
cristijora / user.js
Created May 22, 2019 14:57
User module for auth
import AuthService from '@/services/AuthService';
const types = {
SET_USER: 'SET_USER',
SET_APP_TOKEN: 'SET_APP_TOKEN',
SET_LOGGED_IN: 'SET_LOGGED_IN',
RESET_STATE: 'RESET_STATE',
};
function getDefaultState() {
@cristijora
cristijora / store.js
Created May 22, 2019 14:55
Auth store
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate';
import user from '@/store/modules/user';
Vue.use(Vuex);
export default new Vuex.Store({
plugins: [createPersistedState({
paths: ['user']
})],
@cristijora
cristijora / authMiddleware.js
Created May 22, 2019 14:52
Vue.js authentication
import jwtDecode from 'jwt-decode'
let loginRoute = {
path: '/login'
};
function redirectToLogin(next) {
return next(loginRoute);
}
@cristijora
cristijora / switch.vue
Created January 9, 2019 11:42
Bootstrap switch vue component
<template>
<div
class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-animate"
:class="switchClass"
>
<div class="bootstrap-switch-container" @click="triggerToggle()">
<span class="bootstrap-switch-handle-on ">
<slot name="on"> {{ onText }} </slot>
</span>
<span class="bootstrap-switch-label"></span>
@cristijora
cristijora / vectormaps.vue
Created January 9, 2019 10:02
Vector maps with d3, topojson and datamaps
<template>
<div id="worldMap" style="height: 300px;"></div>
</template>
<script>
import 'd3';
import * as d3 from 'd3';
import 'topojson';
import DataMap from 'datamaps';
import { throttle } from 'src/util/throttle';
@cristijora
cristijora / Full calendar
Created January 9, 2019 09:59
Full calendar without jquery
<template>
<div class="container-fluid">
<div class="row">
<div class="col-md-10 ml-auto mr-auto">
<div class="card card-calendar">
<div class="card-body">
<div id="fullCalendar" ref="calendar"></div>
</div>
</div>
</div>
### Keybase proof
I hereby claim:
* I am cristijora on github.
* I am cristijora (https://keybase.io/cristijora) on keybase.
* I have a public key ASCi8ExRk54RTKqwGQflklHgGd9hi3F9EV9xlTcTv1Ts4Qo
To claim this, I am signing this object:
@cristijora
cristijora / light-bootstrap-main.js
Created January 24, 2018 14:23
LBD PRO polyfills
// simply import the file above.
import './pollyfills'