fix: make menu focus not be balls
This commit is contained in:
14 files changed
+114
-99
No files matched your search
@@ -15,6 +15,7 @@
|
||||
showWhenEmpty?: boolean
|
||||
placeholder?: string
|
||||
onselect?: (item: any) => void
|
||||
label?: string
|
||||
}
|
||||
|
||||
let {
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
{/if}
|
||||
</article>
|
||||
|
||||
<style lang="postcss">
|
||||
<style>
|
||||
.list-type {
|
||||
display: grid;
|
||||
grid-template-areas: 'meta media' 'title media' 'body media' 'embed embed' 'actions actions';
|
||||
|
||||
@@ -20,64 +20,6 @@
|
||||
['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 = (
|
||||
title?: string,
|
||||
): { tags: Tag[]; title?: string } => {
|
||||
@@ -184,6 +126,64 @@
|
||||
titleClass = '',
|
||||
extraBadges,
|
||||
}: 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>
|
||||
|
||||
<!--
|
||||
|
||||
@@ -348,11 +348,6 @@
|
||||
class="w-full"
|
||||
/>
|
||||
<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}
|
||||
<Button
|
||||
onclick={() => (addAltText = !addAltText)}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
listing_type?: ListingType
|
||||
showWhenEmpty?: boolean
|
||||
hideOwnUser?: boolean
|
||||
placeholder?: string
|
||||
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"
|
||||
color="tertiary"
|
||||
size="square-sm"
|
||||
onclick={() => onclose()}
|
||||
onclick={onclose}
|
||||
icon={XMark}
|
||||
></Button>
|
||||
{/if}
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
<div
|
||||
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"
|
||||
role="menu"
|
||||
>
|
||||
{@render children?.(open)}
|
||||
</div>
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
{disabled}
|
||||
data-autoclose={nest ? 'false' : 'true'}
|
||||
shadow="none"
|
||||
role="menuitem"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<div
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
type Strategy,
|
||||
} from '@floating-ui/core'
|
||||
import { createFloatingActions } from 'svelte-floating-ui'
|
||||
import { focusTrap } from 'svelte-focus-trap'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import { expoOut } from 'svelte/easing'
|
||||
import { scale } from 'svelte/transition'
|
||||
import { Material } from '../index'
|
||||
import Portal from './Portal.svelte'
|
||||
import { focusTrap } from 'svelte-focus-trap'
|
||||
|
||||
interface Props {
|
||||
openOnHover?: boolean
|
||||
@@ -72,11 +72,23 @@
|
||||
const menuAttach: Attachment = (element) => {
|
||||
const e = element as HTMLButtonElement
|
||||
|
||||
const mouseLeave = () => (openOnHover ? (open = false) : false)
|
||||
const focus = () => (openOnHover ? (open = true) : false)
|
||||
const focusout = () => (openOnHover ? (open = false) : false)
|
||||
function toggle(force?: boolean) {
|
||||
if (!open && force == false) return
|
||||
|
||||
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 = () => {
|
||||
open = !open
|
||||
toggle()
|
||||
|
||||
if (autoClose) {
|
||||
const clickHandler = (event: Event) => {
|
||||
@@ -86,7 +98,7 @@
|
||||
|
||||
if (!e?.contains(event.target as Element | null)) {
|
||||
if (target?.closest("[data-autoclose='false']") == null) {
|
||||
open = false
|
||||
toggle(false)
|
||||
document.removeEventListener('click', clickHandler)
|
||||
}
|
||||
}
|
||||
@@ -95,14 +107,16 @@
|
||||
}
|
||||
}
|
||||
const keydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') open = false
|
||||
if (event.key === 'Escape') {
|
||||
toggle(false)
|
||||
}
|
||||
}
|
||||
|
||||
e.addEventListener('mouseleave', mouseLeave)
|
||||
e.addEventListener('focus', focus)
|
||||
e.addEventListener('focusout', focusout)
|
||||
e.addEventListener('click', click)
|
||||
e.addEventListener('keydown', keydown)
|
||||
popoverEl?.addEventListener('keydown', keydown)
|
||||
|
||||
floatingRef(e)
|
||||
|
||||
@@ -111,7 +125,7 @@
|
||||
e.removeEventListener('focus', focus)
|
||||
e.removeEventListener('focusout', focusout)
|
||||
e.removeEventListener('click', click)
|
||||
e.removeEventListener('keydown', keydown)
|
||||
popoverEl?.removeEventListener('keydown', keydown)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -127,12 +141,14 @@
|
||||
opacity: 0,
|
||||
easing: expoOut,
|
||||
}}
|
||||
class="z-150 {popoverClass}"
|
||||
class={['z-150', popoverClass]}
|
||||
use:floatingContent
|
||||
use:focusTrap
|
||||
bind:this={popoverEl}
|
||||
>
|
||||
{#if popover}{@render popover(open)}{:else}
|
||||
{#if popover}
|
||||
{@render popover(open)}
|
||||
{:else}
|
||||
<Material elevation="high" color="distinct" class="flex flex-col">
|
||||
{@render children?.(open)}
|
||||
</Material>
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function load({ params, fetch }) {
|
||||
|
||||
const split = comment.comment_view.comment.path.split('.')
|
||||
|
||||
const threadPath = split.slice(-5).join('.')
|
||||
const threadPath = split.slice(-2).join('.')
|
||||
|
||||
redirect(
|
||||
302,
|
||||
|
||||
@@ -9,22 +9,24 @@
|
||||
|
||||
<Header pageHeader>
|
||||
{$t('nav.create.label')}
|
||||
{#snippet extended()}
|
||||
{#if !site || !site.data?.site_view.local_site.community_creation_admin_only}
|
||||
<Tabs
|
||||
margin={false}
|
||||
style="subpage"
|
||||
routes={[
|
||||
{
|
||||
href: '/create/post',
|
||||
name: $t('nav.create.post'),
|
||||
},
|
||||
{
|
||||
href: '/create/community',
|
||||
name: $t('nav.create.community'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Header>
|
||||
|
||||
{#if !site || !site.data?.site_view.local_site.community_creation_admin_only}
|
||||
<Tabs
|
||||
style="subpage"
|
||||
routes={[
|
||||
{
|
||||
href: '/create/post',
|
||||
name: $t('nav.create.post'),
|
||||
},
|
||||
{
|
||||
href: '/create/community',
|
||||
name: $t('nav.create.community'),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{@render children?.()}
|
||||
@@ -304,7 +304,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="postcss">
|
||||
<style>
|
||||
@reference '../../style/app.css'
|
||||
|
||||
:global(.table thead tr th) {
|
||||
|
||||
@@ -306,12 +306,12 @@
|
||||
{/await}
|
||||
{#if data.post.value.post_view.counts.comments > 5}
|
||||
<EndPlaceholder>
|
||||
<span class="text-black dark:text-white font-bold">
|
||||
{data.post.value.post_view.counts.comments}
|
||||
</span>
|
||||
{$t('routes.post.commentCount')}
|
||||
|
||||
{#snippet action()}
|
||||
<span class="text-black dark:text-white font-bold">
|
||||
{data.post.value.post_view.counts.comments}
|
||||
</span>
|
||||
<Button
|
||||
color="tertiary"
|
||||
onclick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
|
||||
|
||||
Reference in new issue
Block a user