From f6365d8e4cd142967a4d407624a3bc8f9ebbd05e Mon Sep 17 00:00:00 2001 From: eivindh Date: Tue, 30 Jan 2018 23:18:09 +0100 Subject: [PATCH 1/2] Added emoji tooltip --- src/components/App.tsx | 19 +++++--------- src/components/Emoji.tsx | 57 ++++++++++++++++++++++++++++++++++++++++ src/styles/app.css | 13 --------- src/styles/emoji.css | 30 +++++++++++++++++++++ src/utils.ts | 9 ++++--- 5 files changed, 98 insertions(+), 30 deletions(-) create mode 100644 src/components/Emoji.tsx create mode 100644 src/styles/emoji.css diff --git a/src/components/App.tsx b/src/components/App.tsx index ba92ab3..775e9b3 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,12 +1,12 @@ import * as React from 'react' import { hot } from 'react-hot-loader' import { Emoji, Favorite, Save } from '../types' +import { filterEmoji, load, save } from '../utils' +import EmojiButton from './Emoji' import Footer from './Footer' - const copy: (s: string) => void = require('copy-text-to-clipboard') import '../styles/app.css' -import { filterEmoji, load, save } from '../utils' type State = { query: string @@ -60,7 +60,7 @@ class App extends React.Component<{}, State> { return (
-

Emoji Keyboard

+

Emoji Keyboard (Click to copy)

this.setState({ query: e.target.value })} value={query} placeholder="Search emojis" />
@@ -69,21 +69,16 @@ class App extends React.Component<{}, State> { {favorites.length > 0 &&

Most used

}
{favorites.map(e => - + this.handleEmojiClick(e)} /> )}
)} -
{query.length > 0 ? (
{emojis.map(e => - + this.handleEmojiClick(e)} /> )}
) @@ -92,9 +87,7 @@ class App extends React.Component<{}, State> {

{category}

{emojis.filter(e => e.category === category).map(e => - + this.handleEmojiClick(e)} /> )}
diff --git a/src/components/Emoji.tsx b/src/components/Emoji.tsx new file mode 100644 index 0000000..2a7869d --- /dev/null +++ b/src/components/Emoji.tsx @@ -0,0 +1,57 @@ +import * as React from 'react' +import { Emoji } from '../types' + +import '../styles/emoji.css' + +type Props = { + emoji: Emoji + onClick: (e: React.MouseEvent) => void +} + +type State = { + hover: boolean +} + +class EmojiButton extends React.Component { + state = { + hover: false + } + + render () { + const { emoji, onClick } = this.props + const { hover } = this.state + return ( +
+ + {hover && ( +
    +
  • + Category: {emoji.category} +
  • +
  • + Description: {emoji.description} +
  • + {emoji.aliases.length > 0 && +
  • + Also known as: {emoji.aliases.join(', ')} +
  • + } + {emoji.tags.length > 0 && +
  • + Tags: {emoji.tags.join(', ')} +
  • + } +
+ )} +
+ ) + } + +} + +export default EmojiButton diff --git a/src/styles/app.css b/src/styles/app.css index 19a4656..e8fc74d 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -22,16 +22,3 @@ input { justify-content: space-between; } } - -.emoji { - font-size: 1.5rem; - padding: 0.5rem; - width: 50px; - cursor: pointer; - background: none; - border: none; -} - -.emoji:hover { - background-color:#D3D3D3; -} diff --git a/src/styles/emoji.css b/src/styles/emoji.css new file mode 100644 index 0000000..7339eba --- /dev/null +++ b/src/styles/emoji.css @@ -0,0 +1,30 @@ +.emoji { + font-size: 1.5rem; + padding: 0.5rem; + width: 50px; + cursor: pointer; + background: none; + border: none; +} + +.emoji:hover { + background-color:#D3D3D3; +} + +.emojicontainer { + position: relative; +} + +.tooltip { + list-style: none; + z-index: 10; + width: 200px; + top: 30px; + margin-left: -75px; + position: absolute; + padding: 0.5rem; + background-color: white; + border: 2px solid gainsboro; + border-radius: 0.5rem; + +} \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 6c71224..f1f6565 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,12 +1,13 @@ import { Emoji, Save } from './types' export function filterEmoji (emoji: Emoji, query: string) { + query = query.toLocaleLowerCase() return ( emoji.emoji.includes(query) || - emoji.description.includes(query) || - emoji.category.includes(query) || - emoji.aliases.some(alias => alias.includes(query)) || - emoji.tags.some(tag => tag.includes(query)) + emoji.description.toLocaleLowerCase().includes(query) || + emoji.category.toLocaleLowerCase().includes(query) || + emoji.aliases.some(alias => alias.toLocaleLowerCase().includes(query)) || + emoji.tags.some(tag => tag.toLocaleLowerCase().includes(query)) ) } From ab6eedb5efd247ddda0b4b9c18cb573ee2eb717e Mon Sep 17 00:00:00 2001 From: eivindh Date: Tue, 30 Jan 2018 23:18:55 +0100 Subject: [PATCH 2/2] Bumped version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9719677..a62b385 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "emoji-keyboard", - "version": "0.3.2", + "version": "0.4.0", "description": "", "main": "index.js", "scripts": {