From 9d3bbc7e5cc9b2d1090180178e391a3ca78d072c Mon Sep 17 00:00:00 2001 From: Spectralitree <72747870+Spectralitree@users.noreply.github.com> Date: Sun, 19 Dec 2021 09:53:13 +0100 Subject: [PATCH] feat: group editing! --- src/lib/CardsHeader.svelte | 2 +- src/lib/group/Body.svelte | 26 ++++++++++--- src/lib/group/Edit.svelte | 76 ++++++++++++++++++++++++++++++++++++++ src/lib/group/List.svelte | 9 +++-- 4 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 src/lib/group/Edit.svelte diff --git a/src/lib/CardsHeader.svelte b/src/lib/CardsHeader.svelte index fe09f7bc..bd2f3da5 100644 --- a/src/lib/CardsHeader.svelte +++ b/src/lib/CardsHeader.svelte @@ -10,7 +10,7 @@ let avatarOpen = false; const toggleAvatarModal = () => (avatarOpen = !avatarOpen); - export let loading: boolean; + export let loading: boolean = false; diff --git a/src/lib/group/Body.svelte b/src/lib/group/Body.svelte index 8c63ce2a..8da89b42 100644 --- a/src/lib/group/Body.svelte +++ b/src/lib/group/Body.svelte @@ -3,24 +3,38 @@ import moment from 'moment'; import { toHTML } from 'discord-markdown'; import type Group from '../../api/group'; + import Edit from './Edit.svelte'; + import twemoji from 'twemoji'; - export let group: Group; + export let item: Group; + let group = item; let editMode: boolean; export let isPublic: boolean; + export let loading: boolean = false; let htmlDescription: string; - if (group.description) { + $: if (group.description) { htmlDescription = toHTML(group.description, {embed: true}); } else { htmlDescription = "(no description)"; } + let htmlDisplayName: string; + if (group.display_name) htmlDisplayName = toHTML(group.display_name) + + let settings = JSON.parse(localStorage.getItem("pk-settings")); + let descriptionElement: any; + let displayNameElement: any; + + $: if (settings && settings.appearance.twemoji) { + if (descriptionElement) twemoji.parse(descriptionElement); + if (displayNameElement) twemoji.parse(displayNameElement); + }; let created = moment(group.created).format("MMM D, YYYY"); let bannerOpen = false; const toggleBannerModal = () => (bannerOpen = !bannerOpen); - let settings = JSON.parse(localStorage.getItem("pk-settings")); @@ -38,7 +52,7 @@ {/if} {#if group.display_name} - Display Name: {group.display_name} + Display Name: {@html htmlDisplayName} {/if} {#if group.created && !isPublic} @@ -62,7 +76,7 @@ {/if} -
+
Description:
{@html htmlDescription}
@@ -73,6 +87,6 @@ {/if} {:else} -woohoo editing goes here + {/if} \ No newline at end of file diff --git a/src/lib/group/Edit.svelte b/src/lib/group/Edit.svelte new file mode 100644 index 00000000..5e158aa8 --- /dev/null +++ b/src/lib/group/Edit.svelte @@ -0,0 +1,76 @@ + + +{#each err as error} + {@html error} +{/each} + + + + + + + + + + + + + + + + + + + + + + +
+ Description:
+