impr: optimize navbar elements+fix: horizontal scrollbar on chromium (#605)

This commit is contained in:
Xylight authored and GitHub committed 2025-07-08 21:47:20 +00:00
1 parent 9d0aa878ca
commit 47418e735c
9 files changed
+59 -102

No files matched your search

+1 -4
View File
@@ -8,17 +8,14 @@
<meta name="keywords" content="lemmy, client" /> <meta name="keywords" content="lemmy, client" />
%sveltekit.head% %sveltekit.head%
</head> </head>
<body data-sveltekit-preload-data="hover"> <body>
<div <div
style=" style="
width: 100vw;
height: 100vh;
z-index: -50; z-index: -50;
position: absolute; position: absolute;
inset: 0; inset: 0;
display: grid; display: grid;
place-items: center; place-items: center;
background-color: #111115;
color: #fafafe; color: #fafafe;
" "
> >
+2
View File
@@ -6,6 +6,8 @@ export const handleError: HandleServerError = async ({
status, status,
message, message,
}) => { }) => {
if (status == 404) return
console.error(`An error was captured:`) console.error(`An error was captured:`)
console.error(error) console.error(error)
console.error(`Event:`, event) console.error(`Event:`, event)
+1 -1
View File
@@ -9,7 +9,7 @@
<aside <aside
class="sticky top-0 left-0 break-words flex shrink class="sticky top-0 left-0 break-words flex shrink
flex-col gap-4 px-6 pt-4 max-w-full w-full h-full flex-col gap-4 px-6 max-w-full w-full h-full
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {clazz}" overflow-auto text-sm border-slate-200 dark:border-zinc-800 {clazz}"
> >
{@render children?.()} {@render children?.()}
+39 -73
View File
@@ -1,28 +1,22 @@
<script lang="ts"> <script lang="ts">
import { settings } from '$lib/settings.svelte.js' import { settings } from '$lib/settings.svelte.js'
import type { Snippet } from 'svelte' import type { Snippet } from 'svelte'
import type { ClassValue, HTMLAttributes, UIEventHandler } from 'svelte/elements' import type {
ClassValue,
HTMLAttributes,
UIEventHandler,
} from 'svelte/elements'
import { scrollY } from 'svelte/reactivity/window' import { scrollY } from 'svelte/reactivity/window'
interface Props extends HTMLAttributes<HTMLDivElement> { interface Props extends HTMLAttributes<HTMLDivElement> {
route?: { id: string | null } | undefined
class?: ClassValue
children?: Snippet children?: Snippet
navbar?: Snippet<[{ class: string; style: string }]> navbar?: Snippet<[{ class: ClassValue; style: string }]>
sidebar?: Snippet<[{ class: string; style: string }]> sidebar?: Snippet<[{ class: ClassValue; style: string }]>
main?: Snippet<[{ class: string; style: string }]> main?: Snippet<[{ class: ClassValue; style: string }]>
suffix?: Snippet<[{ class: string; style: string }]> suffix?: Snippet<[{ class: ClassValue; style: string }]>
} }
let { let { children, navbar, sidebar, main, suffix }: Props = $props()
class: clazz = '',
children,
navbar,
sidebar,
main,
suffix,
...rest
}: Props = $props()
let previousTop = 0 let previousTop = 0
const onscroll: UIEventHandler<Window> = () => { const onscroll: UIEventHandler<Window> = () => {
@@ -31,8 +25,7 @@
return return
} }
dockVisible = (scrollY?.current ?? 0) <= previousTop dockVisible = (scrollY?.current ?? 0) >= previousTop
previousTop = scrollY?.current ?? 0 previousTop = scrollY?.current ?? 0
} }
@@ -41,54 +34,46 @@
<svelte:window {onscroll} /> <svelte:window {onscroll} />
<div {...rest} class="shell bg-slate-50 dark:bg-zinc-950 {clazz}"> {@render children?.()}
{@render children?.()} <div
<div class={[
class="fixed bottom-0 {dockVisible ? '' : 'max-lg:-bottom-24'} lg:top-0 'fixed lg:sticky bottom-0 lg:top-0',
max-w-3xl p-4 left-1/2 -translate-x-1/2 lg:max-w-full lg:p-0 lg:left-0 lg:translate-x-0 dockVisible && 'max-lg:-bottom-24',
w-full z-50 pointer-events-none" 'max-w-3xl p-4 left-1/2 -translate-x-1/2 lg:max-w-full lg:p-0 lg:left-0 lg:translate-x-0',
style="grid-area: navbar; 'w-full z-50 pointer-events-none',
transition: bottom .4s cubic-bezier(0.075, 0.82, 0.165, 1);" ]}
> style="transition: bottom .4s cubic-bezier(0.075, 0.82, 0.165, 1);"
>
{@render navbar?.({ {@render navbar?.({
class: `bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900 class: [
pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0 'bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900',
rounded-full lg:rounded-none`, 'pointer-events-auto backdrop-blur-xl border lg:border-t-0 lg:border-x-0',
'rounded-full lg:rounded-none',
],
style: '', style: '',
})} })}
</div> </div>
<div <div
class="content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen {settings.newWidth class={[
? 'limit-width' 'content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen',
: ''}" settings.newWidth && 'limit-width',
> ]}
>
{@render sidebar?.({ {@render sidebar?.({
class: `hidden md:flex sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950 class: `hidden md:flex sticky top-0 lg:top-16 left-0 h-max bg-slate-50 dark:bg-zinc-950 z-40`,
z-40 lg:pt-20!`,
style: 'grid-area: sidebar; width: 100% !important;', style: 'grid-area: sidebar; width: 100% !important;',
})} })}
{@render main?.({ {@render main?.({
class: `w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-xs z-0 main pb-22! lg:pb-0! lg:pt-22!`, class: `w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-xs z-0 main pb-22 lg:pb-0`,
style: 'grid-area: main', style: 'grid-area: main',
})} })}
{@render suffix?.({ {@render suffix?.({
class: `max-xl:hidden w-full sticky top-0 left-0 max-h-screen bg-slate-50 dark:bg-zinc-950 class: `max-xl:hidden w-full sticky top-0 lg:top-16 left-0 max-h-screen bg-slate-50 dark:bg-zinc-950 z-40`,
z-40 lg:pt-20!`,
style: 'grid-area: suffix;', style: 'grid-area: suffix;',
})} })}
</div>
</div> </div>
<style> <style>
.shell {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
grid-template-areas:
'navbar'
'content';
}
.content { .content {
width: 100%; width: 100%;
display: grid; display: grid;
@@ -101,16 +86,12 @@
} }
.content.limit-width { .content.limit-width {
max-width: 120rem; max-width: 110rem;
}
.content > * {
width: 100%; /* Full width for immediate children */
} }
@media (min-width: 768px) { @media (min-width: 768px) {
.content { .content {
grid-template-columns: 14rem 2fr; grid-template-columns: 16rem 1fr;
justify-items: end start; justify-items: end start;
grid-template-areas: 'sidebar main'; grid-template-areas: 'sidebar main';
} }
@@ -124,23 +105,8 @@
} }
.content.limit-width { .content.limit-width {
grid-template-columns: 1fr 2fr 1fr;
}
:global(.content.limit-width > *:first-child) {
max-width: 20rem;
justify-self: end;
width: 100%;
}
:global(.content.limit-width > *:last-child) {
max-width: 20rem;
justify-self: start;
width: 100%;
}
.main {
width: 100%; width: 100%;
grid-template-columns: 2fr 5fr 2fr;
} }
} }
</style> </style>
+5 -5
View File
@@ -47,14 +47,14 @@
<CommandsWrapper bind:open={promptOpen} /> <CommandsWrapper bind:open={promptOpen} />
<nav <nav
class="flex flex-row gap-2 items-center w-full mx-auto z-50 box-border p-0.5 class={[
duration-150 @container 'flex flex-row gap-2 items-center w-full mx-auto z-50 box-border p-0.5 duration-150 @container',
{clazz} clazz,
" ]}
{style} {style}
> >
<NavButton <NavButton
oncontextmenu={e => { oncontextmenu={(e: Event) => {
e.preventDefault() e.preventDefault()
promptOpen = true promptOpen = true
return true return true
+3 -3
View File
@@ -17,18 +17,18 @@
UserGroup, UserGroup,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import EndPlaceholder from '../EndPlaceholder.svelte' import EndPlaceholder from '../EndPlaceholder.svelte'
import type { ClassValue } from 'svelte/elements'
interface Props { interface Props {
style?: string style?: string
class?: string class?: ClassValue
} }
let { style = '', class: clazz = '' }: Props = $props() let { style = '', class: clazz = '' }: Props = $props()
</script> </script>
<nav <nav
class="flex flex-col p-4 overflow-auto class={['flex flex-col p-4 overflow-auto gap-1 h-fit max-h-screen', clazz]}
gap-1 h-fit max-h-screen {clazz}"
{style} {style}
> >
{#if profile.data?.jwt} {#if profile.data?.jwt}
+7 -8
View File
@@ -50,11 +50,9 @@
$effect(() => { $effect(() => {
if (settings) { if (settings) {
document.documentElement.classList.remove( document.documentElement.classList.remove(
'font-display',
'font-inter', 'font-inter',
'font-sans', 'font-sans',
'font-system', 'font-system',
'font-nunito',
) )
document.documentElement.classList.add( document.documentElement.classList.add(
settings.font == 'inter' settings.font == 'inter'
@@ -69,6 +67,11 @@
$effect(() => { $effect(() => {
document.documentElement.setAttribute('style', theme.vars) document.documentElement.setAttribute('style', theme.vars)
}) })
$effect(() => {
document.documentElement.dir =
($locale == 'he' || $locale == 'ar') && settings.useRtl ? 'rtl' : 'ltr'
})
} }
$effect(() => { $effect(() => {
@@ -109,11 +112,7 @@
Skip Navigation Skip Navigation
</Button> </Button>
<Shell <Shell>
dir={$locale == 'he' && settings.useRtl ? 'rtl' : 'ltr'}
class="min-h-screen ease-cubic duration-200"
route={page.route}
>
<Moderation /> <Moderation />
<ToastContainer /> <ToastContainer />
<ExpandableImage /> <ExpandableImage />
@@ -135,7 +134,7 @@
<Navbar class={c} style={s} /> <Navbar class={c} style={s} />
{/snippet} {/snippet}
{#snippet suffix({ class: c, style: s })} {#snippet suffix({ class: c, style: s })}
<div class=" {c}" style={s}> <div class={c} style={s}>
{#if page.data.slots?.sidebar?.component} {#if page.data.slots?.sidebar?.component}
{@const SvelteComponent = page.data.slots.sidebar.component} {@const SvelteComponent = page.data.slots.sidebar.component}
<SvelteComponent {...page.data.slots.sidebar.props} class="pt-0!" /> <SvelteComponent {...page.data.slots.sidebar.props} class="pt-0!" />
+1 -2
View File
@@ -130,7 +130,7 @@
</div> </div>
{/snippet} {/snippet}
</Header> </Header>
<form class="accounts-grid mt-4 sm:mt-6"> <form class="accounts-grid mt-4 sm:mt-6 gap-4">
{#each profileData.profiles as profile, index (profile.id)} {#each profileData.profiles as profile, index (profile.id)}
<label> <label>
<input <input
@@ -241,6 +241,5 @@
.accounts-grid { .accounts-grid {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: calc(var(--spacing) * 4);
} }
</style> </style>
-6
View File
@@ -8,7 +8,6 @@
--font-sans: sans-serif; --font-sans: sans-serif;
--font-system: system-ui; --font-system: system-ui;
--font-inter: Inter, system-ui, sans-serif; --font-inter: Inter, system-ui, sans-serif;
--font-nunito: Nunito, system-ui, sans-serif;
--font-display: Inter, system-ui, sans-serif; --font-display: Inter, system-ui, sans-serif;
--font-mono: monospace; --font-mono: monospace;
@@ -74,11 +73,6 @@ body {
color-scheme: dark; color-scheme: dark;
} }
html,
body {
text-rendering: auto;
}
.wait * { .wait * {
cursor: wait !important; cursor: wait !important;
} }