forked from github/plane
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;
|
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";
|
import { Tab, Transition, Popover } from "@headlessui/react";
|
||||||
// hooks
|
// hooks
|
||||||
import useOutsideClickDetector from "lib/hooks/useOutsideClickDetector";
|
import useOutsideClickDetector from "lib/hooks/useOutsideClickDetector";
|
||||||
|
// common
|
||||||
|
import { getRandomEmoji } from "constants/common";
|
||||||
// emoji
|
// emoji
|
||||||
import emojis from "./emojis.json";
|
import emojis from "./emojis.json";
|
||||||
// helpers
|
// helpers
|
||||||
@ -36,6 +38,10 @@ const EmojiIconPicker: React.FC<Props> = ({ label, value, onChange }) => {
|
|||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!value) onChange(getRandomEmoji());
|
||||||
|
}, [value, onChange]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover className="relative" ref={ref}>
|
<Popover className="relative" ref={ref}>
|
||||||
<Popover.Button
|
<Popover.Button
|
||||||
|
Loading…
Reference in New Issue
Block a user