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
-1
@@ -42,7 +42,7 @@
|
||||
"@dicebear/initials": "^6.0.4",
|
||||
"lemmy-js-client": "^0.18.0-rc.2",
|
||||
"markdown-it": "^13.0.1",
|
||||
"mono-svelte": "^0.2.8"
|
||||
"mono-svelte": "^0.2.15"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -8,14 +8,18 @@
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import Logo from '$lib/components/ui/Logo.svelte'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { LINKED_INSTANCE_URL, instance } from '$lib/instance.js'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { theme } from '$lib/ui/colors.js'
|
||||
import { Button, Select, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
ArrowLeftOnRectangle,
|
||||
Button,
|
||||
Menu,
|
||||
MenuButton,
|
||||
MenuDivider,
|
||||
Select,
|
||||
Spinner,
|
||||
} from 'mono-svelte'
|
||||
import {
|
||||
Bars3,
|
||||
Bookmark,
|
||||
Cog6Tooth,
|
||||
@@ -135,19 +139,17 @@
|
||||
<Icon mini src={GlobeAlt} size="16" slot="prefix" />
|
||||
<span class="hidden md:inline">Explore</span>
|
||||
</Button>
|
||||
<Menu alignment="bottom-right">
|
||||
<Menu origin="bottom-right">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
color="primary"
|
||||
slot="button"
|
||||
slot="target"
|
||||
aria-label="Create"
|
||||
on:click={toggleOpen}
|
||||
class="max-md:w-9 max-md:h-8 max-md:!p-0"
|
||||
>
|
||||
<Icon src={Plus} width={18} mini slot="prefix" />
|
||||
<span class="hidden md:inline">Create</span>
|
||||
</Button>
|
||||
<li class="text-xs opacity-80 text-left mx-4 my-1 py-1">Create</li>
|
||||
<MenuDivider>Create</MenuDivider>
|
||||
<MenuButton
|
||||
link
|
||||
href="/create/post"
|
||||
@@ -175,17 +177,16 @@
|
||||
</Menu>
|
||||
</div>
|
||||
<Menu
|
||||
alignment="bottom-right"
|
||||
itemsClass="h-8 md:h-8"
|
||||
containerClass="!max-h-[28rem]"
|
||||
origin="bottom-right"
|
||||
itemsClass="h-8 md:h-8 z-10"
|
||||
targetClass="z-10"
|
||||
containerClass="!max-h-[28rem] z-10"
|
||||
>
|
||||
<button
|
||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
||||
dark:bg-zinc-800 relative"
|
||||
aria-label="Profile"
|
||||
slot="button"
|
||||
let:toggleOpen
|
||||
on:click={toggleOpen}
|
||||
slot="target"
|
||||
>
|
||||
{#if $profile?.user}
|
||||
<div class="w-8 h-8 aspect-square object-cover rounded-full">
|
||||
@@ -206,9 +207,9 @@
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
<li class="text-xs opacity-80 text-left mx-4 my-1 py-1">
|
||||
<MenuDivider>
|
||||
{$profile?.user ? $profile.user.local_user_view.person.name : 'Profile'}
|
||||
</li>
|
||||
</MenuDivider>
|
||||
{#if $profile?.user}
|
||||
<MenuButton link href="/profile">
|
||||
<Icon src={UserCircle} mini width={16} /> Profile
|
||||
@@ -238,7 +239,7 @@
|
||||
</span>
|
||||
</MenuButton>
|
||||
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
|
||||
<li class="text-xs px-4 py-1 my-1 opacity-80">App</li>
|
||||
<MenuDivider>App</MenuDivider>
|
||||
<MenuButton link href="/settings">
|
||||
<Icon src={Cog6Tooth} mini width={16} />
|
||||
Settings
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { Alignment } from '$lib/components/ui/menu/menu.js'
|
||||
import { backOut, bounceOut, circOut, expoOut, sineOut } from 'svelte/easing'
|
||||
import { scale } from 'svelte/transition'
|
||||
|
||||
export let open = false
|
||||
|
||||
let clazz = ''
|
||||
export { clazz as class }
|
||||
|
||||
export let itemsClass = ''
|
||||
|
||||
export let absolute = false
|
||||
|
||||
export let alignment: Alignment = 'bottom-left'
|
||||
|
||||
let element: any
|
||||
|
||||
export const toggleOpen = () => (open = !open)
|
||||
|
||||
function getOriginClass(origin: Alignment) {
|
||||
switch (origin) {
|
||||
case 'top-right':
|
||||
return 'bottom-[100%] right-0 origin-bottom-right'
|
||||
case 'bottom-left':
|
||||
return 'top-[100%] origin-top-left'
|
||||
case 'top-left':
|
||||
return 'bottom-[100%] left-0 origin-bottom-left'
|
||||
case 'bottom-right':
|
||||
return 'top-[100%] right-0 origin-top-right'
|
||||
case 'top-center':
|
||||
return 'bottom-[100%] -left-[450%] origin-bottom'
|
||||
case 'bottom-center':
|
||||
return 'top-[100%] -left-[450%] origin-top'
|
||||
default:
|
||||
return 'bottom-[100%] origin-top-left'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:body
|
||||
on:click={(e) => {
|
||||
if (!element.contains(e.target)) {
|
||||
open = false
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="overflow-visible {absolute
|
||||
? 'absolute'
|
||||
: 'relative'} cursor-auto h-max {clazz} {itemsClass}"
|
||||
bind:this={element}
|
||||
tabindex="-1"
|
||||
>
|
||||
<slot name="button" {toggleOpen} />
|
||||
{#if open}
|
||||
<menu
|
||||
transition:scale|local={{
|
||||
duration: 200,
|
||||
start: 0.95,
|
||||
easing: expoOut,
|
||||
}}
|
||||
class="list-none absolute max-h-96 z-30 overflow-auto {getOriginClass(
|
||||
alignment
|
||||
)}
|
||||
rounded-lg py-2 min-w-[16rem] my-2 flex flex-col shadow-sm
|
||||
bg-white dark:bg-zinc-900 backdrop-blur-2xl border border-slate-200 dark:border-zinc-800
|
||||
{$$props.containerClass}"
|
||||
>
|
||||
{#if open}
|
||||
<div on:click={toggleOpen} class="flex flex-col gap-0 h-max">
|
||||
<slot {toggleOpen} />
|
||||
</div>
|
||||
{/if}
|
||||
</menu>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -1,55 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Color } from '$lib/ui/colors'
|
||||
import { Spinner } from 'mono-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
type ButtonColor = keyof typeof buttonColors
|
||||
|
||||
const buttonColors = {
|
||||
secondary:
|
||||
'hover:bg-gray-200/50 hover:dark:bg-zinc-600/20 text-slate-800 fill-slate-800 dark:text-zinc-200 dark:fill-zinc-200',
|
||||
dangerSecondary: 'hover:bg-red-500 text-red-500 hover:text-white',
|
||||
success:
|
||||
'hover:bg-green-600 text-green-600 dark:text-green-500 hover:text-white hover:dark:text-white',
|
||||
warning:
|
||||
'hover:bg-yellow-500 dark:text-yellow-300 text-yellow-600 hover:dark:text-black hover:text-black',
|
||||
}
|
||||
|
||||
export let color: ButtonColor = 'secondary'
|
||||
export let link = false
|
||||
export let href = ''
|
||||
export let loading = false
|
||||
export let disabled = false
|
||||
|
||||
const click = createEventDispatcher()
|
||||
</script>
|
||||
|
||||
<li>
|
||||
{#if link}
|
||||
<a
|
||||
{href}
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm transition-colors {buttonColors[
|
||||
color
|
||||
]} {disabled ? 'opacity-50 pointer-events-none' : ''}"
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
on:click={(e) => click('click', e)}
|
||||
type="button"
|
||||
class="flex flex-row gap-2 items-center px-4 py-2 w-full text-sm
|
||||
transition-colors list-none {buttonColors[
|
||||
color
|
||||
]} disabled:opacity-50 disabled:pointer-events-none"
|
||||
{disabled}
|
||||
>
|
||||
{#if loading}
|
||||
<Spinner width={16} />
|
||||
{:else}
|
||||
<slot name="icon" />
|
||||
{/if}
|
||||
<slot />
|
||||
</button>
|
||||
{/if}
|
||||
</li>
|
||||
@@ -1,7 +0,0 @@
|
||||
export type Alignment =
|
||||
| 'top-right'
|
||||
| 'top-left'
|
||||
| 'bottom-right'
|
||||
| 'bottom-left'
|
||||
| 'bottom-center'
|
||||
| 'top-center'
|
||||
@@ -9,9 +9,7 @@
|
||||
profile,
|
||||
} from '$lib/auth.js'
|
||||
import EditableList from '$lib/components/ui/list/EditableList.svelte'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Menu, MenuButton, toast } from 'mono-svelte'
|
||||
import DebugObject from '$lib/components/util/debug/DebugObject.svelte'
|
||||
import {
|
||||
DEFAULT_INSTANCE_URL,
|
||||
@@ -172,28 +170,26 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="ml-auto" />
|
||||
<Menu alignment="bottom-right">
|
||||
<Menu origin="bottom-right">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
on:click={toggleOpen}
|
||||
size="square-md"
|
||||
slot="button"
|
||||
slot="target"
|
||||
>
|
||||
<Icon src={EllipsisHorizontal} mini size="16" slot="prefix" />
|
||||
</Button>
|
||||
<MenuButton on:click={() => moveProfile(profile.id, true)}>
|
||||
<Icon src={ChevronUp} size="16" mini slot="icon" />
|
||||
<Icon src={ChevronUp} size="16" mini slot="prefix" />
|
||||
Move Up
|
||||
</MenuButton>
|
||||
<MenuButton on:click={() => moveProfile(profile.id, false)}>
|
||||
<Icon src={ChevronDown} size="16" mini slot="icon" />
|
||||
<Icon src={ChevronDown} size="16" mini slot="prefix" />
|
||||
Move Down
|
||||
</MenuButton>
|
||||
<MenuButton
|
||||
disabled={!profile.color}
|
||||
on:click={() => (profile.color = undefined)}
|
||||
>
|
||||
<Icon src={ArrowUturnLeft} size="16" mini slot="icon" />
|
||||
<Icon src={ArrowUturnLeft} size="16" mini slot="prefix" />
|
||||
Reset Color
|
||||
</MenuButton>
|
||||
{#if $userSettings.debugInfo}
|
||||
@@ -203,7 +199,7 @@
|
||||
debugging = !debugging
|
||||
}}
|
||||
>
|
||||
<Icon src={BugAnt} size="16" mini slot="icon" />
|
||||
<Icon src={BugAnt} size="16" mini slot="prefix" />
|
||||
Debug Info
|
||||
</MenuButton>
|
||||
{/if}
|
||||
|
||||
@@ -24,13 +24,11 @@
|
||||
import { isCommentView } from '$lib/lemmy/item.js'
|
||||
import { getClient } from '$lib/lemmy.js'
|
||||
import { isBlocked } from '$lib/lemmy/user.js'
|
||||
import { toast } from 'mono-svelte'
|
||||
import { Menu, MenuButton, toast } from 'mono-svelte'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { ban, isAdmin } from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import Menu from '$lib/components/ui/menu/Menu.svelte'
|
||||
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
|
||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { Button, Modal, Select } from 'mono-svelte'
|
||||
@@ -255,21 +253,16 @@
|
||||
</Button>
|
||||
</div>
|
||||
{#if isAdmin($profile?.user)}
|
||||
<Menu class="ml-auto" alignment="bottom-right">
|
||||
<Button
|
||||
let:toggleOpen
|
||||
size="square-md"
|
||||
on:click={toggleOpen}
|
||||
slot="button"
|
||||
>
|
||||
<Menu class="ml-auto" origin="bottom-right">
|
||||
<Button size="square-md" slot="target">
|
||||
<ShieldIcon width={16} filled />
|
||||
</Button>
|
||||
<MenuButton
|
||||
color="dangerSecondary"
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
ban(data.person_view.person.banned, data.person_view.person)}
|
||||
>
|
||||
<Icon slot="icon" mini size="16" src={ShieldExclamation} />
|
||||
<Icon slot="prefix" mini size="16" src={ShieldExclamation} />
|
||||
{data.person_view.person.banned ? 'Unban' : 'Ban'}
|
||||
</MenuButton>
|
||||
</Menu>
|
||||
|
||||
@@ -2977,10 +2977,10 @@ mlly@^1.2.0, mlly@^1.4.0:
|
||||
pkg-types "^1.0.3"
|
||||
ufo "^1.1.2"
|
||||
|
||||
mono-svelte@^0.2.8:
|
||||
version "0.2.8"
|
||||
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.8.tgz#30f6e83089a1f2517dfede8bba2cf36a6f26161c"
|
||||
integrity sha512-M9KveQgHjBIp0xBPYJTPiDlNAFPIOeEQcq0H7ZokKfiyeDS+ZYCvNyyWC15ziJYWOtErKQd2e0cG7OVdE1ppPA==
|
||||
mono-svelte@^0.2.15:
|
||||
version "0.2.15"
|
||||
resolved "https://registry.yarnpkg.com/mono-svelte/-/mono-svelte-0.2.15.tgz#efc8be5f484499ca93e16f8853a24a3114dff712"
|
||||
integrity sha512-ImItUKzapM9NOKnOgEZqg0x7ykUIuTdM8NAoG8rSnZejrFQVXsjdA6K1TRcj3MQlSx1scr4VbEnByQBDbpVYWw==
|
||||
|
||||
mri@^1.1.0:
|
||||
version "1.2.0"
|
||||
|
||||
Reference in new issue
Block a user