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
/** | |
Inline styles | |
**/ | |
/** | |
This selector will target any element on the page that has inline styles applied to it. | |
As a general rule, inline styles should be avoided as they are difficult to override | |
due to their increased level of specificity. Although inline | |
styles may be necessary in some cases, this selector will help | |
highlight them so a decision can be made on a case-by-case basis. |
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
// es3: https://gist.github.com/addyosmani/1837327 | |
var mediator = (function() { | |
// Subscribe to an event, supply a callback to be executed | |
// when that event is broadcast | |
var subscribe = function(channel, fn) { | |
if (!mediator.channels[channel]) mediator.channels[channel] = []; | |
mediator.channels[channel].push({ | |
context: this, | |
callback: fn | |
}); |
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
<script> | |
function execPolyfill() { | |
(function(){ | |
// CustomElementsV1.min.js v1 polyfill from https://github.com/webcomponents/webcomponentsjs/tree/v1/src/CustomElements/v1. | |
/* | |
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | |
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | |
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt |
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 default class SetValueExample extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
myName: '', | |
}; | |
} | |
setValue(e) { | |
this.setState({[e.target.name]: e.target.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
// Also available as a NPM library: https://github.com/ajwhite/render-if | |
'use strict'; | |
const isFunction = input => typeof input === 'function'; | |
export default predicate => elemOrThunk => | |
predicate ? (isFunction(elemOrThunk) ? elemOrThunk() : elemOrThunk) : null; | |
import renderIf from '../utils/renderif' | |
export default class RenderIfExample extends Component { |
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 function createReducer(initialState, reducerMap) { | |
return (state = initialState, action) => { | |
const reducer = reducerMap[action.type]; | |
return reducer | |
? reducer(state, action.payload) | |
: state; | |
}; | |
} |
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 isObjectEqual = (obj1, obj2) => { | |
if(!isObject(obj1) || !isObject(obj2)) { | |
return false; | |
} | |
if (obj1 === obj2) { | |
return true; | |
} |
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
function* objectEntries(obj, findKeys = false) { | |
let keys = Reflect.ownKeys(obj); | |
if(findKeys) { | |
yield keys; | |
} else { | |
for (let key of keys) { | |
yield [key, obj[key]]; | |
} | |
} |
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
*:focus:not(:focus-visible), | |
*::before:focus:not(:focus-visible), | |
*::after:focus:not(:focus-visible) { | |
outline: none; | |
} | |
/* https://medium.com/@matuzo/writing-css-with-accessibility-in-mind-8514a0007939 */ | |
.visually-hidden { | |
position: absolute; | |
white-space: nowrap; |
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
// http://blog.runnable.com/post/154695425511/promise-anti-patterns | |
// BAD!! variable nesting | |
// Defining a variable to store later | |
var user | |
var accountInfo | |
fetchUser() | |
.then((fetchedUser) => { | |
// Setting the variable that we will use later |