design: use adaptive buttons for nav panel
This commit is contained in:
1 parent
ef1d13b06f
commit
4e4c351a9c
5 files changed
+34
-52
No files matched your search
@@ -118,7 +118,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<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'
|
? 'limit-width'
|
||||||
: ''}"
|
: ''}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -2,23 +2,29 @@
|
|||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||||
|
import { dockProps } from '../layout/Shell.svelte'
|
||||||
|
|
||||||
export let label: string
|
export let label: string
|
||||||
export let icon: IconSource | undefined = undefined
|
export let icon: IconSource | undefined = undefined
|
||||||
export let href: string | undefined = undefined
|
export let href: string | undefined = undefined
|
||||||
|
|
||||||
|
export let adaptive: boolean = true
|
||||||
|
|
||||||
export let isSelectedFilter: (path: string) => boolean = (path) =>
|
export let isSelectedFilter: (path: string) => boolean = (path) =>
|
||||||
href != undefined && path == href
|
href != undefined && path == href
|
||||||
|
|
||||||
$: isSelected = isSelectedFilter($page.url.pathname)
|
$: isSelected = isSelectedFilter($page.url.pathname)
|
||||||
|
$: isPanel = adaptive ? $dockProps.noGap : false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
color="tertiary"
|
color={isPanel ? 'tertiary' : 'tertiary'}
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
on:contextmenu
|
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'
|
? 'bg-slate-200 dark:bg-zinc-900 text-primary-900 dark:!text-primary-100'
|
||||||
: ''} {$$props.class ?? ''}"
|
: ''} {$$props.class ?? ''}"
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -28,10 +34,15 @@
|
|||||||
style="transition-property: background-color, filter;"
|
style="transition-property: background-color, filter;"
|
||||||
>
|
>
|
||||||
{#if icon}
|
{#if icon}
|
||||||
<Icon src={icon} solid={isSelected} size="18" />
|
<Icon
|
||||||
|
src={icon}
|
||||||
|
micro={isPanel}
|
||||||
|
solid={!isPanel && isSelected}
|
||||||
|
size={isPanel ? '16' : '18'}
|
||||||
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<slot {isSelected} name="icon" />
|
<slot size={isPanel ? 16 : 18} {isSelected} name="icon" />
|
||||||
{/if}
|
{/if}
|
||||||
<!-- <span class="max-md:hidden">{label}</span> -->
|
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
|
||||||
<slot />
|
<slot />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -37,14 +37,13 @@
|
|||||||
import CommandsWrapper from './commands/CommandsWrapper.svelte'
|
import CommandsWrapper from './commands/CommandsWrapper.svelte'
|
||||||
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
|
import { optimizeImageURL } from '$lib/components/lemmy/post/helpers'
|
||||||
|
|
||||||
let searching = false
|
|
||||||
let promptOpen: boolean = false
|
let promptOpen: boolean = false
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<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="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}
|
{$$props.class}
|
||||||
"
|
"
|
||||||
style={$$props.style}
|
style={$$props.style}
|
||||||
@@ -58,6 +57,7 @@
|
|||||||
href="/"
|
href="/"
|
||||||
label={$t('nav.home')}
|
label={$t('nav.home')}
|
||||||
class="ml-2 logo"
|
class="ml-2 logo"
|
||||||
|
adaptive={false}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="icon">
|
<svelte:fragment slot="icon">
|
||||||
{#if LINKED_INSTANCE_URL}
|
{#if LINKED_INSTANCE_URL}
|
||||||
@@ -76,39 +76,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</NavButton>
|
</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
|
<div
|
||||||
class="flex flex-row gap-2 py-2 px-2 items-center w-full overflow-auto"
|
class="flex flex-row gap-2 py-2 px-2 items-center w-full overflow-auto"
|
||||||
style="border-radius: inherit;"
|
style="border-radius: inherit;"
|
||||||
@@ -140,7 +107,13 @@
|
|||||||
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
|
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<ShieldIcon let:isSelected slot="icon" filled={isSelected} width={18} />
|
<ShieldIcon
|
||||||
|
let:size
|
||||||
|
let:isSelected
|
||||||
|
slot="icon"
|
||||||
|
filled={isSelected}
|
||||||
|
width={size}
|
||||||
|
/>
|
||||||
</NavButton>
|
</NavButton>
|
||||||
{/if}
|
{/if}
|
||||||
<NavButton
|
<NavButton
|
||||||
@@ -148,11 +121,7 @@
|
|||||||
label={$t('nav.communities')}
|
label={$t('nav.communities')}
|
||||||
icon={GlobeAlt}
|
icon={GlobeAlt}
|
||||||
/>
|
/>
|
||||||
<NavButton
|
<NavButton href="/search" label={$t('nav.search')} icon={MagnifyingGlass} />
|
||||||
on:click={() => (searching = true)}
|
|
||||||
label={$t('nav.search')}
|
|
||||||
icon={MagnifyingGlass}
|
|
||||||
/>
|
|
||||||
<Menu placement="top">
|
<Menu placement="top">
|
||||||
<NavButton
|
<NavButton
|
||||||
class="relative"
|
class="relative"
|
||||||
|
|||||||
@@ -58,19 +58,19 @@
|
|||||||
|
|
||||||
<Menu {...$$restProps}>
|
<Menu {...$$restProps}>
|
||||||
<button
|
<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
|
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')}
|
title={$t('profile.profile')}
|
||||||
slot="target"
|
slot="target"
|
||||||
>
|
>
|
||||||
{#if $profile?.user}
|
{#if $profile?.user}
|
||||||
<div
|
<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
|
<Avatar
|
||||||
url={$profile.user.local_user_view.person.avatar}
|
url={$profile.user.local_user_view.person.avatar}
|
||||||
width={38}
|
width={36}
|
||||||
alt={$profile.user.local_user_view.person.name}
|
alt={$profile.user.local_user_view.person.name}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+3
-1
@@ -8,9 +8,11 @@ import { feature } from '$lib/version.js'
|
|||||||
import { client } from '$lib/lemmy.js'
|
import { client } from '$lib/lemmy.js'
|
||||||
import { site } from './lemmy'
|
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 =>
|
export const findClosestNumber = (numbers: number[], target: number): number =>
|
||||||
numbers.reduce((prev, curr) =>
|
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 = (
|
export const searchParam = (
|
||||||
|
|||||||
Reference in new issue
Block a user