This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import packageJson from '../package.json'; | |
global.appVersion = packageJson.version; | |
// version from response - first param, local version second param | |
const semverGreaterThan = (versionA, versionB) => { | |
const versionsA = versionA.split(/\./g); | |
const versionsB = versionB.split(/\./g); | |
while (versionsA.length || versionsB.length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import moment from 'moment'; | |
export type CalendarEvent = { | |
title: string; | |
description: string; | |
location: string; | |
startDate: string; | |
endDate: string; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const on = (obj: any, ...args: any[]) => obj.addEventListener(...args); | |
export const off = (obj: any, ...args: any[]) => obj.removeEventListener(...args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const prefersReducedMotion = css` | |
@media (prefers-reduced-motion: reduce) { | |
animation: none; | |
transition: none; | |
} | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from "react"; | |
export const useForm = cb => { | |
const [values, setValues] = useState({}); | |
const handleSubmit = event => { | |
if (event) event.preventDefault(); | |
if (cb && typeof cb === "function") cb(values); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
export const useStateLocalStorage = (localStorageKey, initialState = "") => { | |
const init = localStorage.getItem(localStorageKey) || initialState; | |
const [value, setValue] = useState(init); | |
useEffect(() => { | |
localStorage.setItem(localStorageKey, value); | |
}, [value]); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import styled, { keyframes } from "react-emotion"; | |
const useForm = cb => { | |
const [values, setValues] = useState({}); | |
const handleSubmit = event => { | |
if (event) event.preventDefault(); | |
if (cb && typeof cb === "function") cb(values); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import styled, { StyledFunction } from "styled-components" | |
interface YourProps { | |
invalid: boolean | |
} | |
const input: StyledFunction<YourProps & React.HTMLProps<HTMLInputElement>> = styled.input | |
const Input = input` | |
border: ${p => p.invalid ? 'red' : 'blue'}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ---- | |
css custom properties to manipulate color | |
MIT - 2017 - Soft Punch | |
https://gist.github.com/softpunch/ | |
set initial "main" color via HSL values. | |
automatically calculate harmonies and variations of that color with pure css. | |
harmonies are determined solely by hue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################ | |
#### RAND ## | |
################ | |
export PS1="👻 --> " | |
alias ..="cd .. && ls" | |
alias up='cd .. && ls' | |
alias down='cd && ls' | |
alias pwdc="pwd && pwd | tr -d '\n' | pbcopy" | |
################ |
NewerOlder