mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: emoji render function (#1484)
* fix: emoji render function * fix: emoji render function
This commit is contained in:
parent
3a2f4d55d7
commit
49f37e0346
@ -23,6 +23,7 @@ import {
|
|||||||
import { ContrastIcon, LayerDiagonalIcon } from "components/icons";
|
import { ContrastIcon, LayerDiagonalIcon } from "components/icons";
|
||||||
// helpers
|
// helpers
|
||||||
import { renderShortDate } from "helpers/date-time.helper";
|
import { renderShortDate } from "helpers/date-time.helper";
|
||||||
|
import { renderEmoji } from "helpers/emoji.helper";
|
||||||
// types
|
// types
|
||||||
import {
|
import {
|
||||||
IAnalyticsParams,
|
IAnalyticsParams,
|
||||||
@ -221,7 +222,7 @@ export const AnalyticsSidebar: React.FC<Props> = ({
|
|||||||
<div className="text-sm flex items-center gap-1">
|
<div className="text-sm flex items-center gap-1">
|
||||||
{project.emoji ? (
|
{project.emoji ? (
|
||||||
<span className="grid h-6 w-6 flex-shrink-0 place-items-center">
|
<span className="grid h-6 w-6 flex-shrink-0 place-items-center">
|
||||||
{String.fromCodePoint(parseInt(project.emoji))}
|
{renderEmoji(project.emoji)}
|
||||||
</span>
|
</span>
|
||||||
) : project.icon_prop ? (
|
) : project.icon_prop ? (
|
||||||
<div className="h-6 w-6 grid place-items-center flex-shrink-0">
|
<div className="h-6 w-6 grid place-items-center flex-shrink-0">
|
||||||
@ -336,7 +337,7 @@ export const AnalyticsSidebar: React.FC<Props> = ({
|
|||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
{projectDetails?.emoji ? (
|
{projectDetails?.emoji ? (
|
||||||
<div className="grid h-6 w-6 flex-shrink-0 place-items-center">
|
<div className="grid h-6 w-6 flex-shrink-0 place-items-center">
|
||||||
{String.fromCodePoint(parseInt(projectDetails.emoji))}
|
{renderEmoji(projectDetails.emoji)}
|
||||||
</div>
|
</div>
|
||||||
) : projectDetails?.icon_prop ? (
|
) : projectDetails?.icon_prop ? (
|
||||||
<div className="h-6 w-6 grid place-items-center flex-shrink-0">
|
<div className="h-6 w-6 grid place-items-center flex-shrink-0">
|
||||||
|
@ -10,7 +10,7 @@ import emojis from "./emojis.json";
|
|||||||
import icons from "./icons.json";
|
import icons from "./icons.json";
|
||||||
// helpers
|
// helpers
|
||||||
import { getRecentEmojis, saveRecentEmoji } from "./helpers";
|
import { getRecentEmojis, saveRecentEmoji } from "./helpers";
|
||||||
import { getRandomEmoji } from "helpers/common.helper";
|
import { getRandomEmoji, renderEmoji } from "helpers/emoji.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
import useOutsideClickDetector from "hooks/use-outside-click-detector";
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ const EmojiIconPicker: React.FC<Props> = ({ label, value, onChange, onIconColorC
|
|||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{String.fromCodePoint(parseInt(emoji))}
|
{renderEmoji(emoji)}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@ -121,7 +121,7 @@ const EmojiIconPicker: React.FC<Props> = ({ label, value, onChange, onIconColorC
|
|||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{String.fromCodePoint(parseInt(emoji))}
|
{renderEmoji(emoji)}
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,7 @@ import { XMarkIcon } from "@heroicons/react/24/outline";
|
|||||||
import { ImagePickerPopover } from "components/core";
|
import { ImagePickerPopover } from "components/core";
|
||||||
import EmojiIconPicker from "components/emoji-icon-picker";
|
import EmojiIconPicker from "components/emoji-icon-picker";
|
||||||
// helpers
|
// helpers
|
||||||
import { getRandomEmoji } from "helpers/common.helper";
|
import { getRandomEmoji, renderEmoji } from "helpers/emoji.helper";
|
||||||
// types
|
// types
|
||||||
import { ICurrentUserResponse, IProject } from "types";
|
import { ICurrentUserResponse, IProject } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
@ -232,7 +232,7 @@ export const CreateProjectModal: React.FC<Props> = (props) => {
|
|||||||
{value.name}
|
{value.name}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
String.fromCodePoint(parseInt(value))
|
renderEmoji(value)
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
"Icon"
|
"Icon"
|
||||||
|
@ -24,6 +24,7 @@ import {
|
|||||||
// helpers
|
// helpers
|
||||||
import { renderShortDateWithYearFormat } from "helpers/date-time.helper";
|
import { renderShortDateWithYearFormat } from "helpers/date-time.helper";
|
||||||
import { copyTextToClipboard, truncateText } from "helpers/string.helper";
|
import { copyTextToClipboard, truncateText } from "helpers/string.helper";
|
||||||
|
import { renderEmoji } from "helpers/emoji.helper";
|
||||||
// types
|
// types
|
||||||
import type { IFavoriteProject, IProject } from "types";
|
import type { IFavoriteProject, IProject } from "types";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
@ -184,7 +185,7 @@ export const SingleProjectCard: React.FC<ProjectCardProps> = ({
|
|||||||
<h3 className="text-1.5xl font-medium text-brand-base">{project.name}</h3>
|
<h3 className="text-1.5xl font-medium text-brand-base">{project.name}</h3>
|
||||||
{project.emoji ? (
|
{project.emoji ? (
|
||||||
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
||||||
{String.fromCodePoint(parseInt(project.emoji))}
|
{renderEmoji(project.emoji)}
|
||||||
</span>
|
</span>
|
||||||
) : project.icon_prop ? (
|
) : project.icon_prop ? (
|
||||||
<span
|
<span
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
} from "components/icons";
|
} from "components/icons";
|
||||||
// helpers
|
// helpers
|
||||||
import { truncateText } from "helpers/string.helper";
|
import { truncateText } from "helpers/string.helper";
|
||||||
|
import { renderEmoji } from "helpers/emoji.helper";
|
||||||
// types
|
// types
|
||||||
import { IProject } from "types";
|
import { IProject } from "types";
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ export const SingleSidebarProject: React.FC<Props> = ({
|
|||||||
<div className="flex items-center gap-x-2">
|
<div className="flex items-center gap-x-2">
|
||||||
{project.emoji ? (
|
{project.emoji ? (
|
||||||
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
<span className="grid h-7 w-7 flex-shrink-0 place-items-center rounded uppercase">
|
||||||
{String.fromCodePoint(parseInt(project.emoji))}
|
{renderEmoji(project.emoji)}
|
||||||
</span>
|
</span>
|
||||||
) : project.icon_prop ? (
|
) : project.icon_prop ? (
|
||||||
<div className="h-7 w-7 grid place-items-center">
|
<div className="h-7 w-7 grid place-items-center">
|
||||||
|
@ -16,23 +16,3 @@ export const debounce = (func: any, wait: number, immediate: boolean = false) =>
|
|||||||
if (callNow) func(...args);
|
if (callNow) func(...args);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
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)];
|
|
||||||
};
|
|
||||||
|
25
apps/app/helpers/emoji.helper.ts
Normal file
25
apps/app/helpers/emoji.helper.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
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)];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderEmoji = (emoji: string) => {
|
||||||
|
if (!emoji) return;
|
||||||
|
|
||||||
|
return isNaN(parseInt(emoji)) ? emoji : String.fromCodePoint(parseInt(emoji));
|
||||||
|
};
|
@ -27,6 +27,8 @@ import {
|
|||||||
DangerButton,
|
DangerButton,
|
||||||
} from "components/ui";
|
} from "components/ui";
|
||||||
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
||||||
|
// helpers
|
||||||
|
import { renderEmoji } from "helpers/emoji.helper";
|
||||||
// types
|
// types
|
||||||
import { IProject, IWorkspace } from "types";
|
import { IProject, IWorkspace } from "types";
|
||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
@ -186,7 +188,7 @@ const GeneralSettings: NextPage = () => {
|
|||||||
{value.name}
|
{value.name}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
String.fromCodePoint(parseInt(value))
|
renderEmoji(value)
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
"Icon"
|
"Icon"
|
||||||
|
Loading…
Reference in New Issue
Block a user