Skip to content

Instantly share code, notes, and snippets.

View estrattonbailey's full-sized avatar

Eric Bailey estrattonbailey

View GitHub Profile
import React from 'react';
import { connect } from '@picostate/react';
export default connect(state => {
return {
title: state.page.title,
}
})(function Nav(props) {
return (
<nav>
@estrattonbailey
estrattonbailey / Dataloader.js
Created September 25, 2019 15:23
Dataloading
import React from 'react'
import { connect } from 'react-redux'
import { initLoading, stopLoading } from '@/state/actions/loadingActions.js'
import { cacheData } from '@/state/actions/dataActions.js'
export default connect((state, props) => {
return {
data: state.data[props.cache]
}
})(
data:text/html;base64,CjwhRE9DVFlQRSBodG1sPgo8aHRtbD4KICA8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04Ij4KICAgIDxtZXRhIG5hbWU9InZpZXdwb3J0IiBjb250ZW50PSJ3aWR0aD1kZXZpY2Utd2lkdGgsaW5pdGlhbC1zY2FsZT0xIj4KICAgIDx0aXRsZT5waWNvc2l0ZTwvdGl0bGU+CiAgICA8bWV0YSBuYW1lPSJkZXNjcmlwdGlvbiIgY29udGVudD0iQSByZWFsbHkgdmVyeSB0aW55IHNpdGUgZ2VuZXJhdG9yLiIgLz4KICAgIDxsaW5rIHJlbD0iaWNvbiIgdHlwZT0iaW1hZ2UvcG5nIiBzaXplcz0iMzJ4MzIiIGhyZWY9Imh0dHBzOi8vZXN0cmF0dG9uYmFpbGV5LmNvbS9mYXZpY29uLnBuZyI+CiAgICA8bGluayByZWw9InN0eWxlc2hlZXQiIHR5cGU9InRleHQvY3NzIiBocmVmPSJodHRwOi8vbG9jYWxob3N0OjgwODAvZGVmYXVsdC5jc3MiPgogICAgPHNjcmlwdCBzcmM9Imh0dHA6Ly9sb2NhbGhvc3Q6ODA4MC9waWNvc2l0ZS5qcz9vcmlnaW49ZXN0cmF0dG9uYmFpbGV5L2Jsb2ciPjwvc2NyaXB0Pgo=
@estrattonbailey
estrattonbailey / index.js
Created July 26, 2019 16:41
Server Sent App
const http = require('http')
const { h } = require('preact')
const renderToString = require('preact-render-to-string')
const html = `
<!DOCTYPE html>
<html>
<head>
<meta name='charset' content='utf8' />
<title>server-sent app</title>
@estrattonbailey
estrattonbailey / index.js
Last active January 18, 2019 15:37
Color Tweening
function hexToRGB (c) {
const a = []
const steps = [0, 2, 4]
for (let i = 0; i < 3; i++) {
a[i] = c.slice(steps[i], steps[i] + 2)
}
return {
r: parseInt(a[0], 16),
function roop (c, a) {
function cycle (t) {
c() && a(t)
return requestAnimationFrame(cycle)
}
return cycle(performance.now())
}
let y = window.pageYOffset
const Context = React.createContext({})
class Provider extends React.Component {
constructor (props) {
super(props)
this.state = {
foo: 'Hello'
}
}
@estrattonbailey
estrattonbailey / global.css
Last active July 16, 2018 13:56
Global Styles
/**
* Variables
*/
:root {
/* colors */
--black: #000;
--gray1: #555;
--gray2: #aaa;
--gray3: #ddd;
--white: #fff;
@estrattonbailey
estrattonbailey / collection.liquid
Created July 13, 2018 15:00
Sort shopify collection by last names
<div class='collection-list no-pad rel'>
<div class='outer'>
<div class='container'>
{% assign lnames = '' %}
{% assign letters = '' %}
{% for collection in collections %}
{% if collection.title contains 'Designer:' %}
{% assign name = collection.title | split: ':' | last %}
{% assign rname = name | split: "" | reverse | join: "" %}
{% assign lrname = rname | split: " " | first %}
@estrattonbailey
estrattonbailey / touchy.js
Created December 15, 2017 21:36
touchy.js
import mitt from 'mitt'
class Touchy {
constructor (scope) {
this.cancel() // add props to object
scope.addEventListener('touchstart', this.start.bind(this))
scope.addEventListener('touchmove', this.move.bind(this))
scope.addEventListener('touchend', this.end.bind(this))
scope.addEventListener('touchcancel', this.cancel.bind(this))