summaryrefslogtreecommitdiffstats
path: root/ui/src/utils.ts
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-14 16:07:20 -0400
committerDessalines <tyhou13@gmx.com>2020-04-14 16:07:20 -0400
commit1336b4ed6023e7fcf0fd40be63569966ee4b1b45 (patch)
treee62e4422e0ba0430ea6d060f01d20dee22d6e564 /ui/src/utils.ts
parentf040dac647d50c97e3f9ab8058563a7fe0f29261 (diff)
parent641e4c5d96d9d152bc75318b3ea08f789d920b2b (diff)
Merge branch 'dev' into federation
Diffstat (limited to 'ui/src/utils.ts')
-rw-r--r--ui/src/utils.ts24
1 files changed, 21 insertions, 3 deletions
diff --git a/ui/src/utils.ts b/ui/src/utils.ts
index e2310960..480b41c7 100644
--- a/ui/src/utils.ts
+++ b/ui/src/utils.ts
@@ -43,8 +43,9 @@ import twemoji from 'twemoji';
import emojiShortName from 'emoji-short-name';
import Toastify from 'toastify-js';
import tippy from 'tippy.js';
+import EmojiButton from '@joeattardi/emoji-button';
-export const repoUrl = 'https://github.com/dessalines/lemmy';
+export const repoUrl = 'https://github.com/LemmyNet/lemmy';
export const helpGuideUrl = '/docs/about_guide.html';
export const markdownHelpUrl = `${helpGuideUrl}#markdown-guide`;
export const sortingHelpUrl = `${helpGuideUrl}#sorting`;
@@ -88,6 +89,14 @@ export const themes = [
'i386',
];
+export const emojiPicker = new EmojiButton({
+ // Use the emojiShortName from native
+ style: 'twemoji',
+ theme: 'dark',
+ position: 'auto-start',
+ // TODO i18n
+});
+
export function randomStr() {
return Math.random()
.toString(36)
@@ -473,8 +482,9 @@ export function setupTribute(): Tribute {
{
trigger: ':',
menuItemTemplate: (item: any) => {
- let emoji = `:${item.original.key}:`;
- return `${item.original.val} ${emoji}`;
+ let shortName = `:${item.original.key}:`;
+ let twemojiIcon = twemoji.parse(item.original.val);
+ return `${twemojiIcon} ${shortName}`;
},
selectTemplate: (item: any) => {
return `:${item.original.key}:`;
@@ -824,6 +834,14 @@ function randomHsl() {
return `hsla(${Math.random() * 360}, 100%, 50%, 1)`;
}
+export function previewLines(text: string, lines: number = 3): string {
+ // Use lines * 2 because markdown requires 2 lines
+ return text
+ .split('\n')
+ .slice(0, lines * 2)
+ .join('\n');
+}
+
export function hostname(url: string): string {
return new URL(url).hostname;
}