Skip to content

Instantly share code, notes, and snippets.

View jdmorlan's full-sized avatar

Jay Morlan jdmorlan

  • Freelance Web Developer
  • Houston, TX
View GitHub Profile
@jdmorlan
jdmorlan / packages.md
Last active April 6, 2020 15:07
Cool Packages
@jdmorlan
jdmorlan / intro.md
Created December 12, 2016 06:24
React Transition Group - Following D3 enter/exit/update model!

Create a TransitionGroup component that provides three hooks!

  1. Component Will Enter
  2. Component Will Leave
  3. Component Will Update

Component Will Update is for items that were previously in the list, that are no longer in the list.

This is somewhat available today by using the componentWillUpdate instance method on a component, but I don't want to have to provide specific props to check. I want the TransitionGroup to just tell me

@jdmorlan
jdmorlan / component.js
Created December 1, 2016 03:43
Transition Animations - React/Rebound
import React, { Component } from 'react';
import { spring } from './spring.js';
class TheComponent extends Component {
componentWillEnter() {
spring(this.renderPosition, 0);
}
componentWillLeave() {
spring(this.renderPosition, 1);
@jdmorlan
jdmorlan / icon.js
Created November 17, 2016 19:55
Add Font-Awesome to Webpack!
// React component to place Font Awesome items on the page!
import React, { PropTypes } from 'react'
import cx from 'classnames'
const Icon = React.createClass({
propTypes: {
name: PropTypes.string.isRequired,
classNames: PropTypes.string
},
@jdmorlan
jdmorlan / git-merge-workflow.md
Created October 13, 2016 14:58
Git Merging Workflow
  1. Commit your work to branch

  2. git checkout master

  3. git pull

  4. git checkout [branch-name]

  5. git rebase master

export const goTo = (viewName, opts = {}) => {
return (dispatch, getState) => {
const tabName = opts['tabName']
const params = opts['params']
const goingBack = opts['goingBack']
const state = getState()
const currentTab = getCurrentTab(state)
let view
// Initial State
{
status: 'pending',
initial: null,
items: [],
reducer: null,
iterations: []
}
// Set Initial Value
const compose = (...funcs) => {
//... if statements removed for clarity
const last = funcs[funcs.length - 1]
const rest = funcs.slice(0, -1)
return (...args) => rest.reduceRight((composed, f) => f(composed), last(...args))
}
// Examples
const compose = (...funcs) => {
if (funcs.length === 0) {
return (arg) => arg
}
if (funcs.length === 1) {
return funcs[0]
}
}
@jdmorlan
jdmorlan / compose.js
Last active August 28, 2016 23:43
The Compose Function
const compose = (...funcs) => {
if (funcs.length === 0) {
return (arg) => arg
}
if (funcs.length === 1) {
return funcs[0]
}
const last = funcs[funcs.length - 1]