From 848992175b1435195c4d4cb0be9e3f3be060af08 Mon Sep 17 00:00:00 2001 From: Xylight Date: Sun, 8 Sep 2024 17:23:29 -0700 Subject: [PATCH] feat: add TextProps component for reusable text modifications --- .../components/lemmy/post/PostActions.svelte | 80 ++++++++----------- src/lib/components/ui/EntityHeader.svelte | 7 +- src/lib/components/ui/tabs/FilterTabs.svelte | 7 +- src/lib/components/ui/text/TextProps.svelte | 16 ++++ src/lib/util.ts | 4 + src/routes/instances/[instance]/+page.svelte | 0 6 files changed, 61 insertions(+), 53 deletions(-) create mode 100644 src/lib/components/ui/text/TextProps.svelte create mode 100644 src/routes/instances/[instance]/+page.svelte diff --git a/src/lib/components/lemmy/post/PostActions.svelte b/src/lib/components/lemmy/post/PostActions.svelte index 93fe6ab4..6f3f09ae 100644 --- a/src/lib/components/lemmy/post/PostActions.svelte +++ b/src/lib/components/lemmy/post/PostActions.svelte @@ -56,8 +56,10 @@ import { hidePost, postLink } from './helpers' import { feature } from '$lib/version' import Switch from '$lib/components/input/Switch.svelte' - import { instanceToURL } from '$lib/util' + import { instanceId, instanceToURL } from '$lib/util' import { publishedToDate } from '$lib/components/util/date' + import TextProps from '$lib/components/ui/text/TextProps.svelte' + import { communityLink, userLink } from '$lib/lemmy/generic' export let post: PostView export let view: View = 'cozy' @@ -68,10 +70,6 @@ let editing = false let saving = false - let fediseerOpen = false - let fediseerData: Data | null = null - let fediseerLoading = false - let translating = false let localShare = false @@ -80,12 +78,6 @@ $: buttonSquare = view == 'compact' ? 'w-[30px] h-[30px]' : 'w-8 h-8' -{#if fediseerData} - {#await import('$lib/fediseer/Fediseer.svelte') then { default: Fediseer }} - - {/await} -{/if} - {#if editing}

Editing post

@@ -223,47 +215,39 @@ {$t('post.actions.more.creator')} - - - {post.creator.name} + + + + {post.creator.name} + - - - {post.community.title} + + + + {post.community.title} + - { - e.stopImmediatePropagation() - - fediseerLoading = true - const data = await fediseer.getInstanceInfo( - new URL(post.community.actor_id).hostname - ) - fediseerData = data - fediseerOpen = true - fediseerLoading = false - - return - }} - > + +
{$t('post.actions.more.actions')} {#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id} (editing = true)}> diff --git a/src/lib/components/ui/EntityHeader.svelte b/src/lib/components/ui/EntityHeader.svelte index 49112d89..7cd32a19 100644 --- a/src/lib/components/ui/EntityHeader.svelte +++ b/src/lib/components/ui/EntityHeader.svelte @@ -79,10 +79,11 @@ {/if} {#if bio} -
+
diff --git a/src/lib/components/ui/tabs/FilterTabs.svelte b/src/lib/components/ui/tabs/FilterTabs.svelte index ed0e0762..c75bff73 100644 --- a/src/lib/components/ui/tabs/FilterTabs.svelte +++ b/src/lib/components/ui/tabs/FilterTabs.svelte @@ -3,6 +3,7 @@ import { Icon, XMark } from 'svelte-hero-icons' import { expoOut } from 'svelte/easing' import { fly, slide } from 'svelte/transition' + import TextProps from '../text/TextProps.svelte' type T = $$Generic @@ -49,12 +50,14 @@ filters = filters }} color={filters.has(identifier) ? 'primary' : 'ghost'} - class="text-inherit dark:text-inherit text-xs px-2.5" + class="text-xs px-2.5" rounding="pill" size="sm" > - {identifier} + + {identifier} + {/each} diff --git a/src/lib/components/ui/text/TextProps.svelte b/src/lib/components/ui/text/TextProps.svelte new file mode 100644 index 00000000..b0751ba3 --- /dev/null +++ b/src/lib/components/ui/text/TextProps.svelte @@ -0,0 +1,16 @@ + + + + + + + diff --git a/src/lib/util.ts b/src/lib/util.ts index fce3daad..4561c3f0 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -191,3 +191,7 @@ export function canParseUrl(url: string): boolean { return false } } + +export function instanceId(actorId: string) { + return new URL(actorId).hostname +} diff --git a/src/routes/instances/[instance]/+page.svelte b/src/routes/instances/[instance]/+page.svelte new file mode 100644 index 00000000..e69de29b