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 "../../../../SASS/lib/core"; | |
@import "../../Cards/Card/mixins"; | |
.tabs { | |
padding: 0; | |
border: $constants-border; | |
border-radius: 8px; | |
.tabs_header { | |
display: flex; |
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
updateHeight(isOpen) { | |
if (isOpen) { | |
this.containerEl.style.height = `${this.contentEl.scrollHeight}px`; | |
} else { | |
this.containerEl.style.height = '0px'; | |
} | |
} |
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
export default class UnleashedOne extends React.Component { | |
constructor(props) { | |
super(props); | |
this.onChange = this.onChange.bind(this); | |
} | |
onChange(e) { | |
this.props.onChange(e.target.value); | |
} | |
render () { | |
return ( |
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
export default class LeashedOne extends React.Component { | |
constructor(props) { | |
super(props); | |
this.onChange = this.onChange.bind(this); | |
this.onChangeDebounce = _.debounce(value => this.props.onChange(value), 300); | |
} | |
onChange(e) { | |
this.onChangeDebounce(e.target.value); | |
} | |
render () { |
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
class ShouldNotUpdate extends React.Component { | |
constructor(props) { | |
super(props); | |
this.counter = 0; | |
} | |
shouldComponentUpdate(nextProps, nextState) { | |
return this.props.children !== nextProps.children; | |
} | |
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
class ShouldNotUpdate extends React.PureComponent { | |
constructor(props) { | |
super(props); | |
this.counter = 0; | |
} | |
render() { | |
return `I should be rendered only 1 time. actual times rendered: ${++this.counter}`; | |
} | |
} |
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
updateHeight(isOpen) { | |
this.lastRAF && cancelAnimationFrame(this.lastRAF); | |
if (isOpen) { | |
this.lastRAF = requestAnimationFrame(() => { | |
// read: | |
const height =`${this.contentEl.scrollHeight}px`; | |
this.lastRAF = requestAnimationFrame(() => { | |
// write in a different frame: | |
this.containerEl.style.height = height; | |
this.lastRAF = null; |
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
<Tabs> | |
<Tab value="banana" header="Banana Header">Banana</Tab> | |
<Tab value="apple" header="Apple Header">Apple</Tab> | |
</Tabs> |
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
getHeader(tabs) { | |
return tabs.map((tab, i) => { | |
const style = this.isSelected(tab) ? activeTabHeaderStyle : tabHeaderStyle; | |
return ( | |
<span | |
key={tab.props.value} | |
onClick={e => this.selectTab(e, tab.props.value)} | |
style={i === 0 ? style : Object.assign({}, style, sideHeaderStyle)} | |
> | |
{tab.props.header} |
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
isSelected(tab) { | |
return tab.props.value === this.state.value; | |
} |
OlderNewer