Skip to content

Instantly share code, notes, and snippets.

🚧
Refactoring

Stephen Way stephenway

🚧
Refactoring
Block or report user

Report or block stephenway

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AccountHolder.i.ts
/**
*
* AccountHolder Default Values
*/
import find from 'lodash.find'
import get from 'lodash.get'
import {
AccountHolderMutationVariables, AccountTypeEnum, GetAccountHolderQuery, GetPersonQuery
} from '@types-generated'
@stephenway
stephenway / README.md
Last active Sep 27, 2019
WIP: Convert FormikMultiWizard to React.FC & Context
View README.md

React Compound Components

Source

  • [Original Formik Multistep Wizard Implementation][0]

Reference

  • [Compound React Components with Hooks + TypeScript][1]
  • [Guide to Typescript and Hooks][2]: A bit more basic but relevant
@stephenway
stephenway / _app.tsError.tsx
Created Aug 11, 2019
Next.js + Typescript Main App Class Errors
View _app.tsError.tsx
Class static side 'typeof MyApp' incorrectly extends base class static side 'typeof App'.
Types of property 'getInitialProps' are incompatible.
Type '({ Component, ctx }: any) => Promise<{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any; messages: any; initialNow: number; pageProps?: undefined; } | { ...; }>' is not assignable to type '(context: NextAppContext<Record<string, string | string[] | undefined>, {}>) => Promise<DefaultAppIProps>'.
Type 'Promise<{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any; messages: any; initialNow: number; pageProps?: undefined; } | { ...; }>' is not assignable to type 'Promise<DefaultAppIProps>'.
Type '{ pageProps: {}; locale?: undefined; messages?: undefined; initialNow?: undefined; } | { query: any; authtoken: string; isLoggedIn: boolean; locale: any;
@stephenway
stephenway / uniqueValidationMethod.js
Created Aug 9, 2019
Unique Method for Yup Validation
View uniqueValidationMethod.js
/*
* Author: @carlosagsmendes
* Source: https://github.com/jquense/yup/issues/345#issuecomment-487320558
*/
import yup from 'yup';
yup.addMethod(yup.array, 'unique', function (message, mapper = a => a) {
return this.test('unique', message, function (list) {
return list.length === new Set(list.map(mapper)).size;
@stephenway
stephenway / nestedArray.js
Created Feb 7, 2019
Flatten a nested array to a single level array
View nestedArray.js
// Setup nested array
var array1 = [[1,2,[3]],4];
// Iterate over the nested array and reduce/concat
function flattenArray(arr1) {
return arr1.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenArray(val)) : acc.concat(val), []);
}
// Run the nested array through our function
flattenArray(array1);
View graylogTV.css
body, h1, h2, h3, h4, h5, h6 {
color: #fff;
}
body {
margin-top: 0;
}
body,
.content {
@stephenway
stephenway / ButtonExamples.jsx
Created Jul 31, 2017
MDStyled Button Examples
View ButtonExamples.jsx
<div>
<Button handleRoute = {() => {}}>Default</Button>
<Button raised handleRoute={() => {}}>Raised</Button>
<Button dense handleRoute={() => {}}>Dense Default</Button>
<Button raised dense handleRoute={() => {}}>Dense Raised</Button>
<Button compact handleRoute={() => {}}>Compact</Button>
<Button compact raised handleRoute={() => {}}>Compact Raised</Button>
<Button primary handleRoute={() => {}}>Default with Primary</Button>
<Button raised primary handleRoute={() => {}}>Raised with Primary</Button>
<Button accent handleRoute={() => {}}>Default with Accent</Button>
@stephenway
stephenway / fullscreen.cljs
Created Jan 31, 2017
Clojurescript Fullscreen Button
View fullscreen.cljs
(defn get-canvas []
"Returns canvas that will be fullscreened after a click."
(let [canvas (.getElementById js/document "article")
btnStatusBoard (.getElementById js/document "btnStatusBoard")]
(when canvas (.addEventListener btnStatusBoard "click" #(.webkitRequestFullscreen canvas)))
canvas))
(dom/button #js {:className "c-button c-button--text"
:id "btnStatusBoard"
:title (tr "Fullscreen")}
@stephenway
stephenway / style_helpers.cljs
Created Oct 25, 2016
Garden helpers for CSS in cljs
View style_helpers.cljs
(ns project.ui.style-helpers
(:require [om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[om-css.core :as csc]
[garden.core :as g]
[garden.stylesheet :as gs]
[garden.selectors :as s]))
(def ^:once browsers
@stephenway
stephenway / color.cljs
Created Oct 25, 2016
Color palette for cljs
View color.cljs
(ns project.ui.color)
(def orange
{:50 "#ffcc80"
:100 "#ffc16d"
:200 "#ffb75c"
:300 "#ffad4a"
:400 "#fea139"
:500 "#ff9800"
:600 "#f98d1d"
You can’t perform that action at this time.