design: re-do menus, dynamic origin animations
This commit is contained in:
14 files changed
+91
-74
No files matched your search
@@ -40,8 +40,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="flex flex-row items-center gap-0.5 h-7 w-full"
|
class={[
|
||||||
class:flex-row-reverse={settings.posts.reverseActions}
|
'flex flex-row items-center gap-0.5 h-7 w-full',
|
||||||
|
settings.posts.reverseActions && 'flex-row-reverse',
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<CommentVote
|
<CommentVote
|
||||||
upvotes={comment.counts.upvotes}
|
upvotes={comment.counts.upvotes}
|
||||||
@@ -50,15 +52,15 @@
|
|||||||
commentId={comment.comment.id}
|
commentId={comment.comment.id}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
class="text-slate-600 dark:text-zinc-400"
|
size="sm"
|
||||||
|
class="text-slate-500 dark:text-zinc-400"
|
||||||
onclick={() => (replying = !replying)}
|
onclick={() => (replying = !replying)}
|
||||||
disabled={comment.post.locked || disabled}
|
disabled={comment.post.locked || disabled}
|
||||||
>
|
>
|
||||||
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
<Icon src={ChatBubbleOvalLeft} size="15" micro />
|
||||||
<span class="text-xs">{$t('comment.reply')}</span>
|
{$t('comment.reply')}
|
||||||
</Button>
|
</Button>
|
||||||
{#if profile.current?.user && (amMod(profile.current?.user, comment.community) || isAdmin(profile.current.user))}
|
{#if profile.current?.user && (amMod(profile.current?.user, comment.community) || isAdmin(profile.current.user))}
|
||||||
<CommentModerationMenu bind:item={comment} />
|
<CommentModerationMenu bind:item={comment} />
|
||||||
|
|||||||
@@ -190,7 +190,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<VirtualList
|
<VirtualList
|
||||||
id="feed"
|
id="feed"
|
||||||
class="divide-y -mx-3 sm:-mx-6 divide-slate-200 dark:divide-zinc-900"
|
class="divide-y-2 -mx-3 sm:-mx-6 divide-slate-200 dark:divide-zinc-900"
|
||||||
items={posts}
|
items={posts}
|
||||||
{initialOffset}
|
{initialOffset}
|
||||||
overscan={3}
|
overscan={3}
|
||||||
|
|||||||
@@ -197,7 +197,7 @@
|
|||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu>
|
<Menu placement="bottom">
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<button
|
<button
|
||||||
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
class="w-10 h-10 rounded-full border-slate-200 dark:border-zinc-700
|
||||||
@@ -224,7 +224,11 @@
|
|||||||
{/snippet}
|
{/snippet}
|
||||||
{#snippet children(open)}
|
{#snippet children(open)}
|
||||||
{#if open}
|
{#if open}
|
||||||
{#await import('./Profile.svelte') then { default: Profile }}
|
{#await import('./Profile.svelte')}
|
||||||
|
<div class="m-8 w-full h-full grid place-items-center">
|
||||||
|
<Spinner width={20} />
|
||||||
|
</div>
|
||||||
|
{:then { default: Profile }}
|
||||||
<Profile />
|
<Profile />
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
export type Shadow = keyof typeof shadowClass
|
export type Shadow = keyof typeof shadowClass
|
||||||
|
|
||||||
export const sizeClass = {
|
export const sizeClass = {
|
||||||
sm: 'px-3 py-1.5',
|
sm: 'px-3 py-1',
|
||||||
md: 'px-4 py-2',
|
md: 'px-3.5 py-1.5',
|
||||||
lg: 'px-5 py-3',
|
lg: 'px-5 py-3',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
import Label from '../forms/Label.svelte'
|
import Label from '../forms/Label.svelte'
|
||||||
import { generateID } from '../forms/helper.js'
|
import { generateID } from '../forms/helper.js'
|
||||||
|
|
||||||
const borderClass = `border border-slate-200 border-b-slate-300 dark:border-t-zinc-800 dark:border-zinc-900`
|
const borderClass = `border border-slate-200 border-b-slate-300 dark:border-zinc-800`
|
||||||
|
|
||||||
let {
|
let {
|
||||||
label = undefined,
|
label = undefined,
|
||||||
@@ -86,10 +86,11 @@
|
|||||||
>
|
>
|
||||||
{#if prefix}
|
{#if prefix}
|
||||||
<div
|
<div
|
||||||
class="rounded-xl rounded-r-none
|
class={[
|
||||||
text-slate-600 dark:text-zinc-400 {inlineAffixes
|
'rounded-xl rounded-r-none text-slate-600 dark:text-zinc-400',
|
||||||
? 'bg-white dark:bg-zinc-950 pr-0 w-8'
|
inlineAffixes && 'bg-white dark:bg-zinc-900 pr-0 w-8',
|
||||||
: ''} {sizeClass[size]}"
|
sizeClass[size],
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{@render prefix?.()}
|
{@render prefix?.()}
|
||||||
</div>
|
</div>
|
||||||
@@ -104,9 +105,9 @@
|
|||||||
{...rest}
|
{...rest}
|
||||||
class={[
|
class={[
|
||||||
sizeClass[size],
|
sizeClass[size],
|
||||||
`bg-white dark:bg-zinc-950
|
`bg-white dark:bg-zinc-900
|
||||||
focus:outline-hidden rounded-xl text-sm w-full disabled:bg-slate-100
|
focus:outline-hidden rounded-xl text-sm w-full disabled:bg-slate-100
|
||||||
disabled:cursor-not-allowed dark:disabled:bg-zinc-950 invalid:border-red-500!
|
disabled:cursor-not-allowed dark:disabled:bg-zinc-800 invalid:border-red-500!
|
||||||
peer invalid:text-red-500 z-10`,
|
peer invalid:text-red-500 z-10`,
|
||||||
prefix && 'rounded-l-none',
|
prefix && 'rounded-l-none',
|
||||||
prefix && inlineAffixes && 'border-l-0',
|
prefix && inlineAffixes && 'border-l-0',
|
||||||
@@ -119,7 +120,7 @@
|
|||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
'rounded-xl rounded-l-none text-slate-600 dark:text-zinc-400',
|
'rounded-xl rounded-l-none text-slate-600 dark:text-zinc-400',
|
||||||
inlineAffixes && 'bg-white dark:bg-zinc-950 pl-0',
|
inlineAffixes && 'bg-white dark:bg-zinc-900 pl-0',
|
||||||
sizeClass[size],
|
sizeClass[size],
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
>
|
>
|
||||||
oncontextmenu?: HTMLSelectAttributes['oncontextmenu']
|
oncontextmenu?: HTMLSelectAttributes['oncontextmenu']
|
||||||
onchange?: HTMLSelectAttributes['onchange']
|
onchange?: HTMLSelectAttributes['onchange']
|
||||||
|
placement?: Placement
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { Props as SelectProps }
|
export type { Props as SelectProps }
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
import MenuButton from '../../popover/MenuButton.svelte'
|
import MenuButton from '../../popover/MenuButton.svelte'
|
||||||
import Label from '../Label.svelte'
|
import Label from '../Label.svelte'
|
||||||
import { generateID } from '../helper.js'
|
import { generateID } from '../helper.js'
|
||||||
|
import type { Placement } from 'svelte-floating-ui/core'
|
||||||
|
|
||||||
let open = $state(false)
|
let open = $state(false)
|
||||||
let element: HTMLSelectElement | undefined = $state()
|
let element: HTMLSelectElement | undefined = $state()
|
||||||
@@ -84,6 +86,7 @@
|
|||||||
customOption,
|
customOption,
|
||||||
oncontextmenu,
|
oncontextmenu,
|
||||||
onchange,
|
onchange,
|
||||||
|
placement = 'bottom',
|
||||||
...rest
|
...rest
|
||||||
}: Props<T> = $props()
|
}: Props<T> = $props()
|
||||||
</script>
|
</script>
|
||||||
@@ -96,7 +99,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<div class="w-full relative">
|
<div class="w-full relative">
|
||||||
<Menu bind:open>
|
<Menu bind:open {placement}>
|
||||||
{#snippet target()}
|
{#snippet target()}
|
||||||
<select
|
<select
|
||||||
{...rest}
|
{...rest}
|
||||||
|
|||||||
@@ -43,17 +43,17 @@
|
|||||||
{manual}
|
{manual}
|
||||||
{...rest}
|
{...rest}
|
||||||
bind:open
|
bind:open
|
||||||
popoverClass="backdrop-blur-xl rounded-2xl w-full max-w-[280px]"
|
popoverClass="rounded-xl w-full backdrop-blur-md max-w-72"
|
||||||
class={clazz}
|
class={clazz}
|
||||||
{target}
|
{target}
|
||||||
>
|
>
|
||||||
{#snippet popover()}
|
{#snippet popover()}
|
||||||
<div
|
<div
|
||||||
class="w-full max-w-sm 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-xl"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col px-0 list-none bg-white/80 dark:bg-zinc-900/90 rounded-2xl
|
class="flex flex-col p-1 list-none bg-white/80 dark:bg-zinc-900/90 rounded-xl
|
||||||
border border-slate-300 dark:border-zinc-800 border-opacity-50 py-1"
|
border border-slate-300 dark:border-zinc-800 border-opacity-50 gap-px"
|
||||||
>
|
>
|
||||||
{@render children?.(open)}
|
{@render children?.(open)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
size="custom"
|
size="custom"
|
||||||
rounding="none"
|
rounding="none"
|
||||||
class={[
|
class={[
|
||||||
'w-full px-4.5 py-1.5 min-h-7 duration-100 font-normal',
|
'w-full px-3 py-1.5 min-h-7 duration-75 hover:cursor-default font-normal rounded-lg',
|
||||||
disabled && 'opacity-70 pointer-events-none cursor-not-allowed',
|
disabled && 'opacity-70 pointer-events-none cursor-not-allowed',
|
||||||
color == 'tertiary' && 'dark:hover:bg-zinc-800/70',
|
color == 'tertiary' && 'dark:hover:bg-zinc-800/70',
|
||||||
clazz,
|
clazz,
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
<script>
|
<script lang="ts">
|
||||||
/**
|
|
||||||
* @typedef {Object} Props
|
|
||||||
* @property {import('svelte').Snippet} [children]
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {Props} */
|
|
||||||
let { children } = $props()
|
let { children } = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="text-slate-800 dark:text-zinc-200 text-xs font-medium m-4 mb-1 flex items-center gap-1"
|
class="text-slate-800 dark:text-zinc-200 text-xs font-medium m-3 my-2 mb-1 flex items-center gap-1"
|
||||||
>
|
>
|
||||||
<div>{@render children?.()}</div>
|
<div class="sr-only">{@render children?.()}</div>
|
||||||
<hr
|
<hr
|
||||||
class="shrink flex-1 border-slate-200 dark:border-zinc-800 border-opacity-70"
|
class="shrink flex-1 border-slate-100 dark:border-zinc-800 border-opacity-70 -mx-4"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,16 +1,3 @@
|
|||||||
<script module lang="ts">
|
|
||||||
export type Origin = keyof typeof popoverOrigins
|
|
||||||
|
|
||||||
export const popoverOrigins = {
|
|
||||||
'top-right': 'bottom-full right-0 origin-bottom-right',
|
|
||||||
'bottom-left': 'top-full origin-top-left',
|
|
||||||
'top-left': 'bottom-full left-0 origin-bottom-left',
|
|
||||||
'bottom-right': 'top-full right-0 origin-top-right',
|
|
||||||
'top-center': 'bottom-full -left-[450%] origin-bottom',
|
|
||||||
'bottom-center': 'top-full -left-[450%] origin-top',
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
flip,
|
flip,
|
||||||
@@ -62,11 +49,45 @@
|
|||||||
let el = $state<HTMLElement>()
|
let el = $state<HTMLElement>()
|
||||||
let popoverEl = $state<HTMLElement>()
|
let popoverEl = $state<HTMLElement>()
|
||||||
|
|
||||||
|
let origins: Record<Placement, string> = {
|
||||||
|
bottom: 'top',
|
||||||
|
'bottom-end': 'top right',
|
||||||
|
'bottom-start': 'top left',
|
||||||
|
left: 'left',
|
||||||
|
'left-end': 'left',
|
||||||
|
'left-start': 'left',
|
||||||
|
right: 'right',
|
||||||
|
'right-end': 'right',
|
||||||
|
'right-start': 'right',
|
||||||
|
top: 'bottom',
|
||||||
|
'top-end': 'bottom right',
|
||||||
|
'top-start': 'bottom',
|
||||||
|
}
|
||||||
|
|
||||||
const [floatingRef, floatingContent] = createFloatingActions({
|
const [floatingRef, floatingContent] = createFloatingActions({
|
||||||
strategy: strategy,
|
strategy: strategy,
|
||||||
placement: placement,
|
placement: placement,
|
||||||
middleware: middleware,
|
middleware: middleware,
|
||||||
|
onComputed: ({ x, y, placement }) => {
|
||||||
|
if (popoverEl) {
|
||||||
|
popoverEl.style.transformOrigin = origins[placement]
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(placement)
|
||||||
|
|
||||||
|
// @ts-expect-error svelte hell
|
||||||
|
Object.assign(el?.children?.item?.(0) ?? el, {
|
||||||
|
top: '0',
|
||||||
|
left: '0',
|
||||||
|
transform: `translate3d(${roundByDPR(x)}px,${roundByDPR(y)}px,0)`,
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function roundByDPR(value: number) {
|
||||||
|
const dpr = window.devicePixelRatio || 1
|
||||||
|
return Math.round(value * dpr) / dpr
|
||||||
|
}
|
||||||
|
|
||||||
const customFloatingContent = (node: HTMLDivElement) => {
|
const customFloatingContent = (node: HTMLDivElement) => {
|
||||||
// if (!canUseContents) return
|
// if (!canUseContents) return
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
<div
|
<div
|
||||||
class={[
|
class={[
|
||||||
toastColors[toast.type],
|
toastColors[toast.type],
|
||||||
'relative rounded-2xl overflow-hidden flex flex-row items-center gap-2 px-3 py-3 backdrop-blur-lg',
|
'relative rounded-xl overflow-hidden flex flex-row items-center gap-2 px-3 py-3',
|
||||||
|
'bg-white dark:bg-zinc-900 shadow-lg',
|
||||||
toast.long ? 'w-full max-w-lg' : 'w-80',
|
toast.long ? 'w-full max-w-lg' : 'w-80',
|
||||||
]}
|
]}
|
||||||
transition:fly={{
|
transition:fly={{
|
||||||
@@ -42,16 +43,7 @@
|
|||||||
<Icon
|
<Icon
|
||||||
size="28"
|
size="28"
|
||||||
mini
|
mini
|
||||||
class={[
|
class={['relative self-center shrink-0 p-1 rounded-lg']}
|
||||||
'relative self-center shrink-0 p-1 rounded-lg',
|
|
||||||
toast.type == 'info'
|
|
||||||
? 'bg-slate-200 dark:bg-zinc-50 text-slate-700 dark:text-zinc-700'
|
|
||||||
: toast.type == 'success'
|
|
||||||
? 'bg-green-400 dark:bg-green-300 dark:text-green-900 text-green-50'
|
|
||||||
: toast.type == 'warning'
|
|
||||||
? 'bg-yellow-400 dark:bg-yellow-300 dark:text-yellow-900 text-yellow-50'
|
|
||||||
: 'bg-red-400 dark:bg-red-300 dark:text-red-900 text-red-50',
|
|
||||||
]}
|
|
||||||
src={toast.type == 'info'
|
src={toast.type == 'info'
|
||||||
? InformationCircle
|
? InformationCircle
|
||||||
: toast.type == 'success'
|
: toast.type == 'success'
|
||||||
@@ -63,9 +55,7 @@
|
|||||||
: ExclamationCircle}
|
: ExclamationCircle}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
<div class="flex flex-col break-words max-w-full text-inherit">
|
||||||
class="flex flex-col break-words max-w-full text-slate-900 dark:text-zinc-50"
|
|
||||||
>
|
|
||||||
{#if toast.title}
|
{#if toast.title}
|
||||||
<h1 class="text-base font-semibold">{toast.title}</h1>
|
<h1 class="text-base font-semibold">{toast.title}</h1>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -90,9 +80,9 @@
|
|||||||
onclick={() => {
|
onclick={() => {
|
||||||
toasts.update(toasts => toasts.filter(t => t.id != toast.id))
|
toasts.update(toasts => toasts.filter(t => t.id != toast.id))
|
||||||
}}
|
}}
|
||||||
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer"
|
class="rounded-lg w-max transition-colors hover:bg-slate-100 dark:hover:bg-zinc-800 p-1 cursor-pointer text-slate-600 dark:text-zinc-400"
|
||||||
>
|
>
|
||||||
<Icon src={XMark} size="20" micro />
|
<Icon src={XMark} size="16" micro />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
>
|
>
|
||||||
{#each $toasts as toast (toast.id)}
|
{#each $toasts as toast (toast.id)}
|
||||||
<div
|
<div
|
||||||
animate:flip={{ duration: 500, easing: expoOut }}
|
animate:flip={{ duration: 300, easing: expoOut }}
|
||||||
class="pointer-events-auto transition-all
|
class="pointer-events-auto transition-all
|
||||||
duration-300"
|
duration-300"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { writable } from 'svelte/store'
|
|||||||
type ToastType = keyof typeof toastColors
|
type ToastType = keyof typeof toastColors
|
||||||
|
|
||||||
export const toastColors = {
|
export const toastColors = {
|
||||||
error: 'bg-red-100/50 dark:bg-red-900/20 border-red-300/40 border',
|
error: 'text-red-600 dark:text-red-400',
|
||||||
warning: 'bg-yellow-100/50 dark:bg-yellow-500/5 border-yellow-500/40 border',
|
warning: 'text-yellow-600 dark:text-yellow-400',
|
||||||
success: 'bg-green-100/50 dark:bg-green-900/20 border-green-300/40 border',
|
success: 'text-green-600 dark:text-green-400',
|
||||||
info: 'dark:bg-zinc-925/90 bg-white border border-slate-200 dark:border-zinc-800',
|
info: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Toast {
|
export interface Toast {
|
||||||
|
|||||||
@@ -45,8 +45,8 @@
|
|||||||
{#if type}
|
{#if type}
|
||||||
<Location name="type" navigate bind:selected={type} />
|
<Location name="type" navigate bind:selected={type} />
|
||||||
{/if}
|
{/if}
|
||||||
<Sort name="sort" navigate bind:selected={sort} />
|
<Sort placement="bottom" name="sort" navigate bind:selected={sort} />
|
||||||
<ViewSelect />
|
<ViewSelect placement="bottom" />
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -13,8 +13,10 @@
|
|||||||
let searchElement = $state<HTMLInputElement>()
|
let searchElement = $state<HTMLInputElement>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="mt-4 mb-0 sticky z-30 top-6 lg:top-22 drop-shadow-md">
|
<div class="mt-4 mb-0 sticky z-30 top-6 lg:top-22">
|
||||||
<div class="flex gap-2 flex-row items-center w-full text-base h-10">
|
<div
|
||||||
|
class="flex gap-2 flex-row items-center w-full text-base h-10 drop-shadow-md"
|
||||||
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
bind:element={searchElement}
|
bind:element={searchElement}
|
||||||
@@ -27,7 +29,7 @@
|
|||||||
submit
|
submit
|
||||||
color="primary"
|
color="primary"
|
||||||
size="custom"
|
size="custom"
|
||||||
class="shrink-0 h-full aspect-square"
|
class="shrink-0 h-full aspect-square shadow-md"
|
||||||
title="Search"
|
title="Search"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
loading={navigating.to?.route.id == '/search'}
|
loading={navigating.to?.route.id == '/search'}
|
||||||
|
|||||||
Reference in new issue
Block a user