cobalt/src/modules/emoji.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

const names = {
"🎶": "musical_notes",
"🎬": "clapper_board",
"🎉": "party_popper",
"❓": "question_mark",
"✨": "sparkles",
"🪅": "pinata",
"🪄": "magic_wand",
2022-09-11 16:04:06 +01:00
"🐲": "dragon_face",
"🀄": "dragon_face_wukko",
"💸": "money_with_wings",
"⚙️": "gear",
2022-09-08 17:02:55 +01:00
"☹️": "frowning_face",
"📋": "clipboard",
"🎃": "pumpkin",
"🎄": "christmas_tree",
"🕯️": "candle",
"😺": "cat",
"🐶": "dog",
"🎂": "cake",
"🐘": "elephant",
"🐦": "bird",
"🐙": "octopus",
"🔮": "crystal_ball",
2023-05-17 17:50:11 +01:00
"💪": "biceps",
2023-05-23 17:52:17 +01:00
"💖": "sparkling_heart",
"👾": "alien_monster"
}
let sizing = {
18: 0.8,
22: 0.4,
30: 0.7,
48: 0.9,
64: 0.9
}
export default function(emoji, size, disablePadding) {
if (!size) size = 22;
let padding = size !== 22 ? `margin-right:${sizing[size] ? sizing[size] : "0.4"}rem;` : false;
if (disablePadding) padding = 'margin-right:0!important;';
if (!names[emoji]) emoji = "❓";
2023-06-07 11:18:41 +01:00
return `<img class="emoji" draggable=false height="${size}" width="${size}" ${padding ? `style="${padding}"` : ''}alt="${emoji}" src="emoji/${names[emoji]}.svg" loading="lazy">`
}