feat: use new menu component
This commit is contained in:
1 parent
3b87091484
commit
2d1cd8c607
14 files changed
+89
-271
No files matched your search
@@ -1,9 +1,8 @@
|
||||
<script lang="ts">
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import type { Community, ListingType } from 'lemmy-js-client'
|
||||
import { Search } from 'mono-svelte'
|
||||
import { MenuButton, Search } from 'mono-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Icon, XCircle } from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
<script lang="ts">
|
||||
import type { CommentView } from 'lemmy-js-client'
|
||||
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
|
||||
import { page } from '$app/stores'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import {
|
||||
ArrowLeftCircle,
|
||||
ArrowUturnLeft,
|
||||
Bookmark,
|
||||
BookmarkSlash,
|
||||
ChatBubbleOvalLeft,
|
||||
EllipsisHorizontal,
|
||||
Flag,
|
||||
Icon,
|
||||
@@ -17,10 +12,6 @@
|
||||
Square2Stack,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import { getClient, getInstance } from '$lib/lemmy.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { isCommentMutable } from '$lib/components/lemmy/post/helpers.js'
|
||||
import {
|
||||
@@ -28,11 +19,10 @@
|
||||
isAdmin,
|
||||
report,
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import ModerationMenu from '$lib/components/lemmy/moderation/ModerationMenu.svelte'
|
||||
import CommentModerationMenu from '$lib/components/lemmy/moderation/CommentModerationMenu.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { deleteItem, save } from '$lib/lemmy/contentview.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
|
||||
export let comment: CommentView
|
||||
export let replying: boolean = false
|
||||
@@ -58,11 +48,9 @@
|
||||
{#if $profile?.user && (amMod($profile?.user, comment.community) || isAdmin($profile.user))}
|
||||
<CommentModerationMenu bind:item={comment} />
|
||||
{/if}
|
||||
<Menu class="top-0 leading-3" alignment="bottom-center">
|
||||
<Menu origin="bottom-center">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
slot="button"
|
||||
on:click={toggleOpen}
|
||||
slot="target"
|
||||
class="!p-1"
|
||||
aria-label="Comment actions"
|
||||
color="ghost"
|
||||
@@ -75,7 +63,7 @@
|
||||
slot="prefix"
|
||||
/>
|
||||
</Button>
|
||||
<span class="text-xs opacity-80 py-1 my-1 px-4">Comment actions</span>
|
||||
<MenuDivider>Actions</MenuDivider>
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
navigator.share?.({
|
||||
@@ -84,7 +72,7 @@
|
||||
}}
|
||||
>
|
||||
<Icon src={Square2Stack} mini size="16" />
|
||||
<span>Copy Link</span>
|
||||
<divv>Copy Link</divv>
|
||||
</MenuButton>
|
||||
{#if $profile?.jwt}
|
||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||
@@ -104,7 +92,7 @@
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.jwt && isCommentMutable(comment, $profile.user.local_user_view)}
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
color="danger-subtle"
|
||||
on:click={async () => {
|
||||
if ($profile?.jwt)
|
||||
comment.comment.deleted = await deleteItem(
|
||||
@@ -119,7 +107,7 @@
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile.jwt && $profile.user?.local_user_view.person.id != comment.creator.id}
|
||||
<MenuButton on:click={() => report(comment)} color="dangerSecondary">
|
||||
<MenuButton on:click={() => report(comment)} color="danger-subtle">
|
||||
<Icon src={Flag} mini size="16" />
|
||||
<span>Report</span>
|
||||
</MenuButton>
|
||||
|
||||
@@ -1,43 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import type {
|
||||
CommentView,
|
||||
Community,
|
||||
CommunityView,
|
||||
PostView,
|
||||
} from 'lemmy-js-client'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import { amMod, ban, isAdmin, remove } from './moderation'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { Fire, Icon, ShieldExclamation, Trash } from 'svelte-hero-icons'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import { isCommentView } from '$lib/lemmy/item.js'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { Button, Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
|
||||
export let item: PostView | CommentView
|
||||
</script>
|
||||
|
||||
<Menu alignment="bottom-center" class="top-0 h-[26px] w-[26px] ">
|
||||
<Menu origin="bottom-center" class="top-0 h-[26px] w-[26px] ">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
class="w-[26px] h-[26px] hover:!text-green-500 dark:text-zinc-400 text-slate-600"
|
||||
size="square-md"
|
||||
on:click={toggleOpen}
|
||||
slot="button"
|
||||
slot="target"
|
||||
color="ghost"
|
||||
{...$$restProps}
|
||||
>
|
||||
<ShieldIcon filled width={14} />
|
||||
</Button>
|
||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
||||
<li class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
<MenuDivider>
|
||||
Moderation {#if !item.community.local && !amMod($profile.user, item.community)}
|
||||
(Instance Only)
|
||||
{/if}
|
||||
</li>
|
||||
<MenuButton color="success" on:click={() => remove(item)}>
|
||||
</MenuDivider>
|
||||
<MenuButton color="success-subtle" on:click={() => remove(item)}>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{#if isCommentView(item)}
|
||||
{item.comment.removed ? 'Restore' : 'Remove'}
|
||||
@@ -46,13 +35,13 @@
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.user?.local_user_view.person.id != item.creator.id}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
<MenuDivider>
|
||||
User {#if !item.community.local && !amMod($profile.user, item.community)}
|
||||
(Instance Only)
|
||||
{/if}
|
||||
</span>
|
||||
</MenuDivider>
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
>
|
||||
@@ -65,11 +54,9 @@
|
||||
{/if}
|
||||
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<li class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
Admin
|
||||
</li>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item, true)}>
|
||||
<Icon src={Fire} size="16" mini slot="icon" />
|
||||
<MenuDivider>Admin</MenuDivider>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
||||
<Icon src={Fire} size="16" mini slot="prefix" />
|
||||
Purge
|
||||
</MenuButton>
|
||||
{/if}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
<script lang="ts">
|
||||
import { getClient } from '$lib/lemmy'
|
||||
import type { CommentView, Community, PostView } from 'lemmy-js-client'
|
||||
import type { CommentView, PostView } from 'lemmy-js-client'
|
||||
import { amMod, ban, isAdmin, remove } from './moderation'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import {
|
||||
Fire,
|
||||
Icon,
|
||||
InformationCircle,
|
||||
LockClosed,
|
||||
LockOpen,
|
||||
Megaphone,
|
||||
ShieldExclamation,
|
||||
Trash,
|
||||
} from 'svelte-hero-icons'
|
||||
import { Color } from '$lib/ui/colors.js'
|
||||
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { Button } from 'mono-svelte'
|
||||
|
||||
@@ -88,12 +84,10 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Menu alignment="bottom-right">
|
||||
<Menu origin="bottom-right">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
class="hover:text-green-500 dark:text-zinc-400 text-slate-500"
|
||||
on:click={toggleOpen}
|
||||
slot="button"
|
||||
slot="target"
|
||||
size="square-md"
|
||||
loading={acting}
|
||||
{...$$restProps}
|
||||
@@ -115,13 +109,13 @@
|
||||
</svg>
|
||||
</Button>
|
||||
{#if ($profile?.user && amMod($profile.user, item.community)) || ($profile?.user && isAdmin($profile.user))}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
<MenuDivider>
|
||||
Moderation {#if !item.community.local && !amMod($profile.user, item.community)}
|
||||
(Instance Only)
|
||||
{/if}
|
||||
</span>
|
||||
</MenuDivider>
|
||||
<MenuButton
|
||||
color="warning"
|
||||
color="warning-subtle"
|
||||
on:click={() => lock(!item.post.locked)}
|
||||
loading={locking}
|
||||
disabled={locking}
|
||||
@@ -130,13 +124,13 @@
|
||||
src={item.post.locked ? LockOpen : LockClosed}
|
||||
size="16"
|
||||
mini
|
||||
slot="icon"
|
||||
slot="prefix"
|
||||
/>
|
||||
{item.post.locked ? 'Unlock' : 'Lock'}
|
||||
</MenuButton>
|
||||
|
||||
<MenuButton
|
||||
color="success"
|
||||
color="success-subtle"
|
||||
on:click={() =>
|
||||
pin(isPostView(item) ? !item.post.featured_community : false)}
|
||||
loading={pinning}
|
||||
@@ -152,7 +146,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
</MenuButton>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item)}>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{#if isCommentView(item)}
|
||||
{item.comment.removed ? 'Restore' : 'Remove'}
|
||||
@@ -161,13 +155,13 @@
|
||||
{/if}
|
||||
</MenuButton>
|
||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
<MenuDivider>
|
||||
User {#if !item.community.local && !amMod($profile.user, item.community)}
|
||||
(Instance Only)
|
||||
{/if}
|
||||
</span>
|
||||
</MenuDivider>
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
>
|
||||
@@ -179,11 +173,9 @@
|
||||
{/if}
|
||||
{/if}
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<span class="px-4 py-1 my-1 text-xs text-slate-600 dark:text-zinc-400">
|
||||
Admin
|
||||
</span>
|
||||
<MenuDivider>Admin</MenuDivider>
|
||||
<MenuButton
|
||||
color="success"
|
||||
color="success-subtle"
|
||||
on:click={() =>
|
||||
pin(isPostView(item) ? !item.post.featured_local : false, true)}
|
||||
>
|
||||
@@ -195,7 +187,7 @@
|
||||
<span class="text-xs opacity-80">Instance</span>
|
||||
</div>
|
||||
</MenuButton>
|
||||
<MenuButton color="dangerSecondary" on:click={() => remove(item, true)}>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
||||
<Icon src={Fire} size="16" mini />
|
||||
Purge
|
||||
</MenuButton>
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
UserCircle,
|
||||
} from 'svelte-hero-icons'
|
||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import {
|
||||
amMod,
|
||||
@@ -34,7 +32,14 @@
|
||||
import { setSessionStorage } from '$lib/session.js'
|
||||
import { goto } from '$app/navigation'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { Button, Modal, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
Button,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuDivider,
|
||||
Modal,
|
||||
Spinner,
|
||||
} from 'mono-svelte'
|
||||
|
||||
export let post: PostView
|
||||
|
||||
@@ -109,21 +114,20 @@
|
||||
<ModerationMenu bind:item={post} community={post.community} />
|
||||
{/if}
|
||||
<Menu
|
||||
alignment="bottom-right"
|
||||
origin="bottom-right"
|
||||
containerClass="overflow-auto max-h-[400px]"
|
||||
itemsClass="!h-full"
|
||||
class="h-8"
|
||||
targetClass="h-full"
|
||||
>
|
||||
<Button
|
||||
let:toggleOpen
|
||||
slot="button"
|
||||
slot="target"
|
||||
aria-label="Post actions"
|
||||
on:click={toggleOpen}
|
||||
class="hover:text-inherit h-8"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} mini />
|
||||
</Button>
|
||||
<li class="mx-4 text-xs opacity-80 text-left my-1 py-1">Creator</li>
|
||||
<MenuDivider>Creator</MenuDivider>
|
||||
<MenuButton
|
||||
link
|
||||
href="/u/{post.creator.name}@{new URL(post.creator.actor_id).hostname}"
|
||||
@@ -140,7 +144,7 @@
|
||||
<span>{post.community.title}</span>
|
||||
</MenuButton>
|
||||
<hr class="w-[90%] mx-auto opacity-100 dark:opacity-10 my-2" />
|
||||
<li class="mx-4 text-xs opacity-80 text-left my-1 py-1">Actions</li>
|
||||
<MenuDivider>Actions</MenuDivider>
|
||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||
<MenuButton on:click={() => (editing = true)}>
|
||||
<Icon src={PencilSquare} width={16} mini />
|
||||
@@ -210,14 +214,14 @@
|
||||
$profile.jwt
|
||||
)
|
||||
}}
|
||||
color="dangerSecondary"
|
||||
color="danger-subtle"
|
||||
>
|
||||
<Icon src={Trash} width={16} mini />
|
||||
{post.post.deleted ? 'Restore' : 'Delete'}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile.user?.local_user_view.person.id != post.creator.id}
|
||||
<MenuButton on:click={() => report(post)} color="dangerSecondary">
|
||||
<MenuButton on:click={() => report(post)} color="danger-subtle">
|
||||
<Icon src={Flag} width={16} mini />
|
||||
Report
|
||||
</MenuButton>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import { placeholders } from '$lib/util.js'
|
||||
import { Checkbox, TextInput } from 'mono-svelte'
|
||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import ObjectAutocomplete from '$lib/components/lemmy/ObjectAutocomplete.svelte'
|
||||
import { Button } from 'mono-svelte'
|
||||
|
||||
|
||||
Reference in new issue
Block a user