├── .gitignore ├── .prettierrc ├── favicon.ico ├── src ├── state │ └── index.js ├── components │ ├── index.js │ ├── MobileFallback.js │ ├── Search.js │ ├── Emoji.js │ └── Menu.js ├── actions │ └── index.js ├── modules │ ├── index.js │ ├── storage.js │ ├── device.js │ ├── clipboard.js │ ├── keyboard.js │ └── serviceWorker.js ├── index.js └── style.css ├── netlify.toml ├── .babelrc ├── README.md ├── postcss.config.js ├── package.json ├── index.html ├── LICENSE └── tailwind.js /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | dist 3 | node_modules -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true 4 | } 5 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gary149/rocket-emoji/HEAD/favicon.ico -------------------------------------------------------------------------------- /src/state/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | search: '', 3 | searchInputPos: { x: null, y: null }, 4 | menu: true 5 | } 6 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "dist/" 3 | command = "npm run build" 4 | 5 | [[redirects]] 6 | from = "/*" 7 | to = "/index.html" 8 | status = 200 -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": [ 4 | [ 5 | "@babel/plugin-transform-react-jsx", 6 | { "pragma": "h" } 7 | ], 8 | "@babel/plugin-transform-runtime" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /src/components/index.js: -------------------------------------------------------------------------------- 1 | import Menu from './Menu' 2 | import Emoji from './Emoji' 3 | import Search from './Search' 4 | import MobileFallback from './MobileFallback' 5 | 6 | export { 7 | Menu, 8 | Emoji, 9 | Search, 10 | MobileFallback 11 | } 12 | -------------------------------------------------------------------------------- /src/actions/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | search: text => state => ({ 3 | search: text 4 | }), 5 | 6 | setInputSearchPos: ({ x, y }) => state => ({ 7 | searchInputPos: {x, y} 8 | }), 9 | 10 | toggleMenu: () => state => ({ 11 | menu: !state.menu 12 | }) 13 | } 14 | -------------------------------------------------------------------------------- /src/modules/index.js: -------------------------------------------------------------------------------- 1 | import device from './device' 2 | import storage from './storage' 3 | import keyboard from './keyboard' 4 | import clipboard from './clipboard' 5 | import serviceWorker from './serviceWorker' 6 | 7 | export { 8 | device, 9 | storage, 10 | keyboard, 11 | clipboard, 12 | serviceWorker 13 | } 14 | -------------------------------------------------------------------------------- /src/modules/storage.js: -------------------------------------------------------------------------------- 1 | export default { 2 | saveMenuState(active) { 3 | localStorage.setItem('menu', JSON.stringify(active)) 4 | }, 5 | 6 | getMenuState(defaultState = true) { 7 | return localStorage.getItem('menu') 8 | ? JSON.parse(localStorage.getItem('menu')) 9 | : defaultState 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/modules/device.js: -------------------------------------------------------------------------------- 1 | export default { 2 | isMobile() { 3 | const userAgent = navigator.userAgent 4 | return ( 5 | userAgent.match(/Android/i) || 6 | userAgent.match(/webOS/i) || 7 | userAgent.match(/iPhone/i) || 8 | userAgent.match(/iPad/i) || 9 | userAgent.match(/iPod/i) || 10 | userAgent.match(/BlackBerry/i) || 11 | userAgent.match(/Windows Phone/i) 12 | ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/modules/clipboard.js: -------------------------------------------------------------------------------- 1 | export default { 2 | copy(text) { 3 | const element = document.createElement('textarea') 4 | element.value = text 5 | element.style.position = 'fixed' 6 | document.body.appendChild(element) 7 | element.focus({ preventScroll: true }) 8 | element.setSelectionRange(0, element.value.length) 9 | document.execCommand('copy') 10 | document.body.removeChild(element) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/modules/keyboard.js: -------------------------------------------------------------------------------- 1 | const keys = { 2 | alphabet: ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] 3 | } 4 | 5 | export default { 6 | bindEvents(state, actions) { 7 | document.addEventListener('keypress', event => { 8 | if (keys.alphabet.includes(event.key)) { 9 | if (state.search.length > 0) return 10 | actions.search(event.key) 11 | } 12 | }) 13 | 14 | document.addEventListener('keydown', event => { 15 | if (event.key === 'Escape') { 16 | actions.search('') 17 | } 18 | }) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/components/MobileFallback.js: -------------------------------------------------------------------------------- 1 | import { h } from 'hyperapp' 2 | 3 | export default () => ( 4 |
5 |

