2016-05-31 14:36:52 +00:00
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
|
|
|
|
|
|
|
import {Picker} from '../src'
|
|
|
|
|
|
|
|
class Example extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
|
|
|
emojiSize: 24,
|
|
|
|
perLine: 9,
|
2016-05-31 23:36:50 +00:00
|
|
|
skin: 1,
|
2016-05-31 14:36:52 +00:00
|
|
|
set: 'apple',
|
2016-07-15 16:24:50 +00:00
|
|
|
hidden: false,
|
2016-05-31 14:36:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleInput(e) {
|
|
|
|
var { currentTarget } = e,
|
|
|
|
{ value } = currentTarget,
|
|
|
|
key = currentTarget.getAttribute('data-key'),
|
|
|
|
state = {}
|
|
|
|
|
|
|
|
state[key] = parseInt(value)
|
|
|
|
this.setState(state)
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <div>
|
2016-07-27 15:35:12 +00:00
|
|
|
<h1>Emoji Mart</h1>
|
2016-05-31 14:36:52 +00:00
|
|
|
|
|
|
|
<div>
|
|
|
|
{['Apple', 'Google', 'Twitter', 'EmojiOne'].map((set) => {
|
|
|
|
var value = set.toLowerCase(),
|
|
|
|
props = { disabled: value == this.state.set }
|
|
|
|
|
|
|
|
return <button
|
|
|
|
key={value}
|
|
|
|
value={value}
|
|
|
|
onClick={() => this.setState({ set: value })}
|
|
|
|
{...props}>
|
|
|
|
{set}
|
|
|
|
</button>
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
|
2016-07-15 16:24:50 +00:00
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
onClick={() => this.setState({ hidden: !this.state.hidden })}
|
|
|
|
>{this.state.hidden ? 'Mount' : 'Unmount'}</button>
|
|
|
|
</div>
|
|
|
|
|
2016-05-31 14:36:52 +00:00
|
|
|
<pre style={{
|
|
|
|
fontSize: 18,
|
|
|
|
display: 'inline-block',
|
|
|
|
verticalAlign: 'top',
|
|
|
|
margin: '1em',
|
|
|
|
width: '460px',
|
|
|
|
}}>
|
2016-07-27 15:35:12 +00:00
|
|
|
<Operator>import</Operator> {Picker} <Operator>from</Operator> <String>'emoji-mart'</String>
|
2016-05-31 14:36:52 +00:00
|
|
|
<br />
|
|
|
|
<br /><Operator><</Operator><Variable>Picker</Variable>
|
|
|
|
<br /> emojiSize<Operator>=</Operator>{<Variable>{this.state.emojiSize}</Variable>} <input type='range' data-key='emojiSize' onChange={this.handleInput.bind(this)} min='16' max='64' value={this.state.emojiSize} />
|
2016-06-09 00:22:06 +00:00
|
|
|
<br /> perLine<Operator>=</Operator>{<Variable>{this.state.perLine}</Variable>} {this.state.perLine < 10 ? ' ' : ' '} <input type='range' data-key='perLine' onChange={this.handleInput.bind(this)} min='7' max='16' value={this.state.perLine} />
|
2016-05-31 23:36:50 +00:00
|
|
|
<br /> skin<Operator>=</Operator>{<Variable>{this.state.skin}</Variable>} <input type='range' data-key='skin' onChange={this.handleInput.bind(this)} min='1' max='6' value={this.state.skin} />
|
2016-07-06 14:53:03 +00:00
|
|
|
<br /> sheetURL<Operator>=</Operator><String>'sheets/sheet_{this.state.set}_64.png'</String>
|
2016-05-31 14:36:52 +00:00
|
|
|
<br /> onClick<Operator>=</Operator>{(<Variable>emoji</Variable>) => console.log(<Variable>emoji</Variable>)}
|
|
|
|
<br /><Operator>/></Operator>
|
|
|
|
</pre>
|
|
|
|
|
2016-07-15 16:24:50 +00:00
|
|
|
{!this.state.hidden &&
|
|
|
|
<Picker
|
|
|
|
emojiSize={this.state.emojiSize}
|
|
|
|
perLine={this.state.perLine}
|
|
|
|
skin={this.state.skin}
|
|
|
|
sheetURL={`../sheets/sheet_${this.state.set}_64.png`}
|
|
|
|
onClick={(emoji) => console.log(emoji)}
|
|
|
|
/>
|
|
|
|
}
|
2016-05-31 14:36:52 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Operator extends React.Component {
|
|
|
|
render() {
|
|
|
|
return <span style={{color: '#a71d5d'}}>
|
|
|
|
{this.props.children}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Variable extends React.Component {
|
|
|
|
render() {
|
|
|
|
return <span style={{color: '#0086b3'}}>
|
|
|
|
{this.props.children}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class String extends React.Component {
|
|
|
|
render() {
|
|
|
|
return <span style={{color: '#183691'}}>
|
|
|
|
{this.props.children}
|
|
|
|
</span>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Example />, document.querySelector('div'))
|