From 861fb4949a3770a4cb943e76bd4a062f57e2b751 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Wed, 23 Aug 2023 18:15:04 -0700 Subject: [PATCH] feat: add card view --- src/lib/settings.ts | 2 + src/routes/modlog/+page.svelte | 89 +++++++++++-------- src/routes/modlog/item/ModlogItemCard.svelte | 55 ++++++++++++ .../ModlogItemTable.svelte} | 7 +- 4 files changed, 111 insertions(+), 42 deletions(-) create mode 100644 src/routes/modlog/item/ModlogItemCard.svelte rename src/routes/modlog/{ModlogItem.svelte => item/ModlogItemTable.svelte} (81%) diff --git a/src/lib/settings.ts b/src/lib/settings.ts index d969608f..bb2b5ecc 100644 --- a/src/lib/settings.ts +++ b/src/lib/settings.ts @@ -49,6 +49,7 @@ interface Settings { } newVote: boolean randomPlaceholders: boolean + modlogCardView: boolean | undefined } export const defaultSettings: Settings = { @@ -85,6 +86,7 @@ export const defaultSettings: Settings = { }, newVote: toBool(env.PUBLIC_NEW_VOTE_BUTTONS) ?? false, randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? true, + modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined, } export const userSettings = writable(defaultSettings) diff --git a/src/routes/modlog/+page.svelte b/src/routes/modlog/+page.svelte index 3086e172..87e5954c 100644 --- a/src/routes/modlog/+page.svelte +++ b/src/routes/modlog/+page.svelte @@ -1,13 +1,13 @@ @@ -70,42 +70,57 @@ searchParam($page.url, 'community', e.detail?.id.toString(), 'page')} /> + ($userSettings.modlogCardView = e.detail)} + /> {#if data.modlog} -
- - - - - - - - - - - - - - - - - - - - - - - - - {#each data.modlog as modlog} - - {/each} - -
TimeModeratorActionUserCommunityContentReasonLink
-
+ {#if $userSettings.modlogCardView ?? !window.matchMedia('(min-width: 1600px)').matches} +
+ {#each data.modlog as modlog} + + {/each} +
+ {:else} +
+ + + + + + + + + + + + + + + + + + + + + + + + + {#each data.modlog as modlog} + + {/each} + +
TimeModeratorActionUserCommunityContentReasonLink
+
+ {/if} {/if} + import Link from '$lib/components/input/Link.svelte' + import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte' + import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte' + import UserLink from '$lib/components/lemmy/user/UserLink.svelte' + import Card from '$lib/components/ui/Card.svelte' + import SectionTitle from '$lib/components/ui/SectionTitle.svelte' + import RelativeDate from '$lib/components/util/RelativeDate.svelte' + import type { ModLog } from '../+page.js' + import ModlogAction from '../ModlogAction.svelte' + + export let item: ModLog + + + +
+ {#if item.community} + + {/if} + + + +
+ {#if item.actionName} + Action + + + + {/if} + {#if item.moderator} + Moderator + + + + + {/if} + {#if item.moderatee} + User + + {/if} + {#if item.link || item.content} + Submission + {#if item.link && item.content} + + {item.content} + + {:else if item.content} +

{item.content}

+ {:else if item.link} + + {/if} + {/if} +
diff --git a/src/routes/modlog/ModlogItem.svelte b/src/routes/modlog/item/ModlogItemTable.svelte similarity index 81% rename from src/routes/modlog/ModlogItem.svelte rename to src/routes/modlog/item/ModlogItemTable.svelte index 539e31af..07122ae4 100644 --- a/src/routes/modlog/ModlogItem.svelte +++ b/src/routes/modlog/item/ModlogItemTable.svelte @@ -2,12 +2,9 @@ import Link from '$lib/components/input/Link.svelte' import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte' import UserLink from '$lib/components/lemmy/user/UserLink.svelte' - import Card from '$lib/components/ui/Card.svelte' - import SectionTitle from '$lib/components/ui/SectionTitle.svelte' import RelativeDate from '$lib/components/util/RelativeDate.svelte' - import { Icon, Trash, XCircle } from 'svelte-hero-icons' - import type { ModLog } from './+page.js' - import ModlogAction from './ModlogAction.svelte' + import type { ModLog } from '../+page.js' + import ModlogAction from '../ModlogAction.svelte' export let item: ModLog