design: use adaptive buttons for nav panel

This commit is contained in:
Xylight committed 2024-09-01 13:01:32 -07:00
1 parent ef1d13b06f
commit 4e4c351a9c
5 files changed
+34 -52

No files matched your search

+1 -1
View File
@@ -118,7 +118,7 @@
/>
</div>
<div
class="content divide-slate-200 dark:divide-zinc-900 min-h-screen {$userSettings.newWidth
class="content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen {$userSettings.newWidth
? 'limit-width'
: ''}"
>
+16 -5
View File
@@ -2,23 +2,29 @@
import { page } from '$app/stores'
import { Button } from 'mono-svelte'
import { Icon, type IconSource } from 'svelte-hero-icons'
import { dockProps } from '../layout/Shell.svelte'
export let label: string
export let icon: IconSource | undefined = undefined
export let href: string | undefined = undefined
export let adaptive: boolean = true
export let isSelectedFilter: (path: string) => boolean = (path) =>
href != undefined && path == href
$: isSelected = isSelectedFilter($page.url.pathname)
$: isPanel = adaptive ? $dockProps.noGap : false
</script>
<Button
color="tertiary"
color={isPanel ? 'tertiary' : 'tertiary'}
{...$$restProps}
on:click
on:contextmenu
class="rounded-full w-10 h-10 flex-shrink-0 {isSelected
class="rounded-full w-10 h-10 flex-shrink-0 {adaptive
? '@3xl:h-8 @3xl:px-3 @3xl:rounded-[10px] @3xl:w-auto'
: ''} {isSelected
? 'bg-slate-200 dark:bg-zinc-900 text-primary-900 dark:!text-primary-100'
: ''} {$$props.class ?? ''}"
size="custom"
@@ -28,10 +34,15 @@
style="transition-property: background-color, filter;"
>
{#if icon}
<Icon src={icon} solid={isSelected} size="18" />
<Icon
src={icon}
micro={isPanel}
solid={!isPanel && isSelected}
size={isPanel ? '16' : '18'}
/>
{:else}
<slot {isSelected} name="icon" />
<slot size={isPanel ? 16 : 18} {isSelected} name="icon" />
{/if}
<!-- <span class="max-md:hidden">{label}</span> -->
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
<slot />
</Button>
+10 -41
View File
@@ -37,14 +37,13 @@
import CommandsWrapper from './commands/CommandsWrapper.svelte'
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
let searching = false
let promptOpen: boolean = false
</script>
<CommandsWrapper bind:open={promptOpen} />
<nav
class="flex flex-row gap-2 items-center w-full mx-auto z-50 box-border p-0.5
duration-150
duration-150 @container
{$$props.class}
"
style={$$props.style}
@@ -58,6 +57,7 @@
href="/"
label={$t('nav.home')}
class="ml-2 logo"
adaptive={false}
>
<svelte:fragment slot="icon">
{#if LINKED_INSTANCE_URL}
@@ -76,39 +76,6 @@
{/if}
</svelte:fragment>
</NavButton>
{#if searching}
<div
class="w-full h-full absolute z-20 p-2 flex items-center gap-2 bg-white dark:bg-zinc-950
rounded-full"
transition:scale={{
start: 0.96,
duration: 250,
easing: backOut,
}}
>
<Button
size="custom"
rounding="pill"
class="w-11 h-11 flex-shrink-0"
on:click={() => (searching = false)}
>
<Icon src={XMark} size="18" mini />
</Button>
<SearchBar let:search let:loading class="!rounded-full z-20">
<Button
size="custom"
rounding="pill"
class="w-11 h-11 flex-shrink-0"
on:click={search}
color="primary"
type="submit"
{loading}
>
<Icon src={MagnifyingGlass} size="18" mini slot="prefix" />
</Button>
</SearchBar>
</div>
{/if}
<div
class="flex flex-row gap-2 py-2 px-2 items-center w-full overflow-auto"
style="border-radius: inherit;"
@@ -140,7 +107,13 @@
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
{/if}
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
<ShieldIcon
let:size
let:isSelected
slot="icon"
filled={isSelected}
width={size}
/>
</NavButton>
{/if}
<NavButton
@@ -148,11 +121,7 @@
label={$t('nav.communities')}
icon={GlobeAlt}
/>
<NavButton
on:click={() => (searching = true)}
label={$t('nav.search')}
icon={MagnifyingGlass}
/>
<NavButton href="/search" label={$t('nav.search')} icon={MagnifyingGlass} />
<Menu placement="top">
<NavButton
class="relative"
+4 -4
View File
@@ -58,19 +58,19 @@
<Menu {...$$restProps}>
<button
class="w-10 h-10 rounded-full ring-1 ring-slate-200 dark:ring-zinc-700
class="w-10 h-10 rounded-full border-2 border-slate-200 dark:border-zinc-700
transition-all bg-slate-50 dark:bg-zinc-900 relative
hover:dark:brightness-125 hover:brightness {$$props.buttonClass}"
hover:border-primary-900 hover:dark:border-primary-100 active:scale-95 {$$props.buttonClass}"
title={$t('profile.profile')}
slot="target"
>
{#if $profile?.user}
<div
class="w-10 h-10 aspect-square object-cover rounded-full grid place-items-center"
class="w-full h-full aspect-square object-cover rounded-full grid place-items-center"
>
<Avatar
url={$profile.user.local_user_view.person.avatar}
width={38}
width={36}
alt={$profile.user.local_user_view.person.name}
/>
</div>
+3 -1
View File
@@ -8,9 +8,11 @@ import { feature } from '$lib/version.js'
import { client } from '$lib/lemmy.js'
import { site } from './lemmy'
// Despite the name, this will round up
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
export const findClosestNumber = (numbers: number[], target: number): number =>
numbers.reduce((prev, curr) =>
Math.abs(curr - target) < Math.abs(prev - target) ? curr : prev
curr >= target && (prev < target || curr < prev) ? curr : prev
)
export const searchParam = (