- Your first priority is writing code that it is understandable and clearly communicates purpose, intent, and organization. Your second is making sure it is working properly.
- Always strive to uphold the following priciples: - principle of least astonishment - principle of least knowledge - principle of least access - single responsibility principle
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, useLayoutEffect } from 'react' | |
interface Point { | |
count: number; | |
width: number; | |
} | |
const throttle = (throttledFunction: Function, wait: number, context: void) : any => { | |
let timeoutId: any = null | |
let callbackArgs: any[] = [] |
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 { api } from 'ducks/user' | |
const MultiplePatronContext = React.createContext({ | |
isMultiplePatronEnabled: false, | |
error: '', | |
}) | |
export class MultiplePatronProvider extends React.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
import {compose, setPropTypes, defaultProps, withHandlers, componentFromProp, setDisplayName} from 'recompose' | |
const componentEnhance = defaultProps({ component: 'button' }) | |
const ButtonComponent = componentEnhance(componentFromProp('component')) | |
const enhance = compose( | |
setDisplayName(`Button`), | |
setPropTypes({ | |
onClick: PropTypes.func, | |
type: PropTypes.oneOf(['submit', 'button']), |
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 {compose, setPropTypes, defaultProps, withHandlers} from 'recompose' | |
const enhance = compose( | |
setPropTypes({ | |
onClick: PropTypes.func, | |
type: PropTypes.oneOf(['submit', 'button']), | |
className: PropTypes.func, | |
children: PropTypes.func.isRequired, | |
isLoading: PropTypes.bool, | |
}), |
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 {compose, setPropTypes, defaultProps} from 'recompose' | |
const enhance = compose( | |
setPropTypes({ | |
onClick: PropTypes.func, | |
type: PropTypes.oneOf(['submit', 'button']), | |
className: PropTypes.func, | |
children: PropTypes.func.isRequired, | |
isLoading: PropTypes.bool, | |
}), |
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 const Button = ({ type, className, children, onClick, isLoading }) => { | |
return ( | |
<button type={type} className={className} onClick={onClick}> | |
{isLoading && <Loading />} | |
{!isLoading && children} | |
</button> | |
) | |
} |
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 Button extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
isLoading: false, | |
} | |
} | |
static propTypes = { | |
onClick: PropTypes.func, |
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
license: mit | |
scrolling: yes | |
border: no |
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 type="text/javascript"> | |
(function () { | |
"use strict"; | |
// once cached, the css file is stored on the client forever unless | |
// the URL below is changed. Any change will invalidate the cache | |
var css_href = './index_files/web-fonts.css'; | |
// a simple event handler wrapper | |
function on(el, ev, callback) { | |
if (el.addEventListener) { | |
el.addEventListener(ev, callback, false); |
NewerOlder