This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="input-group"> | |
<label class="input-label"><slot></slot></label> | |
<input | |
class="input" | |
v-model="fieldValue" | |
:type="type" | |
:class="inputClass" | |
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Bad: Messy and Hard to Follow #} | |
{% if link %} | |
<a href="/recipes/cookies"> | |
{% endif %} | |
<span>Cookies</span> | |
{% if link %} | |
</a> | |
{% endif %} | |
{# Good: Clean & Clear #} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Scroll to a certain pixel value from the top of the page */ | |
function scrollToValue(pixel, offset = 200) { | |
const newWindowTop = pixel + offset | |
window.scroll({ | |
top: newWindowTop, | |
behavior: 'smooth', | |
}) | |
} | |
/* Scroll to an element on the page */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const $ = selector => document.querySelector(selector) | |
const $$ = selector => document.querySelectorAll(selector) | |
// $ returns a node (or null) | |
$('.nav').classList.add('open') | |
// $$ returns a NodeList (which is empty if no matching elements are found) | |
$$('ul > li > a').forEach($node => $node.style.background = 'red') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Before */ | |
function getErrorMessage(error) { | |
if(error === 'username') { | |
return `Username is required` | |
} else if (error === 'email') { | |
return `Don't forget your email!` | |
} else if (error === 'password') { | |
return `Please enter your password` | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<!-- Example Usage --> | |
<div class="menu"> | |
<ScreenDimmer :visible="menuOpen" /> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server API makes it possible to hook into various parts of Gridsome | |
// on server-side and add custom data to the GraphQL data layer. | |
// Learn more: https://gridsome.org/docs/server-api | |
// Changes here requires a server restart. | |
// To restart press CTRL + C in terminal and run `gridsome develop` | |
const { setContext } = require('apollo-link-context') | |
const { HttpLink } = require('apollo-link-http') | |
const { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div v-if="visible" class="modal"> | |
<div> | |
<div>{{ message }}</div> | |
<div> | |
<button class="button-secondary" @click="cancel">Cancel</button> | |
<button class="button-primary" @click="confirm">Confirm</button> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { setContext } = require('apollo-link-context') | |
const { HttpLink } = require('apollo-link-http') | |
const { | |
introspectSchema, | |
makeRemoteExecutableSchema, | |
} = require('graphql-tools') | |
const fetch = require('node-fetch') | |
const http = new HttpLink({ | |
uri: 'http://example.com/api', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<form method="post" accept-charset="UTF-8"> | |
<h3><label for="username">Username</label></h3> | |
<input v-model="username" id="username" type="text" name="username" /> | |
<h3><label for="email">Email</label></h3> | |
<input v-model="email" id="email" type="text" name="email" /> | |
<h3><label for="password">Password</label></h3> | |
<input v-model="password" id="password" type="password" name="password" /> |