fix: make menu focus not be balls
This commit is contained in:
14 files changed
+100
-85
No files matched your search
@@ -15,6 +15,7 @@
|
|||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
onselect?: (item: any) => void
|
onselect?: (item: any) => void
|
||||||
|
label?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style>
|
||||||
.list-type {
|
.list-type {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-areas: 'meta media' 'title media' 'body media' 'embed embed' 'actions actions';
|
grid-template-areas: 'meta media' 'title media' 'body media' 'embed embed' 'actions actions';
|
||||||
|
|||||||
@@ -20,64 +20,6 @@
|
|||||||
['CW', { content: 'CW', color: '#ff000040' }],
|
['CW', { content: 'CW', color: '#ff000040' }],
|
||||||
])
|
])
|
||||||
|
|
||||||
const badgeToData: Map<
|
|
||||||
BadgeType,
|
|
||||||
{
|
|
||||||
icon: IconSource
|
|
||||||
color: 'red-subtle' | 'yellow-subtle' | 'green-subtle'
|
|
||||||
label: string
|
|
||||||
}
|
|
||||||
> = new Map([
|
|
||||||
[
|
|
||||||
'nsfw',
|
|
||||||
{
|
|
||||||
icon: ExclamationTriangle,
|
|
||||||
color: 'red-subtle',
|
|
||||||
label: t.get('post.badges.nsfw'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'saved',
|
|
||||||
{
|
|
||||||
icon: Bookmark,
|
|
||||||
color: 'yellow-subtle',
|
|
||||||
label: t.get('post.badges.saved'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'featured',
|
|
||||||
{
|
|
||||||
icon: Megaphone,
|
|
||||||
color: 'green-subtle',
|
|
||||||
label: t.get('post.badges.featured'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'removed',
|
|
||||||
{
|
|
||||||
icon: Trash,
|
|
||||||
color: 'green-subtle',
|
|
||||||
label: t.get('post.badges.removed'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'deleted',
|
|
||||||
{
|
|
||||||
icon: Trash,
|
|
||||||
color: 'red-subtle',
|
|
||||||
label: t.get('post.badges.deleted'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'locked',
|
|
||||||
{
|
|
||||||
icon: LockClosed,
|
|
||||||
color: 'yellow-subtle',
|
|
||||||
label: t.get('post.badges.locked'),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
])
|
|
||||||
|
|
||||||
export const parseTags = (
|
export const parseTags = (
|
||||||
title?: string,
|
title?: string,
|
||||||
): { tags: Tag[]; title?: string } => {
|
): { tags: Tag[]; title?: string } => {
|
||||||
@@ -184,6 +126,64 @@
|
|||||||
titleClass = '',
|
titleClass = '',
|
||||||
extraBadges,
|
extraBadges,
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
|
const badgeToData: Map<
|
||||||
|
BadgeType,
|
||||||
|
{
|
||||||
|
icon: IconSource
|
||||||
|
color: 'red-subtle' | 'yellow-subtle' | 'green-subtle'
|
||||||
|
label: string
|
||||||
|
}
|
||||||
|
> = new Map([
|
||||||
|
[
|
||||||
|
'nsfw',
|
||||||
|
{
|
||||||
|
icon: ExclamationTriangle,
|
||||||
|
color: 'red-subtle',
|
||||||
|
label: $t('post.badges.nsfw'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'saved',
|
||||||
|
{
|
||||||
|
icon: Bookmark,
|
||||||
|
color: 'yellow-subtle',
|
||||||
|
label: $t('post.badges.saved'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'featured',
|
||||||
|
{
|
||||||
|
icon: Megaphone,
|
||||||
|
color: 'green-subtle',
|
||||||
|
label: $t('post.badges.featured'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'removed',
|
||||||
|
{
|
||||||
|
icon: Trash,
|
||||||
|
color: 'green-subtle',
|
||||||
|
label: $t('post.badges.removed'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'deleted',
|
||||||
|
{
|
||||||
|
icon: Trash,
|
||||||
|
color: 'red-subtle',
|
||||||
|
label: $t('post.badges.deleted'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'locked',
|
||||||
|
{
|
||||||
|
icon: LockClosed,
|
||||||
|
color: 'yellow-subtle',
|
||||||
|
label: $t('post.badges.locked'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
])
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@@ -348,11 +348,6 @@
|
|||||||
class="w-full"
|
class="w-full"
|
||||||
/>
|
/>
|
||||||
<div class="flex items-center gap-2 actions">
|
<div class="flex items-center gap-2 actions">
|
||||||
<div
|
|
||||||
class="border border-slate-100 dark:border-zinc-800 dark:text-zinc-400 text-slate-600 rounded-xl h-7 w-7 grid place-items-center"
|
|
||||||
>
|
|
||||||
<Icon src={Plus} size="16" micro />
|
|
||||||
</div>
|
|
||||||
{#if data.url}
|
{#if data.url}
|
||||||
<Button
|
<Button
|
||||||
onclick={() => (addAltText = !addAltText)}
|
onclick={() => (addAltText = !addAltText)}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
listing_type?: ListingType
|
listing_type?: ListingType
|
||||||
showWhenEmpty?: boolean
|
showWhenEmpty?: boolean
|
||||||
hideOwnUser?: boolean
|
hideOwnUser?: boolean
|
||||||
|
placeholder?: string
|
||||||
onselect?: (e: Person) => void
|
onselect?: (e: Person) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ bg-white/50 dark:bg-black/50 box-border p-4"
|
|||||||
class="absolute top-0 right-0 m-2 text-slate-600 dark:text-zinc-400"
|
class="absolute top-0 right-0 m-2 text-slate-600 dark:text-zinc-400"
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
size="square-sm"
|
size="square-sm"
|
||||||
onclick={() => onclose()}
|
onclick={onclose}
|
||||||
icon={XMark}
|
icon={XMark}
|
||||||
></Button>
|
></Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex flex-col p-1 list-none bg-white/80 dark:bg-zinc-900/90 rounded-xl
|
class="flex flex-col p-1 list-none bg-white/80 dark:bg-zinc-900/90 rounded-xl
|
||||||
border border-slate-200 dark:border-zinc-800 gap-px"
|
border border-slate-200 dark:border-zinc-800 gap-px"
|
||||||
|
role="menu"
|
||||||
>
|
>
|
||||||
{@render children?.(open)}
|
{@render children?.(open)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
{disabled}
|
{disabled}
|
||||||
data-autoclose={nest ? 'false' : 'true'}
|
data-autoclose={nest ? 'false' : 'true'}
|
||||||
shadow="none"
|
shadow="none"
|
||||||
|
role="menuitem"
|
||||||
>
|
>
|
||||||
{#snippet prefix()}
|
{#snippet prefix()}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -8,12 +8,12 @@
|
|||||||
type Strategy,
|
type Strategy,
|
||||||
} from '@floating-ui/core'
|
} from '@floating-ui/core'
|
||||||
import { createFloatingActions } from 'svelte-floating-ui'
|
import { createFloatingActions } from 'svelte-floating-ui'
|
||||||
import { focusTrap } from 'svelte-focus-trap'
|
|
||||||
import type { Attachment } from 'svelte/attachments'
|
import type { Attachment } from 'svelte/attachments'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { scale } from 'svelte/transition'
|
import { scale } from 'svelte/transition'
|
||||||
import { Material } from '../index'
|
import { Material } from '../index'
|
||||||
import Portal from './Portal.svelte'
|
import Portal from './Portal.svelte'
|
||||||
|
import { focusTrap } from 'svelte-focus-trap'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
openOnHover?: boolean
|
openOnHover?: boolean
|
||||||
@@ -72,11 +72,23 @@
|
|||||||
const menuAttach: Attachment = (element) => {
|
const menuAttach: Attachment = (element) => {
|
||||||
const e = element as HTMLButtonElement
|
const e = element as HTMLButtonElement
|
||||||
|
|
||||||
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
function toggle(force?: boolean) {
|
||||||
const focus = () => (openOnHover ? (open = true) : false)
|
if (!open && force == false) return
|
||||||
const focusout = () => (openOnHover ? (open = false) : false)
|
|
||||||
|
const newOpen = force ?? !open
|
||||||
|
|
||||||
|
if (!newOpen) {
|
||||||
|
e.focus()
|
||||||
|
}
|
||||||
|
|
||||||
|
open = newOpen
|
||||||
|
}
|
||||||
|
|
||||||
|
const mouseLeave = () => openOnHover && toggle(false)
|
||||||
|
const focus = () => openOnHover && toggle(true)
|
||||||
|
const focusout = () => openOnHover && toggle(false)
|
||||||
const click = () => {
|
const click = () => {
|
||||||
open = !open
|
toggle()
|
||||||
|
|
||||||
if (autoClose) {
|
if (autoClose) {
|
||||||
const clickHandler = (event: Event) => {
|
const clickHandler = (event: Event) => {
|
||||||
@@ -86,7 +98,7 @@
|
|||||||
|
|
||||||
if (!e?.contains(event.target as Element | null)) {
|
if (!e?.contains(event.target as Element | null)) {
|
||||||
if (target?.closest("[data-autoclose='false']") == null) {
|
if (target?.closest("[data-autoclose='false']") == null) {
|
||||||
open = false
|
toggle(false)
|
||||||
document.removeEventListener('click', clickHandler)
|
document.removeEventListener('click', clickHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,14 +107,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const keydown = (event: KeyboardEvent) => {
|
const keydown = (event: KeyboardEvent) => {
|
||||||
if (event.key === 'Escape') open = false
|
if (event.key === 'Escape') {
|
||||||
|
toggle(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.addEventListener('mouseleave', mouseLeave)
|
e.addEventListener('mouseleave', mouseLeave)
|
||||||
e.addEventListener('focus', focus)
|
e.addEventListener('focus', focus)
|
||||||
e.addEventListener('focusout', focusout)
|
e.addEventListener('focusout', focusout)
|
||||||
e.addEventListener('click', click)
|
e.addEventListener('click', click)
|
||||||
e.addEventListener('keydown', keydown)
|
popoverEl?.addEventListener('keydown', keydown)
|
||||||
|
|
||||||
floatingRef(e)
|
floatingRef(e)
|
||||||
|
|
||||||
@@ -111,7 +125,7 @@
|
|||||||
e.removeEventListener('focus', focus)
|
e.removeEventListener('focus', focus)
|
||||||
e.removeEventListener('focusout', focusout)
|
e.removeEventListener('focusout', focusout)
|
||||||
e.removeEventListener('click', click)
|
e.removeEventListener('click', click)
|
||||||
e.removeEventListener('keydown', keydown)
|
popoverEl?.removeEventListener('keydown', keydown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -127,12 +141,14 @@
|
|||||||
opacity: 0,
|
opacity: 0,
|
||||||
easing: expoOut,
|
easing: expoOut,
|
||||||
}}
|
}}
|
||||||
class="z-150 {popoverClass}"
|
class={['z-150', popoverClass]}
|
||||||
use:floatingContent
|
use:floatingContent
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
bind:this={popoverEl}
|
bind:this={popoverEl}
|
||||||
>
|
>
|
||||||
{#if popover}{@render popover(open)}{:else}
|
{#if popover}
|
||||||
|
{@render popover(open)}
|
||||||
|
{:else}
|
||||||
<Material elevation="high" color="distinct" class="flex flex-col">
|
<Material elevation="high" color="distinct" class="flex flex-col">
|
||||||
{@render children?.(open)}
|
{@render children?.(open)}
|
||||||
</Material>
|
</Material>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export async function load({ params, fetch }) {
|
|||||||
|
|
||||||
const split = comment.comment_view.comment.path.split('.')
|
const split = comment.comment_view.comment.path.split('.')
|
||||||
|
|
||||||
const threadPath = split.slice(-5).join('.')
|
const threadPath = split.slice(-2).join('.')
|
||||||
|
|
||||||
redirect(
|
redirect(
|
||||||
302,
|
302,
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
|
|
||||||
<Header pageHeader>
|
<Header pageHeader>
|
||||||
{$t('nav.create.label')}
|
{$t('nav.create.label')}
|
||||||
</Header>
|
{#snippet extended()}
|
||||||
|
|
||||||
{#if !site || !site.data?.site_view.local_site.community_creation_admin_only}
|
{#if !site || !site.data?.site_view.local_site.community_creation_admin_only}
|
||||||
<Tabs
|
<Tabs
|
||||||
|
margin={false}
|
||||||
style="subpage"
|
style="subpage"
|
||||||
routes={[
|
routes={[
|
||||||
{
|
{
|
||||||
@@ -26,5 +26,7 @@
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
</Header>
|
||||||
|
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
@@ -304,7 +304,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style>
|
||||||
@reference '../../style/app.css'
|
@reference '../../style/app.css'
|
||||||
|
|
||||||
:global(.table thead tr th) {
|
:global(.table thead tr th) {
|
||||||
|
|||||||
@@ -306,12 +306,12 @@
|
|||||||
{/await}
|
{/await}
|
||||||
{#if data.post.value.post_view.counts.comments > 5}
|
{#if data.post.value.post_view.counts.comments > 5}
|
||||||
<EndPlaceholder>
|
<EndPlaceholder>
|
||||||
<span class="text-black dark:text-white font-bold">
|
|
||||||
{data.post.value.post_view.counts.comments}
|
|
||||||
</span>
|
|
||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
|
|
||||||
{#snippet action()}
|
{#snippet action()}
|
||||||
|
<span class="text-black dark:text-white font-bold">
|
||||||
|
{data.post.value.post_view.counts.comments}
|
||||||
|
</span>
|
||||||
<Button
|
<Button
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
onclick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
onclick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
||||||
|
|||||||
Reference in new issue
Block a user