From 5c4cfdd4d89671621a1b8273d981dccf6f8f9d75 Mon Sep 17 00:00:00 2001 From: saltrafael <76502841+saltrafael@users.noreply.github.com> Date: Wed, 27 Oct 2021 15:20:47 -0300 Subject: [PATCH] [New Feature] Comment Emotes (#125) * Refactor form-field * Create new Emote Menu * Add Emotes * Add Emote Selector and Emote Comment creation ability * Fix and Split CSS --- static/app-strings.json | 80 ++ ui/component/commentCreate/emote-selector.jsx | 68 ++ ui/component/commentCreate/view.jsx | 21 +- .../common/form-components/form-field.jsx | 398 +++++----- ui/component/common/icon-custom.jsx | 8 + ui/component/common/markdown-preview.jsx | 56 +- ui/component/optimizedImage/view.jsx | 9 +- ui/constants/emotes.js | 96 +++ ui/constants/icons.js | 1 + ui/scss/component/_button.scss | 6 - ui/scss/component/_comment-create.scss | 82 ++ ui/scss/component/_comments.scss | 70 +- ui/scss/component/_emote-selector.scss | 40 + ui/scss/component/_form-field.scss | 8 - ui/util/remark-emote.js | 125 +++ ui/util/remark-lbry.js | 2 +- .../themes/odysee/component/_form-field.scss | 711 ++++++++++++++++++ 17 files changed, 1458 insertions(+), 323 deletions(-) create mode 100644 ui/component/commentCreate/emote-selector.jsx create mode 100644 ui/constants/emotes.js create mode 100644 ui/scss/component/_comment-create.scss create mode 100644 ui/scss/component/_emote-selector.scss create mode 100644 ui/util/remark-emote.js create mode 100644 web/scss/themes/odysee/component/_form-field.scss diff --git a/static/app-strings.json b/static/app-strings.json index 99b65f1ec..600ca762d 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -2239,5 +2239,85 @@ "A channel is required to repost on LBRY": "A channel is required to repost on LBRY", "Failed to view lbry://@gatogalactico#9/gato-galactico-e-as-estrelas-ninja-dos#1, please try again. If this problem persists, visit https://lbry.com/faq/support for support.": "Failed to view lbry://@gatogalactico#9/gato-galactico-e-as-estrelas-ninja-dos#1, please try again. If this problem persists, visit https://lbry.com/faq/support for support.", "Admin": "Admin", + ":ALIEN:": ":ALIEN:", + ":ANGRY_2:": ":ANGRY_2:", + ":ANGRY_3:": ":ANGRY_3:", + ":ANGRY_4:": ":ANGRY_4:", + ":ANGRY_1:": ":ANGRY_1:", + ":BLIND:": ":BLIND:", + ":BLOCK:": ":BLOCK:", + ":BOMB:": ":BOMB:", + ":BRAIN_CHIP:": ":BRAIN_CHIP:", + ":CONFIRM:": ":CONFIRM:", + ":CONFUSED_1:": ":CONFUSED_1:", + ":CONFUSED_2:": ":CONFUSED_2:", + ":COOKING_SOMETHING_NICE:": ":COOKING_SOMETHING_NICE:", + ":CRY_2:": ":CRY_2:", + ":CRY_3:": ":CRY_3:", + ":CRY_4:": ":CRY_4:", + ":CRY_5:": ":CRY_5:", + ":CRY_1:": ":CRY_1:", + ":SPACE_DOGE:": ":SPACE_DOGE:", + ":DONUT:": ":DONUT:", + ":EGGPLANT_WITH_CONDOM:": ":EGGPLANT_WITH_CONDOM:", + ":EGGPLANT:": ":EGGPLANT:", + ":FIRE_UP:": ":FIRE_UP:", + ":FLAT_EARTH:": ":FLAT_EARTH:", + ":FLYING_SAUCER:": ":FLYING_SAUCER:", + ":HEART_CHOPPER:": ":HEART_CHOPPER:", + ":HYPER_TROLL:": ":HYPER_TROLL:", + ":ICE_CREAM:": ":ICE_CREAM:", + ":IDK:": ":IDK:", + ":ILLUMINATI_1:": ":ILLUMINATI_1:", + ":ILLUMINATI_2:": ":ILLUMINATI_2:", + ":KISS_2:": ":KISS_2:", + ":KISS_1:": ":KISS_1:", + ":LASER_GUN:": ":LASER_GUN:", + ":LAUGHING_2:": ":LAUGHING_2:", + ":LAUGHING_1:": ":LAUGHING_1:", + ":LOLLIPOP:": ":LOLLIPOP:", + ":LOVE_2:": ":LOVE_2:", + ":LOVE_1:": ":LOVE_1:", + ":MONSTER:": ":MONSTER:", + ":MUSHROOM:": ":MUSHROOM:", + ":NAIL_IT:": ":NAIL_IT:", + ":NO:": ":NO:", + ":OUCH:": ":OUCH:", + ":PREACE:": ":PREACE:", + ":PIZZA:": ":PIZZA:", + ":RABBIT_HOLE:": ":RABBIT_HOLE:", + ":RAINBOW_PUKE_1:": ":RAINBOW_PUKE_1:", + ":RAINBOW_PUKE_2:": ":RAINBOW_PUKE_2:", + ":SPACE_RESITAS:": ":SPACE_RESITAS:", + ":ROCK:": ":ROCK:", + ":SAD:": ":SAD:", + ":SALTY:": ":SALTY:", + ":SCARY:": ":SCARY:", + ":SLEEP:": ":SLEEP:", + ":SLIME_DOWN:": ":SLIME_DOWN:", + ":SMELLY_SOCKS:": ":SMELLY_SOCKS:", + ":SMILE_2:": ":SMILE_2:", + ":SMILE_1:": ":SMILE_1:", + ":SPACE_CHAD:": ":SPACE_CHAD:", + ":SPACE_JULIAN:": ":SPACE_JULIAN:", + ":SPACE_TOM:": ":SPACE_TOM:", + ":SPACE_WOJAK_1:": ":SPACE_WOJAK_1:", + ":SPOCK:": ":SPOCK:", + ":STAR:": ":STAR:", + ":SUNNY_DAY:": ":SUNNY_DAY:", + ":SUPRISED:": ":SUPRISED:", + ":SWEET:": ":SWEET:", + ":THINKING_1:": ":THINKING_1:", + ":THINKING_2:": ":THINKING_2:", + ":THUMB_DOWN:": ":THUMB_DOWN:", + ":THUMB_UP_1:": ":THUMB_UP_1:", + ":THUMB_UP_2:": ":THUMB_UP_2:", + ":TINFOIL_HAT:": ":TINFOIL_HAT:", + ":TROLL_KING:": ":TROLL_KING:", + ":UFO:": ":UFO:", + ":WAITING:": ":WAITING:", + ":WHAT:": ":WHAT:", + ":WOODOO_DOLL:": ":WOODOO_DOLL:", + "Global Emotes": "Global Emotes", "--end--": "--end--" } diff --git a/ui/component/commentCreate/emote-selector.jsx b/ui/component/commentCreate/emote-selector.jsx new file mode 100644 index 000000000..1dc1a1bd6 --- /dev/null +++ b/ui/component/commentCreate/emote-selector.jsx @@ -0,0 +1,68 @@ +// @flow +import 'scss/component/_emote-selector.scss'; +import { EMOTES_24px as EMOTES } from 'constants/emotes'; +import * as ICONS from 'constants/icons'; +import Button from 'component/button'; +import EMOJIS from 'emoji-dictionary'; +import OptimizedImage from 'component/optimizedImage'; +import React from 'react'; + +const OLD_QUICK_EMOJIS = [ + EMOJIS.getUnicode('rocket'), + EMOJIS.getUnicode('jeans'), + EMOJIS.getUnicode('fire'), + EMOJIS.getUnicode('heart'), + EMOJIS.getUnicode('open_mouth'), +]; + +type Props = { commentValue: string, setCommentValue: (string) => void, closeSelector: () => void }; + +export default function EmoteSelector(props: Props) { + const { commentValue, setCommentValue, closeSelector } = props; + + function addEmoteToComment(emote: string) { + setCommentValue( + commentValue + (commentValue && commentValue.charAt(commentValue.length - 1) !== ' ' ? ` ${emote} ` : `${emote} `) + ); + } + + return ( +