Skip to content
This repository has been archived by the owner on Dec 3, 2022. It is now read-only.

Commit

Permalink
add copy event
Browse files Browse the repository at this point in the history
  • Loading branch information
senelway committed Sep 30, 2018
1 parent 7033581 commit bfa99bd
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<html> <head> <title>markmoji</title> <meta charset="UTF-8"> <link rel="“manifest”" href="/manifest.json"> <link href="/style.6624ae52.css"> </head> <body> <div id="app"></div> <script src="/src.7123e05a.js"></script> </body> </html>
<html> <head> <title>markmoji</title> <meta charset="UTF-8"> <link rel="“manifest”" href="/manifest.json"> <link rel="stylesheet" href="/style.fd97e3e6.css"> </head> <body> <div id="app">loading...</div> <script src="/src.7f75be0a.js"></script> </body> </html>
4 changes: 2 additions & 2 deletions dist/src.7123e05a.js → dist/src.7f75be0a.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/style.6624ae52.css → dist/style.fd97e3e6.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<title>markmoji</title>
<meta charset="UTF-8" />
<link rel=“manifest” href="./manifest.json" />
<link href="./src/style.css" />
<link rel="stylesheet" href="./src/style.css" />
</head>
<body>
<div id="app"></div>
<div id="app">loading...</div>
<script src="./src/index.js"></script>
</body>
</html>
20 changes: 10 additions & 10 deletions src/emoji.json
Original file line number Diff line number Diff line change
Expand Up @@ -863,18 +863,18 @@
"small_red_triangle": ":small_red_triangle:",
"small_red_triangle_down": ":small_red_triangle_down:",
"shipit": ":shipit:",
"info": "info",
"warning": "warning",
"note": "note",
"tip": "tip",
"parking": "parking",
"restroom": "restroom",
"speedboat": "speedboat",
"handbag": "handbag",
"info": ":info:",
"warning": ":warning:",
"note": ":note:",
"tip": ":tip:",
"parking": ":parking:",
"restroom": ":restroom:",
"speedboat": ":speedboat:",
"handbag": ":handbag:",
"roll_eyes": ":roll_eyes:",
"thermometer": ":thermometer:",
"nerd_face": ":nerd_face:",
"old_key": "old_key",
"old_key": ":old_key:",
"man_facepalming": ":man_facepalming:",
"woman_facepalming": ":woman_facepalming:"
}
}
14 changes: 13 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@ const root = document.body;

const toLowerCase = e => e.toLowerCase();

const copyTextToClipboard = text => {
const copyFrom = document.createElement("textarea");
copyFrom.textContent = text;
document.body.appendChild(copyFrom);
copyFrom.select();
document.execCommand('copy');
copyFrom.blur();
document.body.removeChild(copyFrom);
console.log(text);
}

const markmoji = {
search: '',
onCopy: copyTextToClipboard,
onChange: ({ currentTarget }) => markmoji.search = currentTarget.value,
onFiltrate: data => {
const keys = Object.keys(data);
Expand All @@ -23,7 +35,7 @@ const markmoji = {
m('div', { class: 'b-flex' }, [
markmoji.onFiltrate(json).length
? markmoji.onFiltrate(json).map(e => (
m('p', { class: 'gitmoji-element' }, [
m('p', { class: 'gitmoji-element', onclick: () => markmoji.onCopy(json[e]) }, [
m('span', translate.translate(e)),
m('code', json[e])
])
Expand Down
8 changes: 6 additions & 2 deletions src/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import 'normalize.css';

:root {
--grey: #eee,
--grey: #eee;
}

* {
Expand All @@ -11,8 +11,12 @@
html, body {
font-size: 14px;
}
body {
padding: 20px;
}

.b-flex {
width: 600px;
display: flex;
flex-wrap: wrap;
padding: 10px;
Expand All @@ -27,7 +31,7 @@ html, body {

.gitmoji-element:hover {
transition: 0.6s;
transform: translateX(20px) scale(1.2);
transform: translateX(20px) scale(1.1);
}

code {
Expand Down

0 comments on commit bfa99bd

Please sign in to comment.