Skip to content

Instantly share code, notes, and snippets.

View LinusBorg's full-sized avatar
I may be slow to respond.

Thorsten Lünborg LinusBorg

I may be slow to respond.
View GitHub Profile
@LinusBorg
LinusBorg / Masonry.vue
Last active June 24, 2019 11:57
Example of proposed Vue setup method
<template>
<div ref="container">
<transition-group name="flip">
<div
v-for="item in gridItems"
:key="item.key"
:style="{ backgroundImage: item.css, height: item.height }"
/>
</transition-group>
</div>
@LinusBorg
LinusBorg / Form.vue
Last active June 24, 2019 11:04
Consuming function-based plugin in object-based Vue component
<template>
<form>
<input type="text" v-model="data.name" />
<span v-if="errors.name">{errors.name.msg{</span>
<span v-else>{{capsName}}</span>
<input type="number" v-model.number="data.age" />
<span v-if="errors.age">{errors.age.msg{</span>
</form>
</template>
@LinusBorg
LinusBorg / Presenter.vue
Last active June 15, 2019 23:22
Pseudocode example for a reddit discussion about the proposed Vue 3 composition RFC
<template>
<!-- eslint-disable -->
<spinner v-if="showSpinner"></spinner>
<presentation-player v-else :page-data="$store.state.presentationPageData"></presentation-player>
</template>
<script>
/* eslint-disable */
import webSocketService from 'services/websocket'
import { usePresentation } from './base'
@LinusBorg
LinusBorg / chunksPlugin.js
Last active March 3, 2019 20:04
Adding a local plugin to a Vue CLI preset
// Local Plugin:
// https://cli.vuejs.org/guide/plugins-and-presets.html#project-local-plugin
// See also:
// https://cli.vuejs.org/dev-guide/plugin-dev.html#modifying-webpack-config
module.exports = api => {
const webpack = require('webpack')
api.configureWebpack({
plugins: [
<template>
<div>
yy
</div>
</template>
<script>
export default {
methods: {
async hello() {
@LinusBorg
LinusBorg / TestinVSCode.md
Created May 2, 2018 14:51
Testing Vue apps in VS Code
@LinusBorg
LinusBorg / reset.js
Created October 16, 2016 22:04
$reset() instance method for Vue
/*
* Add this before you create your Vue instance with new Vue(...)
*/
Vue.prototype.$reset = function () {
var data = this.$options.data()
Object.keys(data).map(key => {
this[key] = data[key]
})
}
function promisifyFileReader (filereader) {
function composeAsync (key) {
return function () {
var args = arguments
return new Promise (function (resolve, reject) {
//
function resolveHandler () {
cleanHandlers()
resolve(filereader.result)
}