Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into issue-#652
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjaak Luthart committed Jun 23, 2017
2 parents a360105 + 1b13717 commit cfb1d01
Show file tree
Hide file tree
Showing 24 changed files with 17,277 additions and 11,202 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dist
*.polyfill.js
emoji.js
node_modules
docs/config
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ dist
debug
/components
.nyc_output
emojione.json
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

UI kit for chat engines with React

Anchor UI uses free Emoji icons supplied by [EmojiOne](https://www.emojione.com/)

## Usage

Install from npm
Expand Down
29 changes: 18 additions & 11 deletions docs/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1454,17 +1454,6 @@
}
],
"props": {
"svgSprites": {
"type": {
"name": "string"
},
"required": false,
"description": "Path to svg sprites",
"defaultValue": {
"value": "''",
"computed": false
}
},
"sendEmoji": {
"type": {
"name": "func"
Expand Down Expand Up @@ -1556,6 +1545,24 @@
"computed": false
}
},
"open": {
"type": {
"name": "bool"
},
"required": false,
"description": "Toggle the EmojiMenu's visibility",
"defaultValue": {
"value": "false",
"computed": false
}
},
"hideMenu": {
"type": {
"name": "func"
},
"required": true,
"description": "Function to hide the menu"
},
"color": {
"type": {
"name": "string"
Expand Down
114 changes: 76 additions & 38 deletions docs/src/components/emoji-menu.jsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,87 @@
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>
<a
href="https://www.emojione.com/"
target="_blank"
rel="noopener noreferrer"
>
This component uses free Emoji icons supplied by EmojiOne
</a>
<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;
1 change: 0 additions & 1 deletion docs/src/components/home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const Home = () => {
marginTop: '16px'
},
link: {
color: 'inherit',
textDecoration: 'underline',
fontWeight: 'normal'
}
Expand Down
7 changes: 7 additions & 0 deletions docs/src/components/message.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ class MessageDoc extends Component {
<h1>Usage</h1>
<ReactMarkdown source={usage} className="markdown" />
</section>
<a
href="https://www.emojione.com/"
target="_blank"
rel="noopener noreferrer"
>
This component uses free Emoji icons supplied by EmojiOne
</a>
<section>
<h1>Scaling emoji&apos;s</h1>
<p>
Expand Down
9 changes: 7 additions & 2 deletions docs/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ h2 {

.home a,
.doc a {
font-weight: bold;
color: #212121;
font-weight: bolder;
color: #757575;
}

h2 {
Expand Down Expand Up @@ -154,3 +154,8 @@ code {
tbody tr td:nth-of-type(2) {
text-transform: capitalize;
}

.emojione {
width: 32px;
height: 32px;
}
8 changes: 8 additions & 0 deletions emoji.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

rm ./emojione.json
ls ./src/emoji-menu/emoji.js
curl https://raw.githubusercontent.com/emojione/emojione/master/emoji.json > emojione.json
node parse-emoji.js > src/emoji-menu/emoji.js
node_modules/.bin/prettier src/emoji-menu/emoji.js --write --single-quote
echo Downloaded and parsed emojione.json!
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"copy": "cp -rf package.json README.md dist",
"build": "npm run compile && npm run copy",
"dist": "cd dist && npm publish",
"docs": "react-docgen components --out docs/components.json --pretty"
"docs": "react-docgen components --out docs/components.json --pretty",
"emojione": "node parse-emoji.js > src/emoji-menu/emoji.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -51,6 +52,7 @@
"eslint-plugin-react": "^6.9.0",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"prettier": "^1.4.4",
"react": "^15.4.2",
"react-addons-test-utils": "^15.4.2",
"react-docgen": "^2.14.0",
Expand All @@ -76,7 +78,7 @@
"dependencies": {
"color": "^1.0.3",
"date-fns": "^1.27.2",
"emojione": "^2.2.7",
"emojione": "^3.0.3",
"escape-html": "^1.0.3",
"html-react-parser": "^0.3.4",
"lodash": "^4.17.4",
Expand Down
18 changes: 18 additions & 0 deletions parse-emoji.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const emojione = require('./emojione.json');
const map = require('lodash/map');

console.log('export default ['); // eslint-disable-line no-console

map(emojione, (e) => {
console.log( // eslint-disable-line no-console
`{
title: '${e.shortname.replace(/:levitate:/g, ':man_in_business_suit_levitating:')}${e.diversities.length > 0 && !e.diversity ? ' tone0' : ''}',
name: '${e.name}',
shortname: '${e.shortname.replace(/:levitate:/g, ':man_in_business_suit_levitating:')}',
category: '${e.category}',
diversity: ${Boolean(e.diversities.length > 0 || e.diversity)}
},`
);
});

console.log('];'); // eslint-disable-line no-console
2 changes: 1 addition & 1 deletion src/button/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default {
}
},
disabled: {
opacity: '0.38'
opacity: '0.5'
},
flatButton: {
backgroundColor: 'transparent',
Expand Down
55 changes: 35 additions & 20 deletions src/emoji-menu/emoji-modifiers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,47 @@ import pure from 'recompose/pure';
import Radium, { Style } from 'radium';
import createMarkup from './create-markup';
import getStyles from './get-styles';
import styles from './styles';

function EmojiModifiers({ modifiers, changeTone, tone, style, modifierStyle }) {
return (
<header style={getStyles.modifierHeader(style)}>
<div
onClick={() => changeTone('tone0')}
className="modifier"
style={
getStyles.modifier(tone === 'tone0', modifierStyle)
}
>
<svg width="50px" height="50px" viewBox="0 0 50 50" className="emojione">
<circle id="circle" fill="#FFDD67" cx="25" cy="25" r="25" />
</svg>
</div>
{modifiers.map(modifier => (
<header style={styles.modifierHeader}>
<div style={getStyles.modifierHeader(style)}>
<div
onClick={() => changeTone('tone0')}
className="modifier"
style={
getStyles.modifier(modifier.title === tone, modifierStyle)
getStyles.modifier(tone === 'tone0', modifierStyle)
}
dangerouslySetInnerHTML={createMarkup(modifier.shortname)}
key={`emoji-${modifier.shortname}`}
onClick={() => changeTone(modifier.title)}
className="modifier"
/>
))}
>
<svg width="50px" height="50px" viewBox="0 0 50 50" className="emojione">
<circle id="circle" fill="#FFDD67" cx="25" cy="25" r="25" />
</svg>
</div>
{modifiers.map((modifier) => {
const title = modifier.title.replace(/:/g, '');

return (
<div
style={
getStyles.modifier(title === tone, modifierStyle)
}
dangerouslySetInnerHTML={createMarkup(modifier.shortname)}
key={`emoji-${modifier.shortname}`}
onClick={() => changeTone(title)}
className="modifier"
/>
);
})}
</div>
<a
style={styles.attributionLink}
href="https://www.emojione.com/"
target="_blank"
rel="noopener noreferrer"
>
Emoji by EmojiOne
</a>
<Style
scopeSelector=".modifier"
rules={{
Expand Down
Loading

0 comments on commit cfb1d01

Please sign in to comment.