Skip to content

Instantly share code, notes, and snippets.

View slightlytyler's full-sized avatar
💭
🤓 codin'

Tyler Martinez slightlytyler

💭
🤓 codin'
  • Cat City
View GitHub Profile
@slightlytyler
slightlytyler / Makefile
Last active November 24, 2018 01:25
Makefile for slightlytyler/docker-ui-demo
GIT_SHA=$(shell git rev-parse HEAD)
TAG=slightlytyler/docker-ui-demo
all: build
build:
docker build -t $(TAG):$(GIT_SHA) . \
&& docker tag $(TAG):$(GIT_SHA) $(TAG):latest
.PHONY: build
@slightlytyler
slightlytyler / .dockerignore
Created November 21, 2018 22:10
dockerignore file for slightlytyler/docker-ui-demo
node_modules
dist
@slightlytyler
slightlytyler / Dockerfile
Created November 21, 2018 22:06
Dockerfile for slightlytyler/docker-ui-demo
FROM node:11.1.0-alpine AS node_base
FROM node_base as deps
WORKDIR /usr/app
COPY package.json /usr/app/package.json
COPY yarn.lock /usr/app/yarn.lock
RUN yarn install
FROM node_base as build
WORKDIR /usr/app
@slightlytyler
slightlytyler / Branch.js
Last active October 3, 2018 21:16
Branch.js
// @flow
import type { Children } from 'react';
import Hidden from 'components/Hidden';
const renderNoop = () => null;
type Props = {
condition: any,
persistent?: boolean,
renderLeft: () => Children,
@slightlytyler
slightlytyler / withForm.js
Last active June 27, 2018 18:25
withForm HOC that wraps withFormik and includes the event in handleSubmit
// @flow
import { withFormik } from 'formik';
import { compose, pick } from 'lodash/fp';
import PropTypes from 'prop-types';
import { withContext, withHandlers } from 'recompose';
type Config = Object;
const pickFormikBag = pick([
'values',
@slightlytyler
slightlytyler / withForm.js
Created June 27, 2018 18:24
withForm HOC that wraps withFormik and includes the event in handleSubmit
// @flow
import { withFormik } from 'formik';
import { compose, pick } from 'lodash/fp';
import PropTypes from 'prop-types';
import { withContext, withHandlers } from 'recompose';
type Config = Object;
const withForm = (config: Config) => {
const HOC = compose(
@slightlytyler
slightlytyler / withForm.js
Created June 27, 2018 18:24
withForm HOC that wraps withFormik and includes the event in handleSubmit
// @flow
import { withFormik } from 'formik';
import { compose, pick } from 'lodash/fp';
import PropTypes from 'prop-types';
import { withContext, withHandlers } from 'recompose';
type Config = Object;
const withForm = (config: Config) => {
const HOC = compose(
@slightlytyler
slightlytyler / main.js
Created February 22, 2018 01:53
Promise problem
const withValues = mapProps(p => ({
...p,
onEvent: val => p.onEvent(val)
.then(res => res.data.val)
.catch(res => Promise.reject(res.data.errors))
}));
const withEffect = mapProps(p => ({
...p,
onEvent: val => p.onEvent(val)
@slightlytyler
slightlytyler / withSubmitOnChange.js
Last active February 5, 2018 02:48
A HOC to handle "autosaving" when a formik form changes value
// @flow
import { isEqual, noop } from 'lodash/fp';
import React, { Component, createFactory } from 'react';
import { setDisplayName, wrapDisplayName } from 'recompose';
import debounce from 'common/utilities/debounce';
const withSubmitOnChange = (BaseComponent: Class<*>) => {
const factory = createFactory(BaseComponent);
type Props = {
@slightlytyler
slightlytyler / schema.graphql
Last active October 11, 2017 17:15
GraphQL intersection types?
schema {
query: Query
}
type Query {
namespaces: AllNamespacesConnection
users: AllUsersConnection
}
interface Node {