feat: add adaptive nav positioning
This commit is contained in:
1 parent
3bd0b066a3
commit
5e43c3a102
4 files changed
+80
-27
No files matched your search
@@ -27,34 +27,65 @@
|
||||
return 'hi this is easter egg, my code broke'
|
||||
}
|
||||
|
||||
$: contentPadding = calculatePadding(
|
||||
$userSettings.dock.noGap,
|
||||
$userSettings.dock.top,
|
||||
true
|
||||
)
|
||||
$: sidePadding = calculatePadding(
|
||||
$userSettings.dock.noGap,
|
||||
$userSettings.dock.top,
|
||||
false
|
||||
)
|
||||
let screenWidth = 1000
|
||||
|
||||
const calculateDockProperties = (
|
||||
settings: typeof $userSettings.dock,
|
||||
screenWidth: number
|
||||
): {
|
||||
noGap: boolean
|
||||
top: boolean
|
||||
} => {
|
||||
let panel = false
|
||||
let top = false
|
||||
|
||||
if (screenWidth > 1000) {
|
||||
panel = true
|
||||
top = true
|
||||
} else if (screenWidth > 800) {
|
||||
panel = true
|
||||
top = false
|
||||
} else if (screenWidth > 600) {
|
||||
panel = false
|
||||
top = false
|
||||
}
|
||||
|
||||
panel = settings.noGap ?? panel
|
||||
top = settings.top ?? top
|
||||
|
||||
return {
|
||||
noGap: panel,
|
||||
top: top,
|
||||
}
|
||||
}
|
||||
|
||||
$: dockProps = calculateDockProperties($userSettings.dock, screenWidth)
|
||||
|
||||
$: contentPadding = calculatePadding(dockProps.noGap, dockProps.top, true)
|
||||
$: sidePadding = calculatePadding(dockProps.noGap, dockProps.top, false)
|
||||
$: topPanel = $userSettings.dock.noGap && $userSettings.dock.top
|
||||
</script>
|
||||
|
||||
<svelte:window bind:innerWidth={screenWidth} />
|
||||
|
||||
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
|
||||
<slot />
|
||||
<div
|
||||
class="
|
||||
{$userSettings.dock.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
|
||||
{$userSettings.dock.top ? 'top-0' : 'bottom-0'}
|
||||
{dockProps.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
|
||||
{dockProps.top ? 'top-0' : 'bottom-0'}
|
||||
{topPanel ? 'fixed top-0' : 'fixed'}
|
||||
w-full z-50 pointer-events-none"
|
||||
style="grid-area: navbar; transition: padding 250ms cubic-bezier(0.075, 0.82, 0.165, 1);"
|
||||
style="grid-area: navbar;
|
||||
transition-property: padding, top, bottom;
|
||||
transition-duration: 250ms;
|
||||
transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);"
|
||||
>
|
||||
<slot
|
||||
name="navbar"
|
||||
class="
|
||||
{$userSettings.dock.noGap
|
||||
? $userSettings.dock.top
|
||||
{dockProps.noGap
|
||||
? dockProps.top
|
||||
? 'border-b shadow-none rounded-none'
|
||||
: 'border-t rounded-none'
|
||||
: 'border rounded-full'}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
import SearchBar from '$lib/components/lemmy/util/SearchBar.svelte'
|
||||
import { swipeGesture } from '$lib/input/swipe'
|
||||
import Logo from '../Logo.svelte'
|
||||
import { LINKED_INSTANCE_URL } from '$lib/instance'
|
||||
|
||||
let searching = false
|
||||
</script>
|
||||
@@ -40,7 +41,22 @@
|
||||
style={$$props.style}
|
||||
>
|
||||
<NavButton href="/" label="Home" class="ml-2 logo">
|
||||
<Logo width={32} slot="icon" />
|
||||
<svelte:fragment slot="icon">
|
||||
{#if LINKED_INSTANCE_URL}
|
||||
{#if $site}
|
||||
<Avatar
|
||||
alt={$site.site_view.site.name}
|
||||
url={$site.site_view.site.icon}
|
||||
width={32}
|
||||
circle={false}
|
||||
/>
|
||||
{:else}
|
||||
<Spinner width={32} />
|
||||
{/if}
|
||||
{:else}
|
||||
<Logo width={32} />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</NavButton>
|
||||
{#if searching}
|
||||
<div
|
||||
|
||||
+4
-4
@@ -70,8 +70,8 @@ interface Settings {
|
||||
youtube: 'youtube' | 'invidious' | 'piped'
|
||||
}
|
||||
dock: {
|
||||
noGap: boolean
|
||||
top: boolean
|
||||
noGap: boolean | null
|
||||
top: boolean | null
|
||||
}
|
||||
posts: {
|
||||
deduplicateEmbed: boolean
|
||||
@@ -127,8 +127,8 @@ export const defaultSettings: Settings = {
|
||||
youtube: 'youtube',
|
||||
},
|
||||
dock: {
|
||||
noGap: toBool(env.PUBLIC_DOCK_PANEL) ?? false,
|
||||
top: toBool(env.PUBLIC_DOCK_TOP) ?? false
|
||||
noGap: toBool(env.PUBLIC_DOCK_PANEL) ?? null,
|
||||
top: toBool(env.PUBLIC_DOCK_TOP) ?? null
|
||||
},
|
||||
posts: {
|
||||
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
|
||||
|
||||
@@ -64,16 +64,22 @@
|
||||
<span slot="title">Dock position</span>
|
||||
<span slot="description">Where the dock should be put</span>
|
||||
<MultiSelect
|
||||
options={[true, false]}
|
||||
optionNames={['Top', 'Bottom']}
|
||||
options={[true, false, null]}
|
||||
optionNames={['Top', 'Bottom', 'Adaptive']}
|
||||
bind:selected={$userSettings.dock.top}
|
||||
/>
|
||||
</Setting>
|
||||
<ToggleSetting
|
||||
bind:checked={$userSettings.dock.noGap}
|
||||
title="Panel mode"
|
||||
description="Extend the dock to screen edges, similar to a panel."
|
||||
/>
|
||||
<Setting>
|
||||
<span slot="title">Panel mode</span>
|
||||
<span slot="description">
|
||||
Extend the dock to screen edges, similar to a panel.
|
||||
</span>
|
||||
<MultiSelect
|
||||
options={[true, false, null]}
|
||||
optionNames={['On', 'Off', 'Adaptive']}
|
||||
bind:selected={$userSettings.dock.noGap}
|
||||
/>
|
||||
</Setting>
|
||||
</Section>
|
||||
|
||||
<Section title="Photon">
|
||||
|
||||
Reference in new issue
Block a user