This file contains hidden or 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
const renderProp = (key, val) => { | |
const type = typeof val; | |
if (type === 'string' && !val) return null; | |
if (type === 'object' && !Object.keys(val).length) return null; | |
switch (type) { | |
case 'number': | |
return `${key}={${val}}`; | |
case 'string': |
This file contains hidden or 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
'.source.js': | |
'constructor': | |
'prefix': 'construct' | |
'body': ''' | |
constructor(props) { | |
super(props); | |
$1 | |
} | |
''' |
This file contains hidden or 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 pickBy from 'lodash.pickby'; | |
import { createElement } from 'react'; | |
export const createComponent = ({ | |
tag: defaultTag = 'div', | |
prop = 'tag', | |
omit = [] | |
} = {}) => { | |
return ({ children, ...otherProps }) => { | |
const tag = otherProps[prop] || defaultTag; |
This file contains hidden or 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
const docgen = require('react-docgen'); | |
const fs = require('fs'); | |
const glob = require('glob'); | |
const chalk = require('chalk'); | |
const chokidar = require('chokidar'); | |
const _ = require('lodash/fp'); | |
const fmap = require('lodash/map'); | |
const { flow, mapValues } = _; |
This file contains hidden or 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
const jest = require('danger-plugin-jest').default; | |
const { message, danger, warn } = require('danger'); | |
// Output all modified files in the PR | |
const modified = danger.git.modified_files; | |
message('Changed Files in this PR: \n' + modified.map(file => `- ${file}\n`)); | |
// Encourage smaller PRs | |
let errorCount = 0; | |
const bigPRThreshold = 600; |
This file contains hidden or 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
# Your snippets | |
# | |
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to | |
# expand the prefix into a larger code block with templated values. | |
# | |
# You can create a new snippet in this file by typing "snip" and then hitting | |
# tab. | |
# | |
# An example CoffeeScript snippet to expand log to console.log: | |
# |
This file contains hidden or 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
# Reusable bash function you can add to your ~/.zshrc or ~/.bashrc file | |
# | |
# Usage: pkg-script start "node index.js" | |
# | |
function pkg-script () { | |
echo $(jq --arg key "${1}" --arg val "${2}" '.scripts[$key]=$val' package.json) | jq . | > package.json | |
} |
This file contains hidden or 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
/** | |
* Check if an element is within the viewport or considered visible | |
* @param {Object} bounds { top, left, bottom, right } - distances from container | |
* @param {Object} container - container object with { width, height } | |
* @return {Boolean} returns visibility state | |
*/ | |
const isInViewport = ({ top, left, bottom, right }, container) { | |
const isTallerThanViewport = top <= 0 && bottom >= container.height | |
const isWiderThanViewport = right >= container.width && left <= 0 |
This file contains hidden or 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
/** | |
* Lookup an object property by dot notation | |
* @param {Object} obj - object to perform lookup | |
* @param {String} key - property location | |
* @param {Any} fallback - fallback if not found | |
* @return {Any} returns value of lookup if found, otherwise undefined | |
*/ | |
const get = (obj, key, fallback) => | |
key | |
.split('.') |
This file contains hidden or 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, { Component } from 'react' | |
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom' | |
import FirebaseProvider, { Consumer as FirebaseConsumer } from './FirebaseProvider' | |
class Container extends Component { | |
render() { | |
return ( | |
<Router> | |
<FirebaseProvider> | |
<FirebaseConsumer> |