Skip to content

Instantly share code, notes, and snippets.

View nabrown's full-sized avatar

Nora Brown nabrown

View GitHub Profile
@nabrown
nabrown / MutationObserver-childList.js
Last active September 12, 2018 13:34
Using a mutation observer to watch for added child nodes
(function() {
// Select the node to observe
var targetNode = document.querySelector('#sqs-cart-root');
// If the targetNode exists on our page
if(targetNode){
// Watch when nodes are added to targetNode, or its descendants
var config = {
@nabrown
nabrown / FigureFunctionalSFC.vue
Created July 28, 2018 00:34
A functional, single-file component
<template functional>
<figure :class="props.type" v-on:click="listeners.click">
<img :src="props.src" />
<figcaption v-if="slots().default">
<span><slot></slot></span>
</figcaption>
<div class="tags" v-if="props.tags && props.type != 'framed'">
<span v-for="tag in props.tags"> {{ tag }}</span>
</div>
</figure>
@nabrown
nabrown / FigureFunctionalRF.js
Created July 27, 2018 22:33
A functional component using a render function
export default {
functional: true,
props: {
src: {
required: true,
type: String
},
type: {
required: true,
type: String
@nabrown
nabrown / FigureStandardRF.js
Created July 27, 2018 22:31
Standard component using a render function
export default {
props: {
src: {
required: true,
type: String
},
type: {
required: true,
type: String
@nabrown
nabrown / FigureStandardSFC.vue
Created July 27, 2018 22:16
Standard, single-file component
<template>
<figure :class="type" v-on:click="$emit('click')">
<img :src="src" />
<figcaption v-if="$slots.default">
<span><slot></slot></span>
</figcaption>
<div class="tags" v-if="tags && type != 'framed'">
<span v-for="tag in tags"> {{ tag }}</span>
</div>
</figure>
@nabrown
nabrown / App.vue
Created July 27, 2018 22:11
Main file for functional component and render function test app
<template>
<div id="app">
<FigureStandardSFC
src="cat-basking.jpg"
type="post-it"
:tags="['cat','feline','fuzzy','gray']"
@click="alertHello">Cat basking in the sun.</FigureStandardSFC>
<FigureStandardRF
src="red-tailed-hawk.jpg"
@nabrown
nabrown / grams-styles.css
Last active June 5, 2018 18:05
Instagram gallery styles with CSS Grid
:root{
--color: #95e9ef;
--background: #1f1f1f;
--spacing: 1rem;
--speed: 1700ms;
--fontsize: 2rem;
}
body{
margin: 0;
padding: var(--spacing);
@nabrown
nabrown / grams-vue.js
Last active June 5, 2018 18:17
Instagram Gallery Vue javascript
var app = new Vue({
el: '#app',
data: {
access_token: "your access token here",
url: "https://api.instagram.com/v1/users/self/media/recent/",
username: "",
grams: [],
next_url: "",
error: false
},
@nabrown
nabrown / grams-app-body.html
Last active June 5, 2018 18:17
Instagram Gallery HTML
<div id="app">
<h1><a :href="instapage">@{{ username }} on instagram</a></h1>
<template v-if="grams.length > 0">
<div v-for="(gram, index) in grams">
<a :href="gram.link">
<img :src="gram.images.standard_resolution.url" :alt="gram.text" />
</a>
</div>
</template>
<div v-else class="loading"></div>
@nabrown
nabrown / grams-shell.html
Created June 4, 2018 20:33
Instagram Gallery Shell
<!DOCTYPE html>
<html>
<head>
<title>Instagram Gallery</title>
<script src="https://unpkg.com/vue@2.5.16/dist/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<style type="text/css">