mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
[Glitch] Emoji Component
Port c12b8f51c1 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { isList } from 'immutable';
|
||||
|
||||
import { assetHost } from '@/flavours/glitch/utils/config';
|
||||
|
||||
import {
|
||||
VARIATION_SELECTOR_CODE,
|
||||
KEYCAP_CODE,
|
||||
@@ -9,11 +11,7 @@ import {
|
||||
EMOJIS_WITH_DARK_BORDER,
|
||||
EMOJIS_WITH_LIGHT_BORDER,
|
||||
} from './constants';
|
||||
import type {
|
||||
CustomEmojiMapArg,
|
||||
ExtraCustomEmojiMap,
|
||||
TwemojiBorderInfo,
|
||||
} from './types';
|
||||
import type { CustomEmojiMapArg, ExtraCustomEmojiMap } from './types';
|
||||
|
||||
// Misc codes that have special handling
|
||||
const SKIER_CODE = 0x26f7;
|
||||
@@ -67,21 +65,17 @@ export const CODES_WITH_DARK_BORDER =
|
||||
export const CODES_WITH_LIGHT_BORDER =
|
||||
EMOJIS_WITH_LIGHT_BORDER.map(emojiToUnicodeHex);
|
||||
|
||||
export function twemojiHasBorder(twemojiHex: string): TwemojiBorderInfo {
|
||||
const normalizedHex = twemojiHex.toUpperCase();
|
||||
let hasLightBorder = false;
|
||||
let hasDarkBorder = false;
|
||||
if (CODES_WITH_LIGHT_BORDER.includes(normalizedHex)) {
|
||||
hasLightBorder = true;
|
||||
export function unicodeHexToUrl(unicodeHex: string, darkMode: boolean): string {
|
||||
const normalizedHex = unicodeToTwemojiHex(unicodeHex);
|
||||
let url = `${assetHost}/emoji/${normalizedHex}`;
|
||||
if (darkMode && CODES_WITH_LIGHT_BORDER.includes(normalizedHex)) {
|
||||
url += '_border';
|
||||
}
|
||||
if (CODES_WITH_DARK_BORDER.includes(normalizedHex)) {
|
||||
hasDarkBorder = true;
|
||||
url += '_border';
|
||||
}
|
||||
return {
|
||||
hexCode: twemojiHex,
|
||||
hasLightBorder,
|
||||
hasDarkBorder,
|
||||
};
|
||||
url += '.svg';
|
||||
return url;
|
||||
}
|
||||
|
||||
interface TwemojiSpecificEmoji {
|
||||
|
||||
Reference in New Issue
Block a user