6 | 🚀 Rocket Emoji is a desktop website. Please connect from your desktop to 7 | use it. 8 |

9 |

10 | It is the fastest way to find and copy an emoji to your clipboard! 11 |

12 | 18 |
19 | ) 20 | -------------------------------------------------------------------------------- /src/modules/serviceWorker.js: -------------------------------------------------------------------------------- 1 | export default { 2 | register() { 3 | if (process.env.NODE_ENV !== 'production') return 4 | if ('serviceWorker' in navigator) { 5 | window.addEventListener('load', () => { 6 | const swPath = `service-worker.js` 7 | navigator.serviceWorker.register(swPath).then( 8 | registration => { 9 | console.log( 10 | 'ServiceWorker registration successful with scope: ', 11 | registration.scope 12 | ) 13 | }, 14 | err => { 15 | console.log('ServiceWorker registration failed: ', err) 16 | } 17 | ) 18 | }) 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Features display](https://res.cloudinary.com/picturesbase/video/upload/c_crop,g_north,h_913,w_1790/v1549280289/rocketemoji_drivfk.gif) 2 | 3 | ## Usage 4 | 5 | 1. `npm install` 6 | 2. `npm run dev` 7 | 8 | ## Dependencies 9 | 10 | - [Hyperapp](https://github.com/hyperapp/hyperapp) - Minimal (1kb), Functional + Stateless components 11 | - [Tailwind](https://tailwindcss.com/docs/what-is-tailwind/) - A utility-first CSS framework for rapidly building custom user interfaces. - [Article](https://www.mikecr.it/ramblings/functional-css/) 12 | - [PurgeCSS](https://github.com/FullHuman/purgecss) - Remove unused css (useful with tailwindcss) 13 | - [Picostyle](https://github.com/morishitter/picostyle) - Ultra small CSS in JS library in 0.4 KB 14 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | const tailwindcss = require('tailwindcss') 2 | const purgecss = require('@fullhuman/postcss-purgecss') 3 | 4 | // This will extract variants 5 | class TailwindExtractor { 6 | static extract(content) { 7 | return content.match(/[A-Za-z0-9-_:\/]+/g) || [] 8 | } 9 | } 10 | 11 | module.exports = { 12 | plugins: [ 13 | tailwindcss('./tailwind.js'), 14 | ...(process.env.NODE_ENV === 'production' 15 | ? [ 16 | purgecss({ 17 | content: ['./index.html', './src/*.js', './src/components/*.js'], 18 | extractors: [ 19 | { 20 | extractor: TailwindExtractor, 21 | extensions: ['js', 'html'] 22 | } 23 | ] 24 | }) 25 | ] 26 | : []), 27 | require('autoprefixer') 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rocket-emoji", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "serve ./dist --single", 8 | "dev": "parcel index.html", 9 | "build": "parcel build index.html --public-url ./" 10 | }, 11 | "author": "Victor Mustar (www.jubiwee.com)", 12 | "license": "ISC", 13 | "dependencies": { 14 | "hyperapp": "^1.2.9", 15 | "picostyle": "^2.1.1", 16 | "serve": "^10.1.2" 17 | }, 18 | "devDependencies": { 19 | "@babel/core": "^7.2.2", 20 | "@babel/plugin-transform-react-jsx": "^7.3.0", 21 | "@babel/plugin-transform-runtime": "^7.2.0", 22 | "@babel/preset-env": "^7.3.1", 23 | "@fullhuman/postcss-purgecss": "^1.1.0", 24 | "@hyperapp/logger": "^0.4.1", 25 | "autoprefixer": "^9.4.6", 26 | "parcel": "^1.11.0", 27 | "parcel-plugin-sw-precache": "^1.0.3", 28 | "purgecss": "^1.0.1", 29 | "tailwindcss": "^0.4.1" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rocket Emoji - The fastest way to copy and paste emojis 5 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010-2018 Google, Inc. http://angularjs.org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/components/Search.js: -------------------------------------------------------------------------------- 1 | import { h } from 'hyperapp' 2 | import picostyle from 'picostyle' 3 | const style = picostyle(h) 4 | 5 | const resolveDrag = (e, cb) => { 6 | const offset = { x: e.offsetX, y: e.offsetY } 7 | document.addEventListener('mousemove', function drag(e) { 8 | if (e.buttons !== 1) { 9 | document.removeEventListener('mousemove', drag) 10 | return 11 | } 12 | cb({ x: e.clientX - offset.x, y: e.clientY - offset.y }) 13 | document.addEventListener('mouseup', function drop() { 14 | document.removeEventListener('mousemove', drag) 15 | document.removeEventListener('mouseup', drop) 16 | }) 17 | }) 18 | } 19 | 20 | const StyledSearch = style('input')(props => ({ 21 | transform: props.x ? '' : 'translate3d(-50%, -50%, 0)', 22 | left: props.x ? `${props.x}px` : '50%', 23 | top: props.y ? `${props.y}px` : '50%' 24 | })) 25 | 26 | export default ({ value, pos, oninput, ondrag }) => ( 27 | $el.focus()} 33 | oninput={e => oninput(e.target.value)} 34 | onmousedown={e => resolveDrag(e, ondrag)} 35 | class="fixed bg-black p-4 text-2xl z-10 rounded text-white shadow" 36 | /> 37 | ) 38 | -------------------------------------------------------------------------------- /src/components/Emoji.js: -------------------------------------------------------------------------------- 1 | import { h } from 'hyperapp' 2 | import clipboard from '../modules/clipboard' 3 | import picostyle, { keyframes } from 'picostyle' 4 | const style = picostyle(h) 5 | 6 | const StyledEmoji = style('button')(props => ({ 7 | transition: 'text-shadow .2s ease-in', 8 | textShadow: 'rgba(12, 8, 9, 0) 1px 1px -2px', 9 | boxShadow: 'rgba(0, 0, 0, 0.2) 0 0 0 0 inset', 10 | ':hover': { 11 | boxShadow: 'rgba(0, 0, 0, 0.2) 0px -1px 2px 0px inset', 12 | textShadow: 'rgba(12, 8, 9, 0.53) 1px 1px 2px' 13 | }, 14 | '.active': { 15 | animation: `${keyframes({ 16 | from: { background: '#ffffff' }, 17 | to: { background: '#353535' } 18 | })} .2s 2 ease-in` 19 | } 20 | })) 21 | 22 | const toggleBlinkAnimation = target => { 23 | target.classList.add('active') 24 | target.addEventListener('animationend', function removeAnimation() { 25 | target.classList.remove('active') 26 | target.removeEventListener('animationend', removeAnimation) 27 | }) 28 | } 29 | 30 | const handleClick = ({ target }) => { 31 | clipboard.copy(target.textContent) 32 | toggleBlinkAnimation(target) 33 | } 34 | 35 | export default ({ emoji }) => ( 36 | 40 | {emoji.symbol} 41 | 42 | ) 43 | -------------------------------------------------------------------------------- /src/components/Menu.js: -------------------------------------------------------------------------------- 1 | import { h } from 'hyperapp' 2 | import { storage } from '../modules' 3 | 4 | export default ({ active, ontoggle }) => ( 5 |