-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✨ Added open and hideMenu prop, added onClickOutside * 💄 Added fontSize * 📝 Updated docs to match new api * 📝 Docgen * Added handleKeyDown to EmojiMenu.
- Loading branch information
Sjaak Luthart
authored
Jun 23, 2017
1 parent
e45a819
commit cf9a230
Showing
5 changed files
with
131 additions
and
43 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,80 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import ReactMarkdown from 'react-markdown'; | ||
import _ from 'underscore'; | ||
import emojione from 'emojione'; | ||
import EmojiMenu from '../../../dist/emoji-menu'; | ||
import Button from '../../../dist/button'; | ||
import Props from './props'; | ||
import components from '../../components.json'; | ||
import Paper from '../../../dist/paper'; | ||
|
||
const usage = '```js\n import EmojiMenu from \'anchor-ui/emoji-menu\';'; | ||
|
||
const EmojiMenuDoc = () => { | ||
const componentData = _.find(components, component => component.displayName === 'EmojiMenu'); | ||
const style = { | ||
paper: { | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
alignItems: 'center', | ||
margin: 0, | ||
padding: '20px' | ||
}, | ||
emojiMenu: { margin: '10px' } | ||
}; | ||
|
||
return ( | ||
<article className="doc"> | ||
<h1>EmojiMenu</h1> | ||
<section> | ||
<h1>Description</h1> | ||
<p>{componentData.description}</p> | ||
</section> | ||
<section> | ||
<h1>Usage</h1> | ||
<ReactMarkdown source={usage} className="markdown" /> | ||
</section> | ||
<section> | ||
<h1>Examples</h1> | ||
<Paper style={style.paper}> | ||
<EmojiMenu | ||
sendEmoji={() => {}} | ||
style={style.emojiMenu} | ||
/> | ||
</Paper> | ||
</section> | ||
<Props props={componentData.props} /> | ||
</article> | ||
); | ||
}; | ||
class EmojiMenuDoc extends Component { | ||
static createMarkup = text => ({ | ||
__html: emojione.toImage(text) | ||
}) | ||
|
||
constructor() { | ||
super(); | ||
|
||
this.state = { | ||
open: false, | ||
emoji: '' | ||
}; | ||
} | ||
|
||
toggleMenu = () => this.setState({ open: !this.state.open }) | ||
|
||
sendEmoji = ({ shortname }) => this.setState({ emoji: shortname }) | ||
|
||
render() { | ||
const componentData = _.find(components, component => component.displayName === 'EmojiMenu'); | ||
const style = { | ||
paper: { | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
alignItems: 'center', | ||
margin: 0, | ||
padding: '20px' | ||
}, | ||
emojiMenu: { margin: '10px' } | ||
}; | ||
|
||
return ( | ||
<article className="doc"> | ||
<h1>EmojiMenu</h1> | ||
<section> | ||
<h1>Description</h1> | ||
<p>{componentData.description}</p> | ||
</section> | ||
<section> | ||
<h1>Usage</h1> | ||
<ReactMarkdown source={usage} className="markdown" /> | ||
</section> | ||
<section> | ||
<h1>Examples</h1> | ||
<Paper style={style.paper}> | ||
{ | ||
this.state.emoji | ||
? <span style={style.emojiMenu} className="emojione" dangerouslySetInnerHTML={EmojiMenuDoc.createMarkup(this.state.emoji)} /> | ||
: null | ||
} | ||
<EmojiMenu | ||
sendEmoji={this.sendEmoji} | ||
style={style.emojiMenu} | ||
open={this.state.open} | ||
hideMenu={this.toggleMenu} | ||
/> | ||
<Button style={style.emojiMenu} onClick={this.toggleMenu}> | ||
Toggle EmojiMenu | ||
</Button> | ||
</Paper> | ||
</section> | ||
<Props props={componentData.props} /> | ||
</article> | ||
); | ||
} | ||
} | ||
|
||
export default EmojiMenuDoc; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,8 @@ code { | |
tbody tr td:nth-of-type(2) { | ||
text-transform: capitalize; | ||
} | ||
|
||
.emojione { | ||
width: 32px; | ||
height: 32px; | ||
} |
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
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