design: improve menus

This commit is contained in:
James Xylight committed 2025-08-21 17:04:25 -07:00
1 parent bfe93cf762
commit 930bb93282
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}
+2 -2
View File
@@ -58,8 +58,8 @@
let {
elevation = 'flat',
padding = 'md',
rounding = 'lg',
color = 'default',
rounding = 'xl',
color = 'uniform',
element = 'div',
class: clazz = '',
children,
+2 -4
View File
@@ -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)}
+3 -2
View File
@@ -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}
+1 -1
View File
@@ -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
+6 -1
View File
@@ -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