feat: add TextProps component for reusable text modifications
This commit is contained in:
1 parent
21ae0f8272
commit
848992175b
6 files changed
+59
-51
No files matched your search
@@ -56,8 +56,10 @@
|
|||||||
import { hidePost, postLink } from './helpers'
|
import { hidePost, postLink } from './helpers'
|
||||||
import { feature } from '$lib/version'
|
import { feature } from '$lib/version'
|
||||||
import Switch from '$lib/components/input/Switch.svelte'
|
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 { 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 post: PostView
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
@@ -68,10 +70,6 @@
|
|||||||
let editing = false
|
let editing = false
|
||||||
let saving = false
|
let saving = false
|
||||||
|
|
||||||
let fediseerOpen = false
|
|
||||||
let fediseerData: Data | null = null
|
|
||||||
let fediseerLoading = false
|
|
||||||
|
|
||||||
let translating = false
|
let translating = false
|
||||||
|
|
||||||
let localShare = false
|
let localShare = false
|
||||||
@@ -80,12 +78,6 @@
|
|||||||
$: buttonSquare = view == 'compact' ? 'w-[30px] h-[30px]' : 'w-8 h-8'
|
$: buttonSquare = view == 'compact' ? 'w-[30px] h-[30px]' : 'w-8 h-8'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if fediseerData}
|
|
||||||
{#await import('$lib/fediseer/Fediseer.svelte') then { default: Fediseer }}
|
|
||||||
<Fediseer bind:open={fediseerOpen} data={fediseerData} />
|
|
||||||
{/await}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if editing}
|
{#if editing}
|
||||||
<Modal bind:open={editing}>
|
<Modal bind:open={editing}>
|
||||||
<h1 slot="title" class="text-2xl font-bold">Editing post</h1>
|
<h1 slot="title" class="text-2xl font-bold">Editing post</h1>
|
||||||
@@ -223,47 +215,39 @@
|
|||||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} micro />
|
<Icon slot="prefix" src={EllipsisHorizontal} width={16} micro />
|
||||||
</Button>
|
</Button>
|
||||||
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
||||||
<MenuButton
|
<MenuButton link href={userLink(post.creator)}>
|
||||||
link
|
<Icon
|
||||||
href="/u/{post.creator.name}@{new URL(post.creator.actor_id).hostname}"
|
src={UserCircle}
|
||||||
>
|
size="16"
|
||||||
<Icon src={UserCircle} size="16" micro slot="prefix" class="flex-shrink-0" />
|
micro
|
||||||
<span class="overflow-hidden overflow-ellipsis whitespace-nowrap">{post.creator.name}</span>
|
slot="prefix"
|
||||||
|
class="flex-shrink-0"
|
||||||
|
/>
|
||||||
|
<TextProps wrap="no-wrap">
|
||||||
|
{post.creator.name}
|
||||||
|
</TextProps>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton
|
<MenuButton link href={communityLink(post.community)}>
|
||||||
link
|
<Icon
|
||||||
href="/c/{post.community.name}@{new URL(post.community.actor_id)
|
src={Newspaper}
|
||||||
.hostname}"
|
size="16"
|
||||||
>
|
micro
|
||||||
<Icon src={Newspaper} size="16" micro slot="prefix" class="flex-shrink-0" />
|
slot="prefix"
|
||||||
<span class="overflow-hidden overflow-ellipsis whitespace-nowrap">{post.community.title}</span>
|
class="flex-shrink-0"
|
||||||
|
/>
|
||||||
|
<TextProps wrap="no-wrap">
|
||||||
|
{post.community.title}
|
||||||
|
</TextProps>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<MenuButton
|
<!-- <MenuButton href="/instances/{instanceId(post.community.actor_id)}">
|
||||||
loading={fediseerLoading}
|
|
||||||
on:click={async (e) => {
|
|
||||||
e.stopImmediatePropagation()
|
|
||||||
|
|
||||||
fediseerLoading = true
|
|
||||||
const data = await fediseer.getInstanceInfo(
|
|
||||||
new URL(post.community.actor_id).hostname
|
|
||||||
)
|
|
||||||
fediseerData = data
|
|
||||||
fediseerOpen = true
|
|
||||||
fediseerLoading = false
|
|
||||||
|
|
||||||
return
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<svelte:fragment slot="prefix">
|
<svelte:fragment slot="prefix">
|
||||||
{#if fediseerLoading}
|
|
||||||
<Spinner width={14} />
|
|
||||||
{:else}
|
|
||||||
<Icon src={ServerStack} size="16" micro class="flex-shrink-0" />
|
<Icon src={ServerStack} size="16" micro class="flex-shrink-0" />
|
||||||
{/if}
|
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<span class="overflow-hidden overflow-ellipsis whitespace-nowrap">{new URL(post.community.actor_id).hostname}</span>
|
<TextProps wrap="no-wrap">
|
||||||
</MenuButton>
|
{instanceId(post.community.actor_id)}
|
||||||
<hr class="w-[90%] mx-auto opacity-100 dark:opacity-10 my-2" />
|
</TextProps>
|
||||||
|
</MenuButton> -->
|
||||||
|
<hr class="border-slate-200 dark:border-zinc-800 mx-2 my-2" />
|
||||||
<MenuDivider>{$t('post.actions.more.actions')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.more.actions')}</MenuDivider>
|
||||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton on:click={() => (editing = true)}>
|
<MenuButton on:click={() => (editing = true)}>
|
||||||
|
|||||||
@@ -79,10 +79,11 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if bio}
|
{#if bio}
|
||||||
<div class="relative {center ? 'text-center' : 'text-left'}">
|
<div class="relative w-full {center ? 'text-center' : 'text-left'}">
|
||||||
<div
|
<div
|
||||||
class="p-4 relative bg-white/30 dark:bg-zinc-900/30 border border-slate-300 dark:border-zinc-800 border-opacity-50
|
class="p-4 relative bg-white/30 dark:bg-zinc-900/30 border border-slate-300
|
||||||
rounded-xl"
|
dark:border-zinc-800 border-opacity-50 rounded-xl
|
||||||
|
max-w-full w-full"
|
||||||
>
|
>
|
||||||
<PostBody class="text-sm" view="list" body={bio} clickThrough />
|
<PostBody class="text-sm" view="list" body={bio} clickThrough />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { Icon, XMark } from 'svelte-hero-icons'
|
import { Icon, XMark } from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
import TextProps from '../text/TextProps.svelte'
|
||||||
|
|
||||||
type T = $$Generic
|
type T = $$Generic
|
||||||
|
|
||||||
@@ -49,12 +50,14 @@
|
|||||||
filters = filters
|
filters = filters
|
||||||
}}
|
}}
|
||||||
color={filters.has(identifier) ? 'primary' : 'ghost'}
|
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"
|
rounding="pill"
|
||||||
size="sm"
|
size="sm"
|
||||||
>
|
>
|
||||||
<slot name="identifier" string={identifier}>
|
<slot name="identifier" string={identifier}>
|
||||||
|
<TextProps wrap="no-wrap">
|
||||||
{identifier}
|
{identifier}
|
||||||
|
</TextProps>
|
||||||
</slot>
|
</slot>
|
||||||
</Button>
|
</Button>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
const wrapClass = {
|
||||||
|
wrap: '',
|
||||||
|
'no-wrap': 'overflow-hidden overflow-ellipsis whitespace-nowrap',
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export let wrap: keyof typeof wrapClass = 'wrap'
|
||||||
|
|
||||||
|
$: classes = `${wrapClass[wrap]} ${$$props.class ?? ''}`
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<span class={classes}>
|
||||||
|
<slot />
|
||||||
|
</span>
|
||||||
@@ -191,3 +191,7 @@ export function canParseUrl(url: string): boolean {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function instanceId(actorId: string) {
|
||||||
|
return new URL(actorId).hostname
|
||||||
|
}
|
||||||
Whitespace-only changes.
Reference in new issue
Block a user