Skip to content

Instantly share code, notes, and snippets.

View estrattonbailey's full-sized avatar

Eric Bailey estrattonbailey

View GitHub Profile
@estrattonbailey
estrattonbailey / index.js
Created October 25, 2017 20:13
Refunk v2 Example
import preact from 'preact'
import connect from 'refunk'
// pass only select props to child
function pear (mapProps) {
return Component => props => (
<Component {...mapProps(props)} />
)
}
@estrattonbailey
estrattonbailey / init.js
Created September 11, 2017 14:39
Module Init Pattern
export default types => (ctx = document) => {
return {
init () {
for (let type in types) {
const attr = 'data-' + type
const nodes = [].slice.call(ctx.querySelectorAll(`[${attr}]`))
for (let i = 0; i < nodes.length; i++) {
try {
require(types[type] + nodes[i].getAttribute(attr) + '.js').default(nodes[i])
@estrattonbailey
estrattonbailey / client.js
Last active September 10, 2017 18:31
webpack config
// imports...
if (module.hot) {
module.hot.accept()
}
import style from '../styles/main.css'
// app code...
import { Stepper, Step } from 'react-stepper' // need a new name, this is taken
render(
<div>
<Stepper active={0}>
<Step>
{({ next, prev, clear }) => (...component1...)}
</Step>
<Step>
{({ next, prev, clear }) => (...component2...)}
const triage = obj => Object.keys(obj).reduce((res, key) => {
res += !!(obj[key]) ? ` ${key}` : ''
return res
}, ' ')
const cx = (...args) => args.reduce((res, arg) => {
res += typeof arg === 'string' ? ` ${arg}` : triage(arg)
return res
}, ' ').trim().replace(/\s\s/, ' ')
@estrattonbailey
estrattonbailey / podcast-reducer.js
Created March 13, 2017 17:30
Merging Redux Stores
import { createStore, combineReducers } from 'redux'
import action from 'action-helper'
const TOGGLE_PLAYING_STATE = 'TOGGLE_PLAYING_STATE'
const SET_CURRENT_TIME = 'SET_CURRENT_TIME'
const SET_DURATION = 'SET_DURATION'
const SET_VOLUME = 'SET_VOLUME'
const initialState = {
playing: false,
{% assign account_page_title = 'Addresses' %}
{% include 'account-titles' %}
{% paginate customer.addresses by 10 %}
<section class="outer mv2 pt1">
<div class="container--s mha">
<div class="relative mv1 mb2">
<button class="new-address button" onclick="barrel.toggleNewForm()">New Address +</button>
@estrattonbailey
estrattonbailey / react-shortcodes.js
Last active February 24, 2025 16:37
React Shortcodes
import React from 'react'
import { renderToString } from 'react-dom/server'
import parser from './shortcode-parser'
export const add = parser.add
const Aside = ({ children, config }) => {
/**
* config = {
* foo: true,
@estrattonbailey
estrattonbailey / main.scss
Created December 12, 2016 21:31
Checkbox/Radio Recipe
input[type="checkbox"],
input[type="radio"] {
border: 1px solid var(--cb);
vertical-align: middle;
&:checked{
background-color: var(--c1);
border-color: var(--c1);
}
&:focus{
@estrattonbailey
estrattonbailey / main.scss
Created December 12, 2016 21:30
Custom select recipe
.select-wrapper {
position: relative;
display: inline-block;
&:after {
position: absolute;
content: '\25bc';
top: calc(50% - 0.7em);
right: 1em;
font-size: 0.6em;