Make example much more performant

- Don’t load all sets spritesheet
- Handle native like the other sets, and use native by default (no spritesheet load)
release
Etienne Lemay 2017-04-23 15:32:03 +02:00
parent 04b993e7b6
commit b8abf0a310
1 changed files with 15 additions and 10 deletions

View File

@ -10,7 +10,7 @@ class Example extends React.Component {
emojiSize: 24, emojiSize: 24,
perLine: 9, perLine: 9,
skin: 1, skin: 1,
native: false, native: true,
set: 'apple', set: 'apple',
hidden: false, hidden: false,
} }
@ -46,19 +46,25 @@ class Example extends React.Component {
</div> </div>
<div className="row"> <div className="row">
{['apple', 'google', 'twitter', 'emojione'].map((set) => { {['native', 'apple', 'google', 'twitter', 'emojione'].map((set) => {
var props = { disabled: set == this.state.set } var props = { disabled: !this.state.native && set == this.state.set }
if (set == 'native' && this.state.native) {
props.disabled = true
}
return <button return <button
key={set} key={set}
value={set} value={set}
onClick={() => this.setState({ set: set })} onClick={() => {
if (set == 'native') {
this.setState({ native: true })
} else {
this.setState({ set: set, native: false })
}
}}
{...props}> {...props}>
<Emoji {set}
set={set}
size={24}
emoji='grinning'
/>
</button> </button>
})} })}
</div> </div>
@ -82,7 +88,6 @@ class Example extends React.Component {
<br /> emojiSize<Operator>=</Operator>&#123;<Variable>{this.state.emojiSize}</Variable>&#125; <input type='range' data-key='emojiSize' onChange={this.handleInput.bind(this)} min='16' max='64' value={this.state.emojiSize} /> <br /> emojiSize<Operator>=</Operator>&#123;<Variable>{this.state.emojiSize}</Variable>&#125; <input type='range' data-key='emojiSize' onChange={this.handleInput.bind(this)} min='16' max='64' value={this.state.emojiSize} />
<br /> perLine<Operator>=</Operator>&#123;<Variable>{this.state.perLine}</Variable>&#125; {this.state.perLine < 10 ? ' ' : ' '} <input type='range' data-key='perLine' onChange={this.handleInput.bind(this)} min='7' max='16' value={this.state.perLine} /> <br /> perLine<Operator>=</Operator>&#123;<Variable>{this.state.perLine}</Variable>&#125; {this.state.perLine < 10 ? ' ' : ' '} <input type='range' data-key='perLine' onChange={this.handleInput.bind(this)} min='7' max='16' value={this.state.perLine} />
<br /> skin<Operator>=</Operator>&#123;<Variable>{this.state.skin}</Variable>&#125; <input type='range' data-key='skin' onChange={this.handleInput.bind(this)} min='1' max='6' value={this.state.skin} /> <br /> skin<Operator>=</Operator>&#123;<Variable>{this.state.skin}</Variable>&#125; <input type='range' data-key='skin' onChange={this.handleInput.bind(this)} min='1' max='6' value={this.state.skin} />
<br /> native<Operator>=</Operator>&#123;<Variable>{this.state.native ? 'true' : 'false'}</Variable>&#125;{this.state.native ? ' ' : ''} <input type='checkbox' data-key='native' onChange={this.handleInput.bind(this)} value={this.state.native} />
<br /> set<Operator>=</Operator><String>'{this.state.set}'</String> <br /> set<Operator>=</Operator><String>'{this.state.set}'</String>
<br /> onClick<Operator>=</Operator>&#123;(<Variable>emoji</Variable>) => console.log(<Variable>emoji</Variable>)&#125; <br /> onClick<Operator>=</Operator>&#123;(<Variable>emoji</Variable>) => console.log(<Variable>emoji</Variable>)&#125;
<br /><Operator>/&gt;</Operator> <br /><Operator>/&gt;</Operator>