design: improve menus
This commit is contained in:
14 files changed
+177
-192
No files matched your search
@@ -11,7 +11,7 @@
|
||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
import { Button, Menu, MenuButton } from 'mono-svelte'
|
||||
import {
|
||||
Bookmark,
|
||||
BookmarkSlash,
|
||||
@@ -69,15 +69,14 @@
|
||||
title={$t('comment.actions.label')}
|
||||
color="tertiary"
|
||||
rounding="pill"
|
||||
size="square-sm"
|
||||
size="square-md"
|
||||
class="text-slate-600 dark:text-zinc-400"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} width={16} height={16} mini />
|
||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
||||
<MenuButton
|
||||
onclick={() => {
|
||||
if (navigator.share)
|
||||
|
||||
@@ -41,19 +41,14 @@
|
||||
<div bind:this={offsetEl}>
|
||||
{#if offsetEl}
|
||||
<VirtualList
|
||||
class="divide-y divide-slate-100 dark:divide-zinc-900 -mx-3 sm:-mx-6"
|
||||
class="divide-y-2 divide-slate-100 dark:divide-zinc-900 -mx-3 sm:-mx-6"
|
||||
overscan={5}
|
||||
estimatedHeight={500}
|
||||
items={nodes}
|
||||
{initialOffset}
|
||||
>
|
||||
{#snippet item(index)}
|
||||
<div
|
||||
class={[
|
||||
'px-3 sm:px-6',
|
||||
index % 2 == 1 && 'bg-slate-25 dark:bg-zinc-950',
|
||||
]}
|
||||
>
|
||||
<div class={['px-3 sm:px-6', index % 2 == 1 && '']}>
|
||||
<Comments
|
||||
bind:nodes={() => [nodes[index]], v => (nodes[index] = v[0])}
|
||||
{post}
|
||||
|
||||
@@ -1,28 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { deleteItem, markAsRead } from '$lib/lemmy/contentview'
|
||||
import { communityLink, userLink } from '$lib/lemmy/generic'
|
||||
import { setSessionStorage } from '$lib/session'
|
||||
import { settings } from '$lib/settings.svelte'
|
||||
import { instanceToURL } from '$lib/util.svelte'
|
||||
import type { PostView } from 'lemmy-js-client'
|
||||
import { Button, MenuButton, MenuDivider, toast } from 'mono-svelte'
|
||||
import { Button, Menu, MenuButton, toast } from 'mono-svelte'
|
||||
import {
|
||||
ArrowTopRightOnSquare,
|
||||
EllipsisHorizontal,
|
||||
Eye,
|
||||
EyeSlash,
|
||||
Flag,
|
||||
GlobeAmericas,
|
||||
GlobeAlt,
|
||||
Icon,
|
||||
MapPin,
|
||||
Newspaper,
|
||||
PencilSquare,
|
||||
Share,
|
||||
Trash,
|
||||
UserCircle,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons'
|
||||
import { report } from '../../moderation/moderation'
|
||||
@@ -34,14 +31,24 @@
|
||||
editing: boolean
|
||||
}
|
||||
|
||||
let localShare = $state(false)
|
||||
|
||||
let { post, onhide, editing = $bindable() }: Props = $props()
|
||||
|
||||
function share(global: boolean = true) {
|
||||
const link = global
|
||||
? post.post.ap_id
|
||||
: `${instanceToURL(profile.current.instance)}/post/${post.post.id}`
|
||||
|
||||
if (navigator.share)
|
||||
navigator.share?.({
|
||||
url: link,
|
||||
})
|
||||
else {
|
||||
navigator.clipboard.writeText(link)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<MenuDivider>
|
||||
{$t('post.actions.more.actions')}
|
||||
</MenuDivider>
|
||||
{#if profile.current?.user && profile.current?.jwt && profile.current.user.local_user_view.person.id == post.creator.id}
|
||||
<MenuButton onclick={() => (editing = true)}>
|
||||
{#snippet prefix()}
|
||||
@@ -65,52 +72,52 @@
|
||||
: $t('post.actions.more.markRead')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton
|
||||
onclick={() => {
|
||||
if (navigator.share)
|
||||
navigator.share?.({
|
||||
url: localShare
|
||||
? `${instanceToURL(profile.current.instance)}/post/${post.post.id}`
|
||||
: post.post.ap_id,
|
||||
})
|
||||
else
|
||||
navigator.clipboard.writeText(
|
||||
localShare
|
||||
? `${instanceToURL(profile.current.instance)}/post/${post.post.id}`
|
||||
: post.post.ap_id,
|
||||
)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
class="flex-1 py-0!"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Share} size="16" micro />
|
||||
{/snippet}
|
||||
{$t('post.actions.more.share')}
|
||||
<div class="flex-1"></div>
|
||||
{#if !post.post.local}
|
||||
<div class="flex gap-1">
|
||||
<Button
|
||||
color={!localShare ? 'primary' : 'secondary'}
|
||||
size="square-sm"
|
||||
rounding="pill"
|
||||
onclick={() => (localShare = false)}
|
||||
title={$t('filter.location.global')}
|
||||
>
|
||||
<Icon src={GlobeAmericas} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
color={localShare ? 'primary' : 'secondary'}
|
||||
size="square-sm"
|
||||
rounding="pill"
|
||||
onclick={() => (localShare = true)}
|
||||
title={$t('filter.location.local')}
|
||||
>
|
||||
<Icon src={MapPin} size="16" micro />
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</MenuButton>
|
||||
<div class="flex flex-row">
|
||||
<MenuButton
|
||||
onclick={() => share()}
|
||||
class={['flex-1', !post.post.local && 'rounded-r-xl']}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Share} size="16" micro />
|
||||
{/snippet}
|
||||
{$t('post.actions.more.share')}
|
||||
</MenuButton>
|
||||
<!--svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!--svelte-ignore a11y_click_events_have_key_events-->
|
||||
<div
|
||||
class="aspect-square w-max m-1 grid place-items-center text-slate-600 dark:text-zinc-400"
|
||||
onclick={e => e.stopPropagation()}
|
||||
>
|
||||
{#if !post.post.local}
|
||||
<Menu>
|
||||
{#snippet target()}
|
||||
<Button
|
||||
aria-label={$t('post.actions.more.label')}
|
||||
color="tertiary"
|
||||
size="custom"
|
||||
class="w-full h-full"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={EllipsisHorizontal} size="16" micro />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/snippet}
|
||||
<MenuButton onclick={() => share(true)}>
|
||||
{#snippet prefix()}
|
||||
<Icon src={GlobeAlt} size="16" micro />
|
||||
{/snippet}
|
||||
{$t('filter.location.global')}
|
||||
</MenuButton>
|
||||
<MenuButton onclick={() => share(false)}>
|
||||
{#snippet prefix()}
|
||||
<Icon src={MapPin} size="16" micro />
|
||||
{/snippet}
|
||||
{$t('filter.location.local')}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if profile.current?.jwt}
|
||||
<MenuButton
|
||||
onclick={() => {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { parseURL } from '$lib/components/input/Link.svelte'
|
||||
import type { View } from '$lib/settings.svelte'
|
||||
import { Button, Material } from 'mono-svelte'
|
||||
import { Material } from 'mono-svelte'
|
||||
import { optimizeImageURL } from '../helpers'
|
||||
import { Icon, Link } from 'svelte-hero-icons'
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
@@ -23,7 +24,7 @@
|
||||
let richURL = $derived(parseURL(url))
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<!--
|
||||
@component
|
||||
For embed-type posts. Displays embed card or a compact link.
|
||||
-->
|
||||
@@ -89,23 +90,20 @@
|
||||
</Material>
|
||||
</a>
|
||||
{:else}
|
||||
<Button
|
||||
<a
|
||||
href={url}
|
||||
target="_blank"
|
||||
class="text-slate-900 dark:text-zinc-300 items-center
|
||||
text-xs overflow-hidden max-w-full block shrink self-start w-max"
|
||||
size="xs"
|
||||
color="ghost"
|
||||
rounding="pill"
|
||||
class="flex flex-row text-slate-900 dark:text-zinc-400 items-center overflow-hidden group/link hover:underline space-x-1 my-1"
|
||||
>
|
||||
<Icon src={Link} size="16" micro class="shrink-0" />
|
||||
{#if richURL}
|
||||
<div
|
||||
class="flex max-w-full overflow-hidden font-medium self-start justify-self-start w-max"
|
||||
class="flex max-w-full overflow-hidden font-medium self-start justify-self-start w-max text-sm"
|
||||
>
|
||||
{richURL.hostname}
|
||||
{#if richURL.pathname != '/'}
|
||||
<span
|
||||
class="text-slate-500 dark:text-zinc-500 whitespace-nowrap font-normal"
|
||||
class="text-slate-500 dark:text-zinc-500 whitespace-nowrap font-normal group-hover/link:opacity-100 opacity-0 transition-opacity duration-100"
|
||||
>
|
||||
{richURL.pathname}
|
||||
</span>
|
||||
@@ -114,5 +112,5 @@
|
||||
{:else}
|
||||
{url}
|
||||
{/if}
|
||||
</Button>
|
||||
</a>
|
||||
{/if}
|
||||
@@ -58,8 +58,8 @@
|
||||
let {
|
||||
elevation = 'flat',
|
||||
padding = 'md',
|
||||
rounding = 'lg',
|
||||
color = 'default',
|
||||
rounding = 'xl',
|
||||
color = 'uniform',
|
||||
element = 'div',
|
||||
class: clazz = '',
|
||||
children,
|
||||
|
||||
@@ -49,12 +49,10 @@
|
||||
>
|
||||
{#snippet popover()}
|
||||
<div
|
||||
class="w-full max-w-[280px] origin-top-left
|
||||
max-h-128 overflow-auto list-none shadow-lg rounded-2xl"
|
||||
class="w-full max-w-sm origin-top-left max-h-128 overflow-auto list-none shadow-lg rounded-2xl"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col py-2 list-none bg-white/80 dark:bg-zinc-900/90 px-2 gap-px
|
||||
rounded-2xl
|
||||
class="flex flex-col px-0 list-none bg-white/80 dark:bg-zinc-900/90 gap-px rounded-2xl
|
||||
border border-slate-300 dark:border-zinc-800 border-opacity-50"
|
||||
>
|
||||
{@render children?.(open)}
|
||||
|
||||
@@ -37,9 +37,10 @@
|
||||
<Button
|
||||
{...rest}
|
||||
{color}
|
||||
size="custom"
|
||||
rounding="none"
|
||||
class={[
|
||||
'w-full px-2 rounded-lg min-h-8 font-normal duration-100',
|
||||
'w-full px-4 py-2 min-h-7 font-normal duration-100',
|
||||
disabled && 'opacity-70 pointer-events-none cursor-not-allowed',
|
||||
color == 'tertiary' && 'dark:hover:bg-zinc-800/70',
|
||||
clazz,
|
||||
@@ -53,7 +54,7 @@
|
||||
<div
|
||||
class={[
|
||||
'contents shrink-0',
|
||||
color == 'tertiary' && 'text-slate-600 dark:text-zinc-400',
|
||||
color == 'tertiary' && 'text-slate-500 dark:text-zinc-500',
|
||||
]}
|
||||
>
|
||||
{#if icon}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium py-2 px-2 flex items-center gap-1"
|
||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium m-4 mb-1 flex items-center gap-1"
|
||||
>
|
||||
<div>{@render children?.()}</div>
|
||||
<hr
|
||||
|
||||
@@ -134,7 +134,12 @@
|
||||
{#if open}
|
||||
<Portal class="z-150">
|
||||
<div
|
||||
transition:scale={{ duration: 300, start: 0.97, easing: expoOut }}
|
||||
transition:scale={{
|
||||
duration: 175,
|
||||
start: 0.95,
|
||||
opacity: 0,
|
||||
easing: expoOut,
|
||||
}}
|
||||
class="z-150 {popoverClass}"
|
||||
use:customFloatingContent
|
||||
use:focusTrap
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||
|
||||
let { children } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>Instances</Header>
|
||||
<div
|
||||
class="mt-4 mb-2 z-30 mx-auto max-w-full flex gap-2 md:flex-row flex-col
|
||||
items-center px-2 w-max top-6 lg:top-22"
|
||||
>
|
||||
<Tabs
|
||||
routes={[
|
||||
{
|
||||
href: '/instances/linked',
|
||||
name: 'Linked',
|
||||
},
|
||||
{ href: '/instances/blocked', name: 'Blocked' },
|
||||
]}
|
||||
></Tabs>
|
||||
</div>
|
||||
<div class="h-3 sm:h-6"></div>
|
||||
{@render children?.()}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
|
||||
export async function load({ fetch }) {
|
||||
return (await getClient(undefined, fetch).getFederatedInstances())
|
||||
.federated_instances
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
<script lang="ts">
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { Material, Popover } from 'mono-svelte'
|
||||
import { Check, Icon, InformationCircle } from 'svelte-hero-icons'
|
||||
|
||||
let { data } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>Linked Instances</Header>
|
||||
{#if data}
|
||||
<div class="flex flex-col md:flex-row gap-4">
|
||||
<div class="flex-1 w-full max-h-168 h-full flex flex-col gap-2">
|
||||
<h2 class="font-bold text-xl flex flex-row items-center gap-1">
|
||||
Linked
|
||||
<Popover openOnHover>
|
||||
{#snippet target()}
|
||||
<Icon src={InformationCircle} mini size="20" />
|
||||
{/snippet}
|
||||
<p class="font-normal">
|
||||
These are the instances your instance can see and interact with
|
||||
content from.
|
||||
</p>
|
||||
</Popover>
|
||||
</h2>
|
||||
<Material
|
||||
class="h-full overflow-auto divide-y *:py-3 divide-slate-200 dark:divide-zinc-800"
|
||||
color="distinct"
|
||||
>
|
||||
{#if data.linked && data.linked.length > 0}
|
||||
{#each data.linked?.sort((b, a) => b.id - a.id) as instance (instance.id)}
|
||||
<div class="flex justify-between items-center first:pt-0 last:pb-0">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{instance.domain}</span>
|
||||
<span
|
||||
class="text-xs text-slate-600 dark:text-zinc-400 capitalize"
|
||||
>
|
||||
{instance.software ?? 'Unknown'} • <RelativeDate
|
||||
date={publishedToDate(instance.published)}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No linked instances"
|
||||
description="This instance likely has federation disabled."
|
||||
/>
|
||||
{/if}
|
||||
</Material>
|
||||
</div>
|
||||
<div class="flex-1 w-full max-h-168 h-full flex flex-col gap-2">
|
||||
<h2 class="font-bold text-xl flex flex-row items-center gap-1">
|
||||
Blocked
|
||||
|
||||
<Popover openOnHover placement="bottom">
|
||||
{#snippet target()}
|
||||
<Icon src={InformationCircle} mini size="20" />
|
||||
{/snippet}
|
||||
<p class="font-normal">
|
||||
These are the instances your instance is explicitly blocking content
|
||||
from.
|
||||
</p>
|
||||
</Popover>
|
||||
</h2>
|
||||
<Material
|
||||
class="h-full overflow-auto divide-y *:py-3 divide-slate-200 dark:divide-zinc-800"
|
||||
color="distinct"
|
||||
>
|
||||
{#if data.blocked && data.blocked.length > 0}
|
||||
{#each data.blocked?.sort((b, a) => b.id - a.id) as instance (instance.id)}
|
||||
<div class="flex justify-between items-center first:pt-0 last:pb-0">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{instance.domain}</span>
|
||||
<span
|
||||
class="text-xs text-slate-600 dark:text-zinc-400 capitalize"
|
||||
>
|
||||
{instance.software ?? 'Unknown'} • <RelativeDate
|
||||
date={publishedToDate(instance.published)}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No blocked instances"
|
||||
description="Blocking an instance will hide submissions from that instance."
|
||||
/>
|
||||
{/if}
|
||||
</Material>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { getClient } from '$lib/lemmy.svelte.js'
|
||||
import { redirect } from '@sveltejs/kit'
|
||||
|
||||
export async function load({ fetch }) {
|
||||
return (await getClient(undefined, fetch).getFederatedInstances())
|
||||
.federated_instances
|
||||
export function load() {
|
||||
redirect(302, '/instances/linked')
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
import VirtualList from '$lib/components/render/VirtualList.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date.js'
|
||||
import { Material, Popover } from 'mono-svelte'
|
||||
import { Check, Icon, InformationCircle } from 'svelte-hero-icons'
|
||||
|
||||
let { data } = $props()
|
||||
</script>
|
||||
|
||||
{#if data}
|
||||
<div class="flex flex-col md:flex-row gap-4">
|
||||
<Material
|
||||
class="h-full overflow-auto divide-y *:py-3 divide-slate-200 dark:divide-zinc-800 max-h-[48rem] w-full"
|
||||
>
|
||||
{#if data.linked && data.linked.length > 0}
|
||||
<VirtualList
|
||||
useWindow={false}
|
||||
items={data.linked}
|
||||
height={473}
|
||||
estimatedHeight={100}
|
||||
>
|
||||
{#snippet item(index)}
|
||||
<div
|
||||
class="flex justify-between items-center first:pt-0 last:pb-0 my-3"
|
||||
>
|
||||
<div class="flex flex-col">
|
||||
<span class="font-medium">{data.linked[index].domain}</span>
|
||||
<span
|
||||
class="text-xs text-slate-600 dark:text-zinc-400 capitalize"
|
||||
>
|
||||
{data.linked[index].software ?? 'Unknown'} • <RelativeDate
|
||||
date={publishedToDate(data.linked[index].published)}
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
</VirtualList>
|
||||
{:else}
|
||||
<Placeholder
|
||||
icon={Check}
|
||||
title="No linked instances"
|
||||
description="This instance likely has federation disabled."
|
||||
/>
|
||||
{/if}
|
||||
</Material>
|
||||
</div>
|
||||
{/if}
|
||||
Reference in new issue
Block a user