Last active
June 30, 2017 16:25
-
-
Save joeporpeglia/aab0f72ed26959a95575c6a246d89049 to your computer and use it in GitHub Desktop.
Revisions
-
joeporpeglia revised this gist
Jun 29, 2017 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ document handleSave ); let isSaving = false; const handleSave = () => { if (isSaving) { 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 charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ document handleSave ); let isSaving = false; const handleSave = () => { if (isSaving) { -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ const withDropdownState = WrappedComponent => { return class extends Component { // Initialize state in constructor render() { return ( <WrappedComponent -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,10 +6,10 @@ const withCounter = connect( const withCounter = compose( withState('value', 'setValue', 0), withHandlers({ onIncrement: ({ setValue, value }) => () => { setValue(value + 1); }, onDecrement: ({ setValue, value }) => () => { setValue(value - 1); }, }) -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,11 @@ const increment = num => num + 1; const incrementWithLog = withLog(increment); const withLog = WrappedComponent => (props) => { console.log('rendered with props:', props); return <WrappedComponent {...props} />; } const Button = props => <button {...props} />; const ButtonWithLog = withLog(Button); -
joeporpeglia revised this gist
Jun 29, 2017 . 2 changed files with 12 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,21 @@ type DropdownProps = { expanded: boolean, value: string | number, onChange: (string | number) => void, onExpand: () => void, onCollapse: () => void, options: { [optionValue: string | number]: string | React$Element }, }; const Dropdown = props => ( <div> <button aria-haspopup="true" aria-expanded={props.expanded} onClick={props.expanded ? props.onCollapse : props.onExpand} > {props.options[props.value]} </button> <ul aria-hidden={!props.expanded}> 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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,10 @@ const withDropdownHandlers = WrappedComponent => { {...props} onExpand={() => props.setExpanded(true)} onCollapse={() => props.setExpanded(false)} onChange={value => { props.setValue(value); props.setExpanded(false); } /> ); }; -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,10 @@ type DropdownProps = { expanded: boolean, value: string | number, onChange: (string | number) => void options: { [optionValue: string | number]: string | React$Element }, }; const Dropdown = props => ( @@ -12,7 +15,9 @@ const Dropdown = props => ( <ul aria-hidden={!props.expanded}> {Object.keys(props.options).map(value => ( <li key={value}> <button onClick={() => props.onChange(value)}> {props.options[value]} </button> </li> ))} </ul> -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,16 @@ const withCounter = connect( selectCounterState, counterActions ); const withCounter = compose( withState('value', 'setValue', 0), withHandlers({ onIncrement: ({ setValue, value }) => { setValue(value + 1); }, onDecrement: ({ setValue, value }) => { setValue(value - 1); }, }) ); -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ const withCounter = connect(selectCounterState, counterActions); const withCounter = compose( withState('value', 'setValue', 0), withHandlers({ onIncrement: ({ setValue, value }) => setValue(value + 1), onDecrement: ({ setValue, value }) => setValue(value - 1), }) ); -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ const Article = (props) => ( <article> <header>{props.header}</header> <main>{props.content}</main> <footer>{props.footer}</footer> </article> ); const Strong = (props) => ( <strong>{props.children}</strong> ); -
joeporpeglia renamed this gist
Jun 29, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
joeporpeglia revised this gist
Jun 29, 2017 . 2 changed files with 12 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ const withLog = wrappedFn => (...args) => { console.log('called with args:', args); return wrappedFn(...args); } const increment = num => num + 1; const incrementWithLog = withLog(increment); const Button = props => <button {...props} />; const ButtonWithLog = withLog(Button); -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,4 +4,8 @@ const Composed = () => ( <Outer> <Inner /> </Outer> ); const Composed = () => ( <Outer children={<Inner />} /> ); -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ const composed = () => outer(inner()); const Composed = () => ( <Outer> -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ const composed = () => outer(inner(...args)); const Composed = () => ( <Outer> -
joeporpeglia revised this gist
Jun 29, 2017 . 6 changed files with 61 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ document .querySelector('.btn-save') .addEventListener( 'click', handleSave ); const isSaving = false; const handleSave = () => { if (isSaving) { return; } isSaving = true; showLoader(); saveForm(); }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ document .querySelector('.btn-save') .addEventListener( 'click', handleSave ); const isSaving = false; const handleSave = () => { if (isSaving) { return; } isSaving = true; saveForm(); }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ document .querySelector('.btn-save') .addEventListener( 'click', handleSave ); const handleSave = () => { saveForm(); }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ const compose2 = (f, g) => (...args) => f(g(...args)); const Composed = () => ( <Outer> <Inner /> </Outer> ); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ .btn-save { background: #1ab7ea; color: #ffffff; } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <form> <button class=”btn-save”> Save </button> </form> -
joeporpeglia revised this gist
Jun 29, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ type DropdownProps = { className: string, options: Array<string> | Array<number> | Array<{ label: React$Element, value: string | number }> onChange: Function, placeholder: string | Element, value: string | number, -
joeporpeglia renamed this gist
Jun 29, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
joeporpeglia revised this gist
Jun 29, 2017 . 5 changed files with 55 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ type DropdownProps = { expanded: boolean, value: string | number, options: { [optionValue: string | number]: string | React$Element }, }; const Dropdown = props => ( <div> <button aria-haspopup="true" aria-expanded={props.expanded}> {props.options[props.value]} </button> <ul aria-hidden={!props.expanded}> {Object.keys(props.options).map(value => ( <li key={value}> {props.options[value]} </li> ))} </ul> </div> ); 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ type DropdownProps = { className: string, options: string[] | number[] | Element[], onChange: Function, placeholder: string | Element, value: string | number, defaultValue: string | number, readOnly: boolean, optionsMaxHeight: number, calculateWidth: boolean, }; 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +0,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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ const withDropdownHandlers = WrappedComponent => { return props => ( <WrappedComponent {...props} onExpand={() => props.setExpanded(true)} onCollapse={() => props.setExpanded(false)} onChange={props.setValue} /> ); }; 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ const withDropdownState = WrappedComponent => { return class extends Component { render() { return ( <WrappedComponent {...this.props} expanded={this.state.expanded} value={this.state.value} setExpanded={expanded => this.setState({ expanded })} setValue={value => this.setState({ value })} /> ); } }; -
joeporpeglia created this gist
Jun 29, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ const withDropdownHandlers = WrappedComponent => { return props => ( <WrappedComponent {...props} onExpand={...} onCollapse={...} onChange={...} /> ); };