mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
feat: random emoji will be chosen if none provided
This commit is contained in:
parent
f322bcc4b0
commit
18cf044e3b
@ -216,3 +216,23 @@ export const createSimilarString = (str: string) => {
|
||||
|
||||
return shuffled;
|
||||
};
|
||||
|
||||
export const getRandomEmoji = () => {
|
||||
const emojis = [
|
||||
"8986",
|
||||
"9200",
|
||||
"128204",
|
||||
"127773",
|
||||
"127891",
|
||||
"127947",
|
||||
"128076",
|
||||
"128077",
|
||||
"128187",
|
||||
"128188",
|
||||
"128512",
|
||||
"128522",
|
||||
"128578",
|
||||
];
|
||||
|
||||
return emojis[Math.floor(Math.random() * emojis.length)];
|
||||
};
|
||||
|
@ -3,6 +3,8 @@ import React, { useEffect, useState, useRef } from "react";
|
||||
import { Tab, Transition, Popover } from "@headlessui/react";
|
||||
// hooks
|
||||
import useOutsideClickDetector from "lib/hooks/useOutsideClickDetector";
|
||||
// common
|
||||
import { getRandomEmoji } from "constants/common";
|
||||
// emoji
|
||||
import emojis from "./emojis.json";
|
||||
// helpers
|
||||
@ -36,6 +38,10 @@ const EmojiIconPicker: React.FC<Props> = ({ label, value, onChange }) => {
|
||||
setIsOpen(false);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!value) onChange(getRandomEmoji());
|
||||
}, [value, onChange]);
|
||||
|
||||
return (
|
||||
<Popover className="relative" ref={ref}>
|
||||
<Popover.Button
|
||||
|
Loading…
Reference in New Issue
Block a user