mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 08:20:12 +00:00
feat: let developers and operators pick the sidebar mode from one menu (#12124)
* feat: let developers and operators pick the sidebar mode from one menu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore: describe the footer's single mode button Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep operators off the shared collapse preference and the narrow menu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: add expand-on-hover sidebar mode and a Cmd+\ rail toggle Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: anchor sidebar rows across modes and open folded sections in popovers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: rework sidebar sections as foldable cards and keep hover mode on resize Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: move sidebar mode menu to the hidden-mode handle and flash the mode button on change Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: close section popovers on outside click, retract to icons only, and show section chevrons beside icons Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: build folded sidebar section flyouts on the melt menu with real submenus Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: reveal the hidden sidebar from the keyboard, unclip nested submenus, close flyouts on any link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: put an unfolded section's chevron at the end of its row in the open sidebar Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: start an unfolded section's title at the row's left edge Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show section rows as title and chevron only in the open sidebar Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep a section title's line box the same folded and unfolded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: keep the folded AI sessions menu open for view options and edit sessions inside it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: show the hidden sidebar on keyboard focus of its handle instead of a menu item Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: put session batch actions in one sticky row and hold the sidebar open while selecting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: leave session selection alone on an Esc that closes search, and end it when a menu batch delete is cancelled Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: rename SidebarSection's children prop where the menu's own snippets shadow it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: render a section's title outside its fold control so folding cannot move it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: move the sidebar customization submenu from the settings menu to the sidebar mode menu Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: let the sidebar's Customize menu hide the AI chats section Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show the sidebar's Customize menu in the narrow panel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: rename icons only to collapsed, add one-click collapse, label home row Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: show the collapse button only in expanded and collapsed modes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep the home label until a click that leaves another page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
co-authored by
Claude Opus 5.5
Ruben Fiszel
parent
09082918a6
commit
0119bd93b7
@@ -8,15 +8,18 @@
|
||||
import type { Item } from '$lib/utils'
|
||||
import type { MenubarMenuElements, createDropdownMenu } from '@melt-ui/svelte'
|
||||
import { Tooltip } from './meltComponents'
|
||||
import DropdownSubmenuItem from './DropdownSubmenuItem.svelte'
|
||||
|
||||
interface Props {
|
||||
item: Item
|
||||
builders: ReturnType<typeof createDropdownMenu>['builders']
|
||||
meltItem: MenubarMenuElements['item']
|
||||
close?: (afterClose?: () => void) => void
|
||||
/** Classes merged onto the row that opens the submenu. */
|
||||
class?: string
|
||||
}
|
||||
|
||||
let { item, builders, meltItem, close }: Props = $props()
|
||||
let { item, builders, meltItem, close, class: className = '' }: Props = $props()
|
||||
|
||||
const {
|
||||
elements: { subTrigger, subMenu },
|
||||
@@ -33,11 +36,12 @@
|
||||
class={twMerge(
|
||||
'px-4 py-2 text-primary font-normal hover:bg-surface-hover cursor-pointer text-xs transition-colors w-full',
|
||||
'data-[highlighted]:bg-surface-hover',
|
||||
'flex flex-row gap-2 items-center rounded-sm'
|
||||
'flex flex-row gap-2 items-center rounded-sm',
|
||||
className
|
||||
)}
|
||||
>
|
||||
{#if item.icon}
|
||||
<item.icon size={14} color={item.iconColor} class="shrink-0" />
|
||||
<item.icon size={className ? 16 : 14} color={item.iconColor} class="shrink-0" />
|
||||
{/if}
|
||||
<p class="truncate grow min-w-0 whitespace-nowrap text-left">
|
||||
{item.displayName}
|
||||
@@ -51,23 +55,29 @@
|
||||
use:melt={$subMenu}
|
||||
class="z-[6000] bg-surface-tertiary dark:border {CustomSubmenu
|
||||
? ''
|
||||
: 'w-48 overflow-y-auto py-1'} origin-top-right rounded-lg shadow-lg focus:outline-none"
|
||||
: 'w-48 py-1'} origin-top-right rounded-lg shadow-lg focus:outline-none"
|
||||
>
|
||||
{#if CustomSubmenu}
|
||||
<CustomSubmenu {...item.customSubmenuProps} close={closeMenu} />
|
||||
{:else}
|
||||
{#each subItems as subItem}
|
||||
{#if subItem.separatorTop}
|
||||
<div class="my-1 border-t border-border-light"></div>
|
||||
{/if}
|
||||
{@render subMenuItem(subItem)}
|
||||
{/each}
|
||||
<!-- The scroll sits on this wrapper, not on the melt element: that element is the containing
|
||||
block of a nested submenu, which its overflow would clip. -->
|
||||
<div class="max-h-[inherit] overflow-y-auto">
|
||||
{#each subItems as subItem}
|
||||
{#if subItem.separatorTop}
|
||||
<div class="my-1 border-t border-border-light"></div>
|
||||
{/if}
|
||||
{@render subMenuItem(subItem)}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#snippet subMenuItem(subItem: Item)}
|
||||
{#if subItem.disabled && subItem.tooltip}
|
||||
{#if subItem.submenuItems || subItem.customSubmenu}
|
||||
<DropdownSubmenuItem item={subItem} {builders} {meltItem} {close} />
|
||||
{:else if subItem.disabled && subItem.tooltip}
|
||||
<!-- Wrapper carries the native `title`: the disabled button swallows the pointer events
|
||||
the ⓘ tooltip would need, and its `pointer-events-none` lets the hover reach here. -->
|
||||
<div title={subItem.tooltip} class="w-full">
|
||||
@@ -84,6 +94,7 @@
|
||||
href={subItem?.href}
|
||||
target={subItem?.hrefTarget}
|
||||
disabled={subItem?.disabled}
|
||||
keepOpen={subItem.keepOpen}
|
||||
class={twMerge(
|
||||
'px-4 py-2 text-primary font-normal hover:bg-surface-hover cursor-pointer text-xs transition-colors w-full',
|
||||
'data-[highlighted]:bg-surface-hover',
|
||||
@@ -94,7 +105,12 @@
|
||||
item={meltItem}
|
||||
>
|
||||
{#if subItem.icon}
|
||||
<subItem.icon size={14} color={subItem.iconColor} class="shrink-0" {...subItem.iconProps ?? {}} />
|
||||
<subItem.icon
|
||||
size={14}
|
||||
color={subItem.iconColor}
|
||||
class="shrink-0"
|
||||
{...subItem.iconProps ?? {}}
|
||||
/>
|
||||
{/if}
|
||||
<p
|
||||
title={subItem.disabled && subItem.tooltip ? undefined : subItem.displayName}
|
||||
|
||||
@@ -9,8 +9,11 @@ The row's height matches the sidebar's own header row, so the two read as one ba
|
||||
<script lang="ts">
|
||||
import { ChevronDown, PanelLeft } from 'lucide-svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import { BROWSER } from 'esm-env'
|
||||
import { navDetached } from './sidebar/navDetached.svelte'
|
||||
import { navHandleSlot } from './sidebar/navHandlePlacement.svelte'
|
||||
import ModeButtonFlash from './sidebar/ModeButtonFlash.svelte'
|
||||
import NavBreadcrumb from './NavBreadcrumb.svelte'
|
||||
import BreadcrumbNavPicker from './BreadcrumbNavPicker.svelte'
|
||||
import { BAR_HEIGHT, pageHeader, PHONE_BAR } from './pageHeaderRegistry.svelte'
|
||||
@@ -31,6 +34,39 @@ The row's height matches the sidebar's own header row, so the two read as one ba
|
||||
panelled?: boolean
|
||||
} = $props()
|
||||
|
||||
// Read once, as the layout does: whether the card slides in on hover or waits for a tap.
|
||||
const hoverPointer = BROWSER && window.matchMedia('(hover: hover)').matches
|
||||
// Below the layout's 768px breakpoint the sidebar is a drawer whatever the mode, so the handle
|
||||
// has no mode to offer there.
|
||||
let innerWidth = $state(BROWSER ? window.innerWidth : 0)
|
||||
|
||||
// The keyboard's way to the hidden sidebar: focusing the handle shows the card as hovering it
|
||||
// does, and Tab from the handle goes into the card, which comes later in no tab order. Focus
|
||||
// coming back from the card (Esc) or from the handle's menu does not show it again.
|
||||
function cameFromCardOrMenu(e: FocusEvent): boolean {
|
||||
return !!(e.relatedTarget as Element | null)?.closest('[data-nav-card], [role="menu"]')
|
||||
}
|
||||
// A closing menu is gone before focus returns, so that return carries no related target.
|
||||
let focusInHandleMenu = false
|
||||
function revealOnKeyboardFocus(e: FocusEvent) {
|
||||
const fromMenu = focusInHandleMenu
|
||||
focusInHandleMenu = false
|
||||
if (!(e.target as Element).matches(':focus-visible') || fromMenu || cameFromCardOrMenu(e))
|
||||
return
|
||||
navHandleSlot.open()
|
||||
}
|
||||
function hideOnBlur(e: FocusEvent) {
|
||||
if ((e.relatedTarget as Element | null)?.closest('[role="menu"]')) focusInHandleMenu = true
|
||||
if (!cameFromCardOrMenu(e)) navHandleSlot.scheduleClose()
|
||||
}
|
||||
function tabIntoCard(e: KeyboardEvent) {
|
||||
if (e.key !== 'Tab' || e.shiftKey) return
|
||||
const link = document.querySelector<HTMLElement>('[data-nav-card] a[href]')
|
||||
if (!link || link.closest('[inert]')) return
|
||||
e.preventDefault()
|
||||
if (!navHandleSlot.pinned) navHandleSlot.toggle()
|
||||
link.focus()
|
||||
}
|
||||
const content = $derived(pageHeader.content)
|
||||
const actions = $derived(pageHeader.actions)
|
||||
const hasActions = $derived(actions.length > 0)
|
||||
@@ -167,7 +203,7 @@ The row's height matches the sidebar's own header row, so the two read as one ba
|
||||
const showEdge = $derived(separator === 'always' || (separator === 'onScroll' && scrolledUnder))
|
||||
</script>
|
||||
|
||||
<svelte:window onscrollcapture={onScrollCapture} />
|
||||
<svelte:window onscrollcapture={onScrollCapture} bind:innerWidth />
|
||||
|
||||
<!-- The band owns its bottom edge, so a page never draws a second one under it. A page says which
|
||||
rule it wants (see `separator` in the registry); the default shows the edge only while
|
||||
@@ -200,31 +236,55 @@ The row's height matches the sidebar's own header row, so the two read as one ba
|
||||
)}
|
||||
>
|
||||
{#if (navDetached.val || panelled) && !navHidden}
|
||||
<!-- Reveals the hidden sidebar, and only that: the card follows the pointer, holding while it
|
||||
is on the handle, on the card, or in a menu either opened, and sliding back out when it
|
||||
leaves. A click or tap pins it instead, until another one here, a press on the page or Esc
|
||||
puts it back. Attaching
|
||||
it for good belongs to the toggle in the sidebar's own footer, where detaching it
|
||||
happened. Docked, the sidebar speaks for itself and nothing leads the bar. -->
|
||||
<!-- Reveals the hidden sidebar: the card follows the pointer, holding while it is on the
|
||||
handle, on the card, or in a menu either opened, and sliding back out when it leaves. A tap
|
||||
pins it instead, until another one here, a press on the page or Esc puts it back. Docked,
|
||||
the sidebar speaks for itself and nothing leads the bar. -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
data-nav-handle
|
||||
class="relative"
|
||||
bind:clientWidth={handleWidth}
|
||||
onmouseenter={() => navHandleSlot.open()}
|
||||
onmouseleave={() => navHandleSlot.scheduleClose()}
|
||||
onfocusin={revealOnKeyboardFocus}
|
||||
onfocusout={hideOnBlur}
|
||||
onkeydown={tabIntoCard}
|
||||
>
|
||||
<ModeButtonFlash />
|
||||
<!-- No tooltip: hovering here already slides the sidebar in, which says what the button
|
||||
does better than a label popping up over it. -->
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
iconOnly
|
||||
startIcon={{ icon: PanelLeft }}
|
||||
aria-label="Show sidebar"
|
||||
selected={navHandleSlot.pinned}
|
||||
aria-pressed={navHandleSlot.pinned}
|
||||
onclick={() => navHandleSlot.toggle()}
|
||||
/>
|
||||
does better than a label popping up over it. Where hover does that, a click picks the
|
||||
sidebar's mode, as the card has no footer to hold that menu; a touch screen taps to pin
|
||||
the card instead. -->
|
||||
{#if navDetached.val && hoverPointer && innerWidth >= 768 && navHandleSlot.modeItems}
|
||||
<DropdownV2
|
||||
placement="bottom-start"
|
||||
fixedHeight={false}
|
||||
items={() => navHandleSlot.modeItems ?? []}
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<Button
|
||||
nonCaptureEvent
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
iconOnly
|
||||
startIcon={{ icon: PanelLeft }}
|
||||
aria-label="Sidebar mode"
|
||||
/>
|
||||
{/snippet}
|
||||
</DropdownV2>
|
||||
{:else}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
iconOnly
|
||||
startIcon={{ icon: PanelLeft }}
|
||||
aria-label="Show sidebar"
|
||||
selected={navHandleSlot.pinned}
|
||||
aria-pressed={navHandleSlot.pinned}
|
||||
onclick={() => navHandleSlot.toggle()}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
// Open on hover without pinning, so the menu closes again once the pointer leaves.
|
||||
// A click then pins it open until a click outside or on the trigger.
|
||||
openOnHover?: boolean
|
||||
// A click inside the hover-opened content pins it too, for content that changes size
|
||||
// under the pointer: a menu that grows near the window's edge moves, and the pointer
|
||||
// it leaves behind would close it.
|
||||
pinOnClick?: boolean
|
||||
// Grace period before a hover-opened menu closes, so the pointer can travel from
|
||||
// the trigger to the content.
|
||||
debounceDelay?: number
|
||||
@@ -68,6 +72,7 @@
|
||||
renderContent = false,
|
||||
submenuSafe = false,
|
||||
openOnHover = false,
|
||||
pinOnClick = false,
|
||||
debounceDelay = 150,
|
||||
class: classNames = '',
|
||||
closeFocus = undefined,
|
||||
@@ -233,6 +238,12 @@
|
||||
data-menu
|
||||
onmouseenter={cancelPendingClose}
|
||||
onmouseleave={scheduleClose}
|
||||
onclickcapture={() => {
|
||||
if (openOnHover && pinOnClick && open) {
|
||||
cancelPendingClose()
|
||||
pinned = true
|
||||
}
|
||||
}}
|
||||
transition:placementFly={{ duration: 100, placement }}
|
||||
style={contentStyle}
|
||||
class={twMerge(
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
import { melt } from '@melt-ui/svelte'
|
||||
import type { MenubarMenuElements } from '@melt-ui/svelte'
|
||||
import { triggerableByAI } from '$lib/actions/triggerableByAI.svelte'
|
||||
import { onCustomEvent } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
interface Props {
|
||||
/** The menu stays open after a click on this item, for a setting whose effect shows in it. */
|
||||
keepOpen?: boolean
|
||||
aiId?: string | undefined
|
||||
aiDescription?: string | undefined
|
||||
href?: string | undefined
|
||||
@@ -19,6 +22,7 @@
|
||||
}
|
||||
|
||||
let {
|
||||
keepOpen = false,
|
||||
aiId = undefined,
|
||||
aiDescription = undefined,
|
||||
href = undefined,
|
||||
@@ -66,6 +70,13 @@
|
||||
bind:this={buttonRef}
|
||||
onclick={onClick}
|
||||
use:melt={$item}
|
||||
use:onCustomEvent={{
|
||||
event: 'm-click',
|
||||
// Cancelling melt's own click event skips its close; the click itself still runs.
|
||||
handler: (e: Event) => {
|
||||
if (keepOpen) e.preventDefault()
|
||||
}
|
||||
}}
|
||||
use:triggerableByAI={{
|
||||
id: aiId,
|
||||
description: aiDescription,
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte'
|
||||
import { melt } from '@melt-ui/svelte'
|
||||
import type { MenubarMenuBuilders } from '@melt-ui/svelte'
|
||||
import { Check, ChevronRight, Filter } from 'lucide-svelte'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import Toggle from '$lib/components/Toggle.svelte'
|
||||
import { GROUP_BY_OPTIONS, LAST_ACTIVITY_OPTIONS, type GroupBy } from './sessionFilters'
|
||||
|
||||
interface Props {
|
||||
// Submenu builders from the enclosing melt Menu — createSubmenu must be
|
||||
// called against this specific menu instance (same pattern as DropdownSubmenuItem).
|
||||
builders: MenubarMenuBuilders
|
||||
showArchived: boolean
|
||||
archivedCount: number
|
||||
lastActivityDays: number
|
||||
groupBy: GroupBy
|
||||
}
|
||||
|
||||
let {
|
||||
builders,
|
||||
showArchived = $bindable(),
|
||||
archivedCount,
|
||||
lastActivityDays = $bindable(),
|
||||
groupBy = $bindable()
|
||||
}: Props = $props()
|
||||
|
||||
const {
|
||||
elements: { subTrigger, subMenu },
|
||||
states: { subOpen }
|
||||
} = untrack(() => builders).createSubmenu()
|
||||
|
||||
// Count of active (non-default) filters, surfaced as a subtle badge on the
|
||||
// trigger so an applied filter is visible without opening the submenu.
|
||||
// Grouping is left out: it reorders the list rather than hiding anything.
|
||||
let activeCount = $derived((showArchived ? 1 : 0) + (lastActivityDays > 0 ? 1 : 0))
|
||||
|
||||
const optionRow = twMerge(
|
||||
'px-3 py-1.5 w-full text-left text-xs font-normal text-secondary',
|
||||
'flex flex-row items-center gap-2 rounded-sm hover:bg-surface-hover hover:text-primary'
|
||||
)
|
||||
</script>
|
||||
|
||||
<button
|
||||
use:melt={$subTrigger}
|
||||
class={twMerge(
|
||||
'px-3 py-1.5 w-full text-left text-xs font-normal text-secondary',
|
||||
'flex flex-row items-center gap-2 rounded-sm',
|
||||
'data-[highlighted]:bg-surface-hover data-[highlighted]:text-primary'
|
||||
)}
|
||||
>
|
||||
<Filter size={14} class="shrink-0 text-tertiary" />
|
||||
<span class="grow">Filter</span>
|
||||
{#if activeCount > 0}
|
||||
<span class="text-2xs text-tertiary tabular-nums">{activeCount}</span>
|
||||
{/if}
|
||||
<ChevronRight size={14} class="shrink-0 text-tertiary" />
|
||||
</button>
|
||||
|
||||
{#if $subOpen}
|
||||
<div
|
||||
use:melt={$subMenu}
|
||||
class="z-[6000] w-48 bg-surface dark:border rounded-md shadow-md focus:outline-none py-1"
|
||||
>
|
||||
<!-- Rendered as plain content (not MenuItems) so picking a filter keeps the
|
||||
submenu open instead of selecting-and-closing the whole menu. -->
|
||||
<div class="px-3 py-1.5 flex flex-col gap-0.5">
|
||||
<Toggle bind:checked={showArchived} size="xs" options={{ right: 'Show archived' }} />
|
||||
{#if archivedCount > 0}
|
||||
<span class="text-2xs text-tertiary pl-1">
|
||||
{archivedCount} archived session{archivedCount === 1 ? '' : 's'}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="my-1 border-t border-border-light"></div>
|
||||
<div class="px-3 pb-0.5 text-3xs text-tertiary">Last activity</div>
|
||||
{#each LAST_ACTIVITY_OPTIONS as option (option.days)}
|
||||
<button type="button" class={optionRow} onclick={() => (lastActivityDays = option.days)}>
|
||||
<span class="grow truncate">{option.label}</span>
|
||||
{#if lastActivityDays === option.days}
|
||||
<Check size={14} class="shrink-0 text-primary" />
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
<div class="my-1 border-t border-border-light"></div>
|
||||
<div class="px-3 pb-0.5 text-3xs text-tertiary">Group by</div>
|
||||
{#each GROUP_BY_OPTIONS as option (option.value)}
|
||||
<button type="button" class={optionRow} onclick={() => (groupBy = option.value)}>
|
||||
<span class="grow truncate">{option.label}</span>
|
||||
{#if groupBy === option.value}
|
||||
<Check size={14} class="shrink-0 text-primary" />
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,9 @@
|
||||
icon={KeyRound}
|
||||
iconClasses="text-accent"
|
||||
labelClass="text-accent font-semibold"
|
||||
buttonClass="border border-border-selected/50 bg-surface-accent-selected hover:bg-surface-accent-selected hover:border-border-selected"
|
||||
buttonClass="border border-border-selected/50 bg-surface-accent-selected hover:bg-surface-accent-selected hover:border-border-selected {isCollapsed
|
||||
? 'h-10'
|
||||
: ''}"
|
||||
{isCollapsed}
|
||||
stopPropagationOnClick
|
||||
on:click={() => (accountSetup.open = true)}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { resource } from 'runed'
|
||||
import { slide } from 'svelte/transition'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { Bot } from 'lucide-svelte'
|
||||
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
|
||||
import { Bot, MessagesSquare } from 'lucide-svelte'
|
||||
import SidebarSection from './SidebarSection.svelte'
|
||||
import { page } from '$app/state'
|
||||
import { afterNavigate } from '$app/navigation'
|
||||
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
|
||||
@@ -24,11 +23,11 @@
|
||||
)
|
||||
|
||||
// Tagged with its workspace: responses are not ordered, and a late one from the workspace
|
||||
// just left must not show here. Not read on the collapsed rail, which shows no chats.
|
||||
// just left must not show here.
|
||||
const listing = resource(
|
||||
() => [$workspaceStore, isCollapsed] as const,
|
||||
async ([ws, collapsed]) => {
|
||||
if (!ws || collapsed) return undefined
|
||||
() => $workspaceStore,
|
||||
async (ws) => {
|
||||
if (!ws) return undefined
|
||||
const rows = await FlowConversationsService.listFlowConversations({
|
||||
workspace: ws,
|
||||
perPage: 30,
|
||||
@@ -60,17 +59,18 @@
|
||||
const openId = $derived(page.url.searchParams.get('conversation'))
|
||||
</script>
|
||||
|
||||
{#if !isCollapsed && rows.length > 0}
|
||||
<div class="flex flex-col gap-1">
|
||||
<SidebarSectionHeader
|
||||
title="AI chats"
|
||||
collapsed={sectionCollapsed.val}
|
||||
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
|
||||
/>
|
||||
{#if !sectionCollapsed.val}
|
||||
{#if rows.length > 0}
|
||||
<SidebarSection
|
||||
title="AI chats"
|
||||
icon={MessagesSquare}
|
||||
folded={sectionCollapsed.val}
|
||||
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
|
||||
{isCollapsed}
|
||||
>
|
||||
{#snippet children(inPopover)}
|
||||
{@const rail = isCollapsed && !inPopover}
|
||||
<div
|
||||
transition:slide={{ duration: 180 }}
|
||||
class="flex flex-col gap-0.5 max-h-[40vh] overflow-y-auto"
|
||||
class="flex flex-col gap-0.5 max-h-[40vh] overflow-y-auto {rail ? 'scrollbar-hidden' : ''}"
|
||||
>
|
||||
{#each rows as c (c.id)}
|
||||
{@const t = target(c)}
|
||||
@@ -79,7 +79,9 @@
|
||||
href={t.href}
|
||||
title="{t.agent ? 'Agent' : 'Flow'} {t.path}"
|
||||
class={twMerge(
|
||||
'flex flex-row items-center gap-2 px-2 py-1 rounded text-xs font-normal min-w-0',
|
||||
// shrink-0: in the capped list a row would otherwise shrink to its content,
|
||||
// which is shorter in the rail, where it has no label.
|
||||
'flex flex-row items-center gap-2 px-2 h-6 shrink-0 rounded text-xs font-normal min-w-0',
|
||||
selected
|
||||
? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText)
|
||||
: 'text-secondary hover:bg-surface-hover'
|
||||
@@ -90,10 +92,10 @@
|
||||
{:else}
|
||||
<BarsStaggered size={14} class="shrink-0 text-teal-500" />
|
||||
{/if}
|
||||
<span class="truncate">{c.title || 'Untitled chat'}</span>
|
||||
<span class={rail ? 'sr-only' : 'truncate'}>{c.title || 'Untitled chat'}</span>
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
</SidebarSection>
|
||||
{/if}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<!--
|
||||
@component
|
||||
The starred items as a sidebar section, turned on from "Customize sidebar" in the settings menu.
|
||||
Hidden in the collapsed rail, like the AI chats.
|
||||
The starred items as a sidebar section, turned on from Customize in the sidebar menu.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { slide } from 'svelte/transition'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { Bot, CodeXml, LayoutDashboard, Table2, Trash2 } from 'lucide-svelte'
|
||||
import { Bot, CodeXml, LayoutDashboard, Star, Table2, Trash2 } from 'lucide-svelte'
|
||||
import { page } from '$app/state'
|
||||
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import { globalDbManagerDrawer, workspaceStore } from '$lib/stores'
|
||||
import { parseDbInputFromAssetSyntax } from '$lib/utils'
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
|
||||
import SidebarSection from './SidebarSection.svelte'
|
||||
import { favoriteManager } from './FavoriteMenu.svelte'
|
||||
import { sidebarClasses } from './MenuButton.svelte'
|
||||
import { sidebarPrefs } from './sidebarPrefs.svelte'
|
||||
@@ -29,15 +27,17 @@ Hidden in the collapsed rail, like the AI chats.
|
||||
const loaded = $derived(favoriteManager.loadedFor === $workspaceStore)
|
||||
</script>
|
||||
|
||||
{#if sidebarPrefs.favorites.val && !isCollapsed && loaded}
|
||||
<div class="flex flex-col gap-1">
|
||||
<SidebarSectionHeader
|
||||
title="Favorites"
|
||||
collapsed={sectionCollapsed.val}
|
||||
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
|
||||
/>
|
||||
{#if !sectionCollapsed.val}
|
||||
<div transition:slide={{ duration: 180 }} class="flex flex-col gap-0.5">
|
||||
{#if sidebarPrefs.favorites.val && loaded}
|
||||
<SidebarSection
|
||||
title="Favorites"
|
||||
icon={Star}
|
||||
folded={sectionCollapsed.val}
|
||||
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
|
||||
{isCollapsed}
|
||||
>
|
||||
{#snippet children(inPopover)}
|
||||
{@const rail = isCollapsed && !inPopover}
|
||||
<div class="flex flex-col gap-0.5">
|
||||
{#each favoriteManager.current as favorite (`${favorite.kind}:${favorite.path}`)}
|
||||
{@const selected = favorite.href !== '#' && page.url.pathname === favorite.href}
|
||||
<div class="relative group/fav">
|
||||
@@ -52,7 +52,8 @@ Hidden in the collapsed rail, like the AI chats.
|
||||
if (dbInput) globalDbManagerDrawer.val?.openDrawer(dbInput)
|
||||
}}
|
||||
class={twMerge(
|
||||
'flex flex-row items-center gap-2 px-2 py-1 pr-7 rounded text-xs font-normal min-w-0',
|
||||
'flex flex-row items-center gap-2 px-2 h-6 rounded text-xs font-normal min-w-0',
|
||||
rail ? '' : 'pr-7',
|
||||
selected
|
||||
? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText)
|
||||
: 'text-secondary hover:bg-surface-hover'
|
||||
@@ -70,10 +71,13 @@ Hidden in the collapsed rail, like the AI chats.
|
||||
{:else}
|
||||
<Table2 size={14} class="shrink-0 text-primary" />
|
||||
{/if}
|
||||
<span class="truncate">{favorite.label}</span>
|
||||
<span class={rail ? 'sr-only' : 'truncate'}>{favorite.label}</span>
|
||||
</a>
|
||||
<div
|
||||
class="absolute right-0.5 top-0 h-full flex items-center opacity-0 group-hover/fav:opacity-100 has-[[aria-expanded=true]]:opacity-100 transition-opacity"
|
||||
class={twMerge(
|
||||
'absolute right-0.5 top-0 h-full flex items-center opacity-0 group-hover/fav:opacity-100 has-[[aria-expanded=true]]:opacity-100 transition-opacity',
|
||||
rail ? 'hidden' : ''
|
||||
)}
|
||||
>
|
||||
<DropdownV2
|
||||
items={[
|
||||
@@ -89,9 +93,17 @@ Hidden in the collapsed rail, like the AI chats.
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="px-2 py-1 text-2xs text-hint">Star an item to list it here.</p>
|
||||
<!-- Kept, unread, in the rail: the rows under it stay where the open sidebar has them. -->
|
||||
<p
|
||||
class={twMerge(
|
||||
'px-2 h-6 flex items-center text-2xs text-hint',
|
||||
rail ? 'invisible' : ''
|
||||
)}
|
||||
>
|
||||
Star an item to list it here.
|
||||
</p>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
</SidebarSection>
|
||||
{/if}
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
notificationsCount?: number
|
||||
color?: string | null
|
||||
trigger?: MenubarMenuElements['trigger'] | undefined
|
||||
/** Makes the button an item of an enclosing melt menu, in place of a trigger. */
|
||||
item?: MenubarMenuElements['item'] | undefined
|
||||
href?: string | undefined
|
||||
/** Applied to the button AND to the label, so text sizing reaches the label text. */
|
||||
class?: string | undefined
|
||||
@@ -74,6 +76,7 @@
|
||||
notificationsCount = 0,
|
||||
color = null,
|
||||
trigger = undefined,
|
||||
item = undefined,
|
||||
href = undefined,
|
||||
class: classNames = undefined,
|
||||
buttonClass = undefined,
|
||||
@@ -86,6 +89,7 @@
|
||||
}: Props = $props()
|
||||
|
||||
let buttonRef: HTMLButtonElement | HTMLAnchorElement | undefined = $state(undefined)
|
||||
const meltElement = $derived(trigger ?? item)
|
||||
|
||||
let dispatch = createEventDispatcher()
|
||||
|
||||
@@ -126,16 +130,15 @@
|
||||
compact ? 'w-auto' : 'w-full',
|
||||
sidebarClasses.hoverBg,
|
||||
'transition-all relative',
|
||||
// Compact rows sit in the page header and keep its height; the nav's are 30px, and
|
||||
// square on the collapsed rail.
|
||||
sublabel ? 'h-10' : compact || isCollapsed ? 'h-8' : 'h-[30px]',
|
||||
// One height in the rail and the open sidebar, so a row keeps its place in every mode.
|
||||
sublabel ? 'h-10' : 'h-[30px]',
|
||||
classNames,
|
||||
buttonClass
|
||||
)}
|
||||
use:conditionalMelt={trigger}
|
||||
use:conditionalMelt={meltElement}
|
||||
aria-label={ariaLabel ?? label}
|
||||
title={isCollapsed || disableTitle ? undefined : label}
|
||||
{...$trigger}
|
||||
{...$meltElement}
|
||||
>
|
||||
{#if icon}
|
||||
{@const SvelteComponent = icon}
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
aiId?: string | undefined
|
||||
aiDescription?: string | undefined
|
||||
label: string
|
||||
// Native tooltip in every mode, for a row whose label does not say where it goes.
|
||||
hint?: string | undefined
|
||||
href: string
|
||||
icon?: any | undefined
|
||||
iconProps?: Record<string, unknown>
|
||||
isCollapsed: boolean
|
||||
disabled?: boolean
|
||||
lightMode?: boolean
|
||||
@@ -26,8 +29,10 @@
|
||||
aiId = undefined,
|
||||
aiDescription = undefined,
|
||||
label,
|
||||
hint = undefined,
|
||||
href,
|
||||
icon = undefined,
|
||||
iconProps = {},
|
||||
isCollapsed,
|
||||
disabled = false,
|
||||
lightMode = false,
|
||||
@@ -48,7 +53,12 @@
|
||||
</script>
|
||||
|
||||
{#if !disabled}
|
||||
<Popover appearTimeout={0} disappearTimeout={0} class="w-full" disablePopup={!isCollapsed}>
|
||||
<Popover
|
||||
appearTimeout={0}
|
||||
disappearTimeout={0}
|
||||
class="w-full"
|
||||
disablePopup={!isCollapsed || !!hint}
|
||||
>
|
||||
<a
|
||||
{href}
|
||||
use:triggerableByAI={{
|
||||
@@ -61,8 +71,8 @@
|
||||
{onclick}
|
||||
class={twMerge(
|
||||
'group flex items-center px-2 py-1 text-sm font-light rounded-md gap-2',
|
||||
// Collapsed, the rail's rows are squares, as its footer buttons are.
|
||||
isCollapsed ? 'h-8' : 'h-[30px]',
|
||||
// One height in the rail and the open sidebar, so a row keeps its place in every mode.
|
||||
'h-[30px]',
|
||||
isSelected
|
||||
? sidebarClasses.selectedBg
|
||||
: item
|
||||
@@ -77,13 +87,14 @@
|
||||
data-light-mode={lightMode}
|
||||
target={href.includes('http') ? '_blank' : null}
|
||||
aria-label={label}
|
||||
title={isCollapsed ? undefined : label}
|
||||
title={hint ?? (isCollapsed ? undefined : label)}
|
||||
use:conditionalMelt={item}
|
||||
{...$item}
|
||||
>
|
||||
{#if icon}
|
||||
{@const SvelteComponent = icon}
|
||||
<SvelteComponent
|
||||
{...iconProps}
|
||||
size={16}
|
||||
class={twMerge(
|
||||
'flex-shrink-0 transition-all',
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { navHandleSlot } from './navHandlePlacement.svelte'
|
||||
</script>
|
||||
|
||||
<!-- Placed in a `relative` box around the sidebar mode button. `opacity-0` at rest: the keyframes
|
||||
carry no fill mode, so the element returns to its own opacity once the pulse ends. -->
|
||||
{#if navHandleSlot.modeFlash}
|
||||
{#key navHandleSlot.modeFlash}
|
||||
<span
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute -inset-1 rounded-lg bg-blue-500/30 opacity-0 motion-safe:animate-[fade-out_1.2s_ease-in-out_0.2s]"
|
||||
></span>
|
||||
{/key}
|
||||
{/if}
|
||||
@@ -20,14 +20,11 @@
|
||||
Trash2,
|
||||
KeyRound,
|
||||
GraduationCap,
|
||||
PanelLeft,
|
||||
Star,
|
||||
FolderOpen,
|
||||
Users,
|
||||
ShieldCheck
|
||||
} from 'lucide-svelte'
|
||||
import AccessDrawer from '../AccessDrawer.svelte'
|
||||
import { sidebarPrefs } from './sidebarPrefs.svelte'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { type Item } from '$lib/utils'
|
||||
import { logout } from '$lib/logoutKit'
|
||||
@@ -215,18 +212,6 @@
|
||||
icon: darkMode ? Sun : Moon,
|
||||
action: () => toggleDarkMode()
|
||||
},
|
||||
{
|
||||
displayName: 'Customize sidebar',
|
||||
icon: PanelLeft,
|
||||
submenuItems: [
|
||||
{
|
||||
displayName: 'Favorites section',
|
||||
icon: Star,
|
||||
toggle: sidebarPrefs.favorites.val,
|
||||
action: () => (sidebarPrefs.favorites.val = !sidebarPrefs.favorites.val)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// The email is the label itself; the crown icon carries the admin role.
|
||||
displayName: $userStore?.non_member
|
||||
@@ -320,7 +305,10 @@
|
||||
{/snippet}
|
||||
|
||||
<!-- Workers and Logs are full pages (not account/instance actions), so they sit
|
||||
as plain links above the Settings dropdown rather than inside it. -->
|
||||
as plain links above the Settings dropdown rather than inside it.
|
||||
The dropdown triggers below are anchored left and clip their row: DropdownV2 justifies its
|
||||
button's content to the end, and Firefox repaints a button whose content overflows it, which
|
||||
a label showing while the sidebar is still narrow would do on every frame of the expand. -->
|
||||
<div class="flex flex-col gap-0.5 mb-0.5">
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
@@ -336,7 +324,7 @@
|
||||
<DropdownV2
|
||||
items={logsItems}
|
||||
placement="top-start"
|
||||
class="w-full"
|
||||
class="w-full min-w-0 justify-start"
|
||||
fixedHeight={false}
|
||||
enableFlyTransition
|
||||
aiId="sidebar-menu-link-logs"
|
||||
@@ -344,13 +332,11 @@
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<span
|
||||
class="relative flex items-center gap-2 w-full px-2 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
|
||||
? 'h-8 justify-center'
|
||||
: 'h-[30px]'}"
|
||||
class="relative flex flex-1 min-w-0 items-center gap-2 w-full h-[30px] px-2 rounded-md text-secondary text-xs font-normal whitespace-nowrap overflow-hidden hover:bg-surface-hover cursor-pointer"
|
||||
>
|
||||
<Logs size={16} />
|
||||
<Logs size={16} class="shrink-0 text-hint" />
|
||||
{#if !isCollapsed}
|
||||
Logs
|
||||
<span class="truncate">Logs</span>
|
||||
<span class="ml-auto flex items-center gap-2">
|
||||
{#if numUnacknowledgedCriticalAlerts > 0}
|
||||
<SideBarNotification notificationCount={numUnacknowledgedCriticalAlerts} />
|
||||
@@ -387,20 +373,18 @@
|
||||
<DropdownV2
|
||||
{items}
|
||||
placement="top-start"
|
||||
class="w-full"
|
||||
class="w-full min-w-0 justify-start"
|
||||
fixedHeight={false}
|
||||
enableFlyTransition
|
||||
on:close={onChangelogsOpened}
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<span
|
||||
class="relative flex items-center gap-2 w-full px-2 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
|
||||
? 'h-8 justify-center'
|
||||
: 'h-[30px]'}"
|
||||
class="relative flex flex-1 min-w-0 items-center gap-2 w-full h-[30px] px-2 rounded-md text-secondary text-xs font-normal whitespace-nowrap overflow-hidden hover:bg-surface-hover cursor-pointer"
|
||||
>
|
||||
<Settings size={16} />
|
||||
<Settings size={16} class="shrink-0 text-hint" />
|
||||
{#if !isCollapsed}
|
||||
Settings
|
||||
<span class="truncate">Settings</span>
|
||||
<ChevronDown size={14} class="ml-auto flex-shrink-0 text-tertiary" />
|
||||
{/if}
|
||||
{#if hasNewChangelogs}
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
Unplug,
|
||||
AlertCircle,
|
||||
Database,
|
||||
MailIcon
|
||||
MailIcon,
|
||||
Zap
|
||||
} from 'lucide-svelte'
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
import { slide } from 'svelte/transition'
|
||||
import UserMenu from './UserMenu.svelte'
|
||||
import DiscordIcon from '../icons/brands/Discord.svelte'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
@@ -49,15 +49,10 @@
|
||||
getServiceIcon
|
||||
} from '../triggers/native/utils'
|
||||
import type { NativeServiceName } from '$lib/gen/types.gen'
|
||||
import {
|
||||
Menubar,
|
||||
Menu,
|
||||
MenuSingleItem,
|
||||
MenuItem,
|
||||
MeltButton
|
||||
} from '$lib/components/meltComponents'
|
||||
import { Menubar, Menu, MenuSingleItem, MenuItem } from '$lib/components/meltComponents'
|
||||
import MenuButton from './MenuButton.svelte'
|
||||
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
|
||||
import SidebarSection, { flyoutRowClass } from './SidebarSection.svelte'
|
||||
import DropdownSubmenuItem from '$lib/components/DropdownSubmenuItem.svelte'
|
||||
import GoogleCloudIcon from '../icons/triggers/GoogleCloudIcon.svelte'
|
||||
import AzureIcon from '../icons/triggers/AzureIcon.svelte'
|
||||
import type { VisibilityKey } from '$lib/roleCapabilities'
|
||||
@@ -479,14 +474,10 @@
|
||||
])
|
||||
</script>
|
||||
|
||||
<!-- Expanded, each section opens 10px under the one before, the gap the layout's scroll area puts
|
||||
between this nav and the sections after it; the collapsed rail keeps one pitch instead. -->
|
||||
<nav
|
||||
class={twMerge(
|
||||
'flex flex-col overflow-x-hidden scrollbar-hidden px-2 gap-2',
|
||||
isCollapsed ? 'md:pb-2' : ''
|
||||
)}
|
||||
>
|
||||
<!-- Each section opens 10px under the one before, the gap the layout's scroll area puts between
|
||||
this nav and the sections after it. The rail spaces them the same, so a row keeps its place
|
||||
in every mode. -->
|
||||
<nav class="flex flex-col overflow-x-hidden scrollbar-hidden px-2 gap-2">
|
||||
<div class={twMerge('flex flex-col')}>
|
||||
{#if showMain}
|
||||
<div class="space-y-0.5">
|
||||
@@ -498,45 +489,48 @@
|
||||
{#if showMain}
|
||||
{#if dataLinks.length > 0}
|
||||
<!-- 8px: the layout's 2px gap above this nav makes it 10 under Runs. -->
|
||||
<div class={isCollapsed ? '' : 'mt-2'}>
|
||||
<!-- Collapsed, no title row: the rail's icons keep one pitch across sections. -->
|
||||
{#if !isCollapsed}
|
||||
<SidebarSectionHeader
|
||||
title="Data"
|
||||
collapsed={dataSectionCollapsed.val}
|
||||
onToggle={() => (dataSectionCollapsed.val = !dataSectionCollapsed.val)}
|
||||
/>
|
||||
{/if}
|
||||
{#if isCollapsed || !dataSectionCollapsed.val}
|
||||
<div transition:slide={{ duration: 180 }} class="flex flex-col gap-0.5">
|
||||
{#each dataLinks as menuLink (menuLink.href)}
|
||||
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} />
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="mt-2">
|
||||
<SidebarSection
|
||||
title="Data"
|
||||
icon={Database}
|
||||
folded={dataSectionCollapsed.val}
|
||||
onToggle={() => (dataSectionCollapsed.val = !dataSectionCollapsed.val)}
|
||||
{isCollapsed}
|
||||
>
|
||||
{#snippet children(inPopover, menu)}
|
||||
<div class="flex flex-col gap-0.5">
|
||||
{#each dataLinks as menuLink (menuLink.href)}
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
{...menuLink}
|
||||
isCollapsed={isCollapsed && !inPopover}
|
||||
item={menu?.item}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
{/snippet}
|
||||
</SidebarSection>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#if showMain && showTriggersGroup}
|
||||
<!-- Expanded, the + sits at the right of the section's title row, as the AI sessions
|
||||
section's options do; the collapsed rail has no title row, so it ends the list. -->
|
||||
{#snippet addTriggerMenu(createMenu: any, inHeader: boolean)}
|
||||
<Menu {createMenu} usePointerDownOutside placement={inHeader ? 'bottom-end' : undefined}>
|
||||
{#snippet addTriggerMenu(createMenu: any, rail: boolean)}
|
||||
<Menu
|
||||
{createMenu}
|
||||
usePointerDownOutside
|
||||
placement={rail ? 'right-start' : 'bottom-start'}
|
||||
class="h-[30px]"
|
||||
>
|
||||
{#snippet triggr({ trigger })}
|
||||
<MeltButton
|
||||
<MenuButton
|
||||
aiId="sidebar-menu-link-add-trigger"
|
||||
aiDescription="Button to add a new trigger. Can be HTTP, WebSocket, Postgres, Kafka, NATS, SQS, GCP Pub/Sub, or MQTT"
|
||||
class={twMerge(
|
||||
inHeader
|
||||
? 'h-7 w-7 shrink-0 flex items-center justify-center rounded-md text-secondary hover:bg-surface-hover'
|
||||
: 'w-full text-secondary text-2xs flex flex-row gap-1 py-1 items-center px-2 hover:bg-surface-hover rounded',
|
||||
'data-[highlighted]:bg-surface-hover'
|
||||
)}
|
||||
title="Add trigger"
|
||||
meltElement={trigger}
|
||||
>
|
||||
<Plus size={14} />
|
||||
</MeltButton>
|
||||
icon={Plus}
|
||||
label="New trigger"
|
||||
isCollapsed={rail}
|
||||
buttonClass="data-[highlighted]:bg-surface-hover"
|
||||
{trigger}
|
||||
/>
|
||||
{/snippet}
|
||||
{#snippet children({ item })}
|
||||
{#each extraTriggerLinks as subItem (subItem.href ?? subItem.label)}
|
||||
@@ -559,37 +553,52 @@
|
||||
{/snippet}
|
||||
</Menu>
|
||||
{/snippet}
|
||||
<div class={isCollapsed ? 'mt-0.5' : 'mt-2.5'}>
|
||||
<!-- Collapsed, no title row: the rail's icons keep one pitch across sections. -->
|
||||
{#if !isCollapsed}
|
||||
<SidebarSectionHeader
|
||||
title="Triggers"
|
||||
collapsed={triggersCollapsed.val}
|
||||
onToggle={() => (triggersCollapsed.val = !triggersCollapsed.val)}
|
||||
actions={showAddTriggerMenu ? triggerHeaderActions : undefined}
|
||||
/>
|
||||
{#snippet triggerHeaderActions()}
|
||||
<Menubar>
|
||||
{#snippet children({ createMenu })}
|
||||
{@render addTriggerMenu(createMenu, true)}
|
||||
{/snippet}
|
||||
</Menubar>
|
||||
{/snippet}
|
||||
{/if}
|
||||
{#if isCollapsed || !triggersCollapsed.val}
|
||||
<div transition:slide={{ duration: 180 }}>
|
||||
<Menubar class="flex flex-col gap-0.5">
|
||||
{#snippet children({ createMenu })}
|
||||
{#each triggerMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
|
||||
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} />
|
||||
{/each}
|
||||
{#if showAddTriggerMenu && isCollapsed}
|
||||
{@render addTriggerMenu(createMenu, false)}
|
||||
<div class="mt-2.5">
|
||||
<SidebarSection
|
||||
title="Triggers"
|
||||
icon={Zap}
|
||||
folded={triggersCollapsed.val}
|
||||
onToggle={() => (triggersCollapsed.val = !triggersCollapsed.val)}
|
||||
{isCollapsed}
|
||||
>
|
||||
{#snippet children(inPopover, menu)}
|
||||
<div class="flex flex-col gap-0.5">
|
||||
{#if showAddTriggerMenu}
|
||||
{#if menu}
|
||||
<DropdownSubmenuItem
|
||||
item={{
|
||||
displayName: 'New trigger',
|
||||
icon: Plus,
|
||||
submenuItems: extraTriggerLinks.map((l) => ({
|
||||
displayName: l.label,
|
||||
icon: l.icon,
|
||||
href: l.disabled ? undefined : l.href,
|
||||
disabled: l.disabled
|
||||
}))
|
||||
}}
|
||||
builders={menu.builders}
|
||||
meltItem={menu.item}
|
||||
class={flyoutRowClass}
|
||||
/>
|
||||
{:else}
|
||||
<Menubar class="w-full">
|
||||
{#snippet children({ createMenu })}
|
||||
{@render addTriggerMenu(createMenu, isCollapsed)}
|
||||
{/snippet}
|
||||
</Menubar>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Menubar>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
{#each triggerMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
{...menuLink}
|
||||
isCollapsed={isCollapsed && !inPopover}
|
||||
item={menu?.item}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
{/snippet}
|
||||
</SidebarSection>
|
||||
</div>
|
||||
{/if}
|
||||
{#if showSecondary}
|
||||
|
||||
@@ -4,12 +4,16 @@
|
||||
let {
|
||||
color,
|
||||
class: className = '',
|
||||
hideScrollbar = false,
|
||||
children
|
||||
}: {
|
||||
// Rail background, so the overflow fades blend into it rather than sitting
|
||||
// as visible bars.
|
||||
color: string
|
||||
class?: string
|
||||
// Even a transparent scrollbar takes its width where the system shows scrollbars,
|
||||
// which narrows rows in the icon rail and leaves their highlight off-center.
|
||||
hideScrollbar?: boolean
|
||||
children: Snippet
|
||||
} = $props()
|
||||
|
||||
@@ -41,7 +45,9 @@
|
||||
<div
|
||||
bind:this={viewport}
|
||||
onscroll={measure}
|
||||
class="sidebar-scroll h-full overflow-y-auto overflow-x-hidden scrollbar-subtle flex flex-col gap-2.5"
|
||||
class="sidebar-scroll h-full overflow-y-auto overflow-x-hidden {hideScrollbar
|
||||
? 'scrollbar-hidden'
|
||||
: 'scrollbar-subtle'} flex flex-col gap-2.5"
|
||||
>
|
||||
{@render children()}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
<!--
|
||||
@component
|
||||
A foldable sidebar section whose rows keep their places in every sidebar mode. Its title row is the
|
||||
same row folded or not, so folding moves nothing but the items under it. The row behaves the same in
|
||||
every mode: a click folds or unfolds it, and hovering a folded row shows its items in a menu.
|
||||
A fold is a layout the reader keeps, so reaching a folded section's items never unfolds it.
|
||||
-->
|
||||
<script module lang="ts">
|
||||
import type { MenubarMenuElements, createDropdownMenu } from '@melt-ui/svelte'
|
||||
|
||||
/** The folded section's menu, for rows that should be its items. */
|
||||
export type SectionMenu = {
|
||||
item: MenubarMenuElements['item']
|
||||
builders: ReturnType<typeof createDropdownMenu>['builders']
|
||||
}
|
||||
export type SectionActionsArgs = { inPopover: boolean; menu?: SectionMenu }
|
||||
/** A row of the folded section's menu that is not a link, styled as its links are. */
|
||||
export const flyoutRowClass =
|
||||
'h-[30px] px-2 py-0 rounded-md text-xs font-normal text-secondary [&>svg:first-child]:text-hint'
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte'
|
||||
import { slide } from 'svelte/transition'
|
||||
import { ChevronDown, ChevronRight } from 'lucide-svelte'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { Button } from '$lib/components/common'
|
||||
import Menubar from '$lib/components/meltComponents/Menubar.svelte'
|
||||
import Menu from '$lib/components/meltComponents/Menu.svelte'
|
||||
import MeltButton from '$lib/components/meltComponents/MeltButton.svelte'
|
||||
import { sidebarClasses } from './MenuButton.svelte'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
icon: any
|
||||
folded: boolean
|
||||
onToggle: () => void
|
||||
isCollapsed: boolean
|
||||
/** A dot on the icon: something inside wants attention. */
|
||||
notify?: boolean
|
||||
/** A section with nothing to fold: the row stays, without its chevron. */
|
||||
disabled?: boolean
|
||||
/**
|
||||
* Buttons at the end of an unfolded row in the open sidebar, and rows at the top of a folded
|
||||
* row's menu, where `menu` lets them be its items and open submenus from it.
|
||||
*/
|
||||
actions?: Snippet<[SectionActionsArgs]>
|
||||
/**
|
||||
* The section's items; `inPopover` asks for them with their names, whatever the mode, and
|
||||
* `menu` is the folded row's menu they are listed in.
|
||||
*/
|
||||
children: Snippet<[boolean, SectionMenu | undefined]>
|
||||
/** The folded row's menu closed. */
|
||||
onClose?: () => void
|
||||
}
|
||||
|
||||
let {
|
||||
title,
|
||||
icon: Icon,
|
||||
folded,
|
||||
onToggle,
|
||||
isCollapsed,
|
||||
notify = false,
|
||||
disabled = false,
|
||||
actions,
|
||||
// Renamed: the menu's own `children` snippets below would shadow it.
|
||||
children: items,
|
||||
onClose
|
||||
}: Props = $props()
|
||||
|
||||
const isFolded = $derived(folded && !disabled)
|
||||
const toggleLabel = $derived(isFolded ? `Unfold ${title}` : `Fold ${title}`)
|
||||
const rowClass =
|
||||
'relative flex items-center justify-start w-full h-[30px] px-2 gap-2 rounded-lg text-left font-normal'
|
||||
|
||||
let open = $state(false)
|
||||
function setOpen(value: boolean) {
|
||||
if (open && !value) onClose?.()
|
||||
open = value
|
||||
}
|
||||
function toggle() {
|
||||
setOpen(false)
|
||||
onToggle()
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- In the open sidebar a section row is its title at the start and a chevron at the end, down
|
||||
when unfolded, right when folded. The rail has no title, so the row takes an item icon's place:
|
||||
the down chevron when unfolded (its items, right under it, name it), the section's icon when
|
||||
folded, with a right chevron in the strip beside it. -->
|
||||
{#snippet foldChevron(size: number, extraClass: string)}
|
||||
<ChevronRight {size} class={twMerge('flex-shrink-0 text-hint', extraClass)} aria-hidden="true" />
|
||||
{/snippet}
|
||||
|
||||
{#snippet notifyDot(extraClass: string)}
|
||||
<span class={twMerge('w-1.5 h-1.5 rounded-full bg-surface-accent-primary', extraClass)}></span>
|
||||
{/snippet}
|
||||
|
||||
{#snippet sectionIcon()}
|
||||
<!-- Under an item icon's 16px, to leave the rail's chevron room beside it. -->
|
||||
<span class="relative flex-shrink-0 flex">
|
||||
<Icon size={12} class="text-hint" />
|
||||
{#if notify}
|
||||
{@render notifyDot('absolute -top-1 -right-1')}
|
||||
{/if}
|
||||
</span>
|
||||
{/snippet}
|
||||
|
||||
{#snippet unfoldedChevron(extraClass: string)}
|
||||
<!-- 2.67 keeps the 1.33px stroke a 16px item icon draws at strokeWidth 2. -->
|
||||
<ChevronDown
|
||||
size={12}
|
||||
strokeWidth={2.67}
|
||||
class={twMerge('flex-shrink-0 text-hint', extraClass)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
{/snippet}
|
||||
|
||||
{#snippet rowContent()}
|
||||
{#if isCollapsed}
|
||||
<span class="flex-shrink-0 flex items-center justify-center w-4 h-4">
|
||||
{#if isFolded || disabled}
|
||||
{@render sectionIcon()}
|
||||
{:else}
|
||||
{@render unfoldedChevron('')}
|
||||
{/if}
|
||||
</span>
|
||||
{#if isFolded}
|
||||
{@render foldChevron(10, 'absolute right-0.5 top-[10px]')}
|
||||
{/if}
|
||||
{:else if isFolded}
|
||||
{@render foldChevron(12, 'ml-auto')}
|
||||
{:else if !disabled}
|
||||
{@render unfoldedChevron('ml-auto')}
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
<!-- Padding, not a margin, widens the gap above the section: a margin would collapse into the
|
||||
wrapper's own. The card has no side padding, so its rows keep the places they have outside it;
|
||||
it darkens whatever the sidebar's color is, accent tint included. -->
|
||||
<div class="pt-1.5">
|
||||
<div
|
||||
class={twMerge(
|
||||
'rounded-lg bg-black/[0.02] dark:bg-white/[0.025]',
|
||||
// Folded, the card is the row alone, so the row's hover fills it exactly.
|
||||
!isFolded && 'pb-0.5'
|
||||
)}
|
||||
>
|
||||
<!-- A fixed height and flex wrappers: Firefox gives inline wrappers line space, so a row sized by
|
||||
its content comes out taller than the 30px every other row has, more so while it is squeezed. -->
|
||||
<div class="relative flex flex-row items-center gap-0.5 h-[30px]">
|
||||
<div class="relative flex-1 min-w-0 flex items-center">
|
||||
{#if isFolded}
|
||||
<!-- The click folds rather than pinning the menu: caught before melt's own handler. Only
|
||||
the user's: the menu opens on hover by clicking its own trigger from script. -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions, a11y_click_events_have_key_events -->
|
||||
<div
|
||||
class={twMerge(
|
||||
rowClass,
|
||||
'px-0',
|
||||
open ? sidebarClasses.selectedBg : sidebarClasses.hoverBg
|
||||
)}
|
||||
onclickcapture={(e) => {
|
||||
if (!e.isTrusted) return
|
||||
e.stopPropagation()
|
||||
toggle()
|
||||
}}
|
||||
>
|
||||
<Menubar class="w-full h-full">
|
||||
{#snippet children({ createMenu })}
|
||||
<Menu
|
||||
{createMenu}
|
||||
bind:open={() => open, setOpen}
|
||||
openOnHover
|
||||
pinOnClick
|
||||
submenuSafe
|
||||
placement="right-start"
|
||||
closeFocus={null}
|
||||
class="h-full"
|
||||
menuClass="w-56"
|
||||
maxHeight={600}
|
||||
>
|
||||
{#snippet triggr({ trigger })}
|
||||
<MeltButton
|
||||
meltElement={trigger}
|
||||
title={toggleLabel}
|
||||
class="w-full h-full min-w-0 flex items-center gap-2 px-2 text-left"
|
||||
>
|
||||
{@render rowContent()}
|
||||
</MeltButton>
|
||||
{/snippet}
|
||||
{#snippet children({ item, builders })}
|
||||
{@const menu = { item, builders } as SectionMenu}
|
||||
<!-- A session or link picked here leaves the menu with the page it opened:
|
||||
only the rows given `menu.item` are melt items that close it themselves. -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions, a11y_click_events_have_key_events -->
|
||||
<div
|
||||
class="flex flex-col gap-0.5 px-1"
|
||||
onclick={(e) => {
|
||||
if ((e.target as Element).closest('a, [role="option"]')) setOpen(false)
|
||||
}}
|
||||
>
|
||||
<!-- The collapsed rail shows no title on the row, so its menu does. -->
|
||||
{#if isCollapsed}
|
||||
<div class="flex flex-row items-center h-7 pl-2">
|
||||
<span
|
||||
class="flex-1 truncate text-secondary text-[0.5rem] font-normal uppercase"
|
||||
>{title}</span
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
{@render actions?.({ inPopover: true, menu })}
|
||||
{@render items(true, menu)}
|
||||
</div>
|
||||
{/snippet}
|
||||
</Menu>
|
||||
{/snippet}
|
||||
</Menubar>
|
||||
</div>
|
||||
{:else if disabled}
|
||||
<div class={rowClass}>
|
||||
{@render rowContent()}
|
||||
</div>
|
||||
{:else}
|
||||
<Button
|
||||
variant="subtle"
|
||||
title={toggleLabel}
|
||||
aria-label={toggleLabel}
|
||||
aria-expanded={true}
|
||||
wrapperClasses="w-full"
|
||||
btnClasses={twMerge(rowClass, sidebarClasses.hoverBg)}
|
||||
onClick={toggle}
|
||||
>
|
||||
{@render rowContent()}
|
||||
</Button>
|
||||
{/if}
|
||||
{#if !isCollapsed}
|
||||
<!-- Outside the row's control, which is a different element folded and unfolded (melt's
|
||||
inline-block trigger, or a Button): the title stays one element, placed the same. -->
|
||||
<span
|
||||
class="pointer-events-none absolute inset-y-0 left-2 right-7 flex items-center gap-2"
|
||||
>
|
||||
<span class="truncate uppercase text-[0.5rem] leading-3 font-normal text-secondary"
|
||||
>{title}</span
|
||||
>
|
||||
{#if notify && (isFolded || disabled)}
|
||||
{@render notifyDot('flex-shrink-0')}
|
||||
{/if}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if !isCollapsed && !isFolded}
|
||||
{@render actions?.({ inPopover: false })}
|
||||
{/if}
|
||||
</div>
|
||||
{#if !isFolded}
|
||||
<div transition:slide={{ duration: 180 }}>
|
||||
{@render items(false, undefined)}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,48 +0,0 @@
|
||||
<!--
|
||||
@component
|
||||
A sidebar section's title row. The title folds the section and fills the row up to its actions;
|
||||
its padding lines the text up with the nav rows' icons and its height matches theirs, so actions
|
||||
are `sm` (h-7) buttons.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte'
|
||||
import { ChevronDown, ChevronRight } from 'lucide-svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
collapsed: boolean
|
||||
onToggle: () => void
|
||||
/** A section with nothing to fold: the title stays, without its chevron. */
|
||||
disabled?: boolean
|
||||
actions?: Snippet
|
||||
}
|
||||
|
||||
let { title, collapsed, onToggle, disabled = false, actions }: Props = $props()
|
||||
|
||||
const titleClasses = 'px-2 text-secondary text-[0.5rem] font-normal uppercase'
|
||||
</script>
|
||||
|
||||
<div class="flex flex-row items-center h-7 gap-0.5">
|
||||
{#if disabled}
|
||||
<!-- A label rather than a disabled Button, which would grey the title out. -->
|
||||
<span class="flex-1 min-w-0 h-7 flex flex-row items-center {titleClasses}">{title}</span>
|
||||
{:else}
|
||||
<Button
|
||||
variant="subtle"
|
||||
unifiedSize="sm"
|
||||
onClick={onToggle}
|
||||
aria-expanded={!collapsed}
|
||||
wrapperClasses="flex-1 min-w-0"
|
||||
btnClasses="justify-start text-left gap-1 {titleClasses}"
|
||||
>
|
||||
{title}
|
||||
{#if collapsed}
|
||||
<ChevronRight size={10} />
|
||||
{:else}
|
||||
<ChevronDown size={10} />
|
||||
{/if}
|
||||
</Button>
|
||||
{/if}
|
||||
{@render actions?.()}
|
||||
</div>
|
||||
@@ -306,9 +306,9 @@
|
||||
{/snippet}
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded p-1.5 hover:bg-surface-hover flex {isCollapsed
|
||||
? 'justify-center'
|
||||
: 'flex-col gap-1'}"
|
||||
class="w-full h-9 rounded hover:bg-surface-hover flex {isCollapsed
|
||||
? 'items-center px-2'
|
||||
: 'flex-col justify-center gap-1 p-1.5'}"
|
||||
onclick={() => {
|
||||
open = true
|
||||
const key: UsageMeterKey = $isPremiumStore ? 'paid:workspace' : `free:${tightest.key}`
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BAR_HEIGHT_PX } from '../pageHeaderRegistry.svelte'
|
||||
import type { Item } from '$lib/utils'
|
||||
|
||||
// Opening the detached sidebar's card, from the band's own handle or from the corner control that
|
||||
// stands in for it on a page which hides the band.
|
||||
@@ -22,6 +23,15 @@ let card: CardState | undefined
|
||||
const FALLBACK_CARD_TOP = BAR_HEIGHT_PX
|
||||
const GAP_UNDER_HANDLE = 6
|
||||
let cardTop = $state(FALLBACK_CARD_TOP)
|
||||
// The sidebar mode menu, which the layout builds from its own state. Where the card slides in on
|
||||
// hover, the handle's click opens it, as the card then carries no footer to hold it.
|
||||
let modeItems: (() => Item[]) | undefined = $state()
|
||||
// A mode change can move the mode button between the sidebar's footer and the page header, so the
|
||||
// button flashes where it lands. Nonzero only while the flash plays: the header remounts on every
|
||||
// page, and a lasting value would replay it there.
|
||||
const MODE_FLASH_MS = 1500
|
||||
let modeFlash = $state(0)
|
||||
let modeFlashTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
export const navHandleSlot = {
|
||||
/** Distance from the top of the viewport to the card's top edge, in px. */
|
||||
@@ -32,6 +42,22 @@ export const navHandleSlot = {
|
||||
get pinned(): boolean {
|
||||
return !!card?.isOpen() && card.isPinned()
|
||||
},
|
||||
/** The sidebar mode menu's items, once the layout has registered them. Reactive. */
|
||||
get modeItems(): Item[] | undefined {
|
||||
return modeItems?.()
|
||||
},
|
||||
setModeItems(items: () => Item[]) {
|
||||
modeItems = items
|
||||
},
|
||||
/** Nonzero while the mode button flashes after a mode change; each change gets a new value. */
|
||||
get modeFlash(): number {
|
||||
return modeFlash
|
||||
},
|
||||
flashModeButton() {
|
||||
clearTimeout(modeFlashTimer)
|
||||
modeFlash += 1
|
||||
modeFlashTimer = setTimeout(() => (modeFlash = 0), MODE_FLASH_MS)
|
||||
},
|
||||
/** The root layout owns the card, so it registers how to open, pin, close and hover-close it. */
|
||||
setOpener(
|
||||
open: () => void,
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
/** What "Customize sidebar" in the settings menu changes, per browser. Module-level so the
|
||||
/** What Customize in the sidebar menu changes, per browser. Module-level so the
|
||||
* menu that flips a choice and the sidebar that reads it share one value. */
|
||||
export const sidebarPrefs = {
|
||||
/** The starred items as a section of their own. */
|
||||
favorites: useLocalStorageValue('windmill_sidebar_show_favorites', false, 'boolean')
|
||||
favorites: useLocalStorageValue('windmill_sidebar_show_favorites', false, 'boolean'),
|
||||
/** The reader's flow and agent chats. */
|
||||
aiChats: useLocalStorageValue('windmill_sidebar_show_ai_chats', true, 'boolean')
|
||||
}
|
||||
|
||||
/** Set on the first click of the brand row: until then it also says it is Home, since the
|
||||
* brand alone does not tell a newcomer where it goes. */
|
||||
export const homeRowLearned = useLocalStorageValue(
|
||||
'windmill_sidebar_home_row_learned',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
|
||||
@@ -1672,6 +1672,9 @@ export type Item = {
|
||||
* slot. Presentational: the row's own click is what flips it, so `action` must
|
||||
* apply the change. */
|
||||
toggle?: boolean
|
||||
/** The menu stays open after the row is picked, for a setting whose effect shows in it.
|
||||
* Rows of a `DropdownSubmenuItem` only. */
|
||||
keepOpen?: boolean
|
||||
submenuItems?: Item[]
|
||||
shortcut?: string
|
||||
// Renders a trailing check on the right of the label to mark the
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { BROWSER } from 'esm-env'
|
||||
import { isMac } from '$lib/utils'
|
||||
import { isMac, type Item } from '$lib/utils'
|
||||
|
||||
import {
|
||||
AppService,
|
||||
@@ -86,13 +86,14 @@
|
||||
import {
|
||||
PanelLeft,
|
||||
PanelLeftClose,
|
||||
PanelLeftDashed,
|
||||
PanelLeftOpen,
|
||||
Home,
|
||||
Play,
|
||||
Search,
|
||||
ArrowLeft
|
||||
ArrowLeft,
|
||||
Star,
|
||||
MessagesSquare
|
||||
} from 'lucide-svelte'
|
||||
import { homeRowLearned, sidebarPrefs } from '$lib/components/sidebar/sidebarPrefs.svelte'
|
||||
import { Button } from '$lib/components/common'
|
||||
import { isInstanceRoute } from '$lib/instanceRoutes'
|
||||
import { getUserExt } from '$lib/user'
|
||||
@@ -107,6 +108,7 @@
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { navDetached } from '$lib/components/sidebar/navDetached.svelte'
|
||||
import { navHandleSlot } from '$lib/components/sidebar/navHandlePlacement.svelte'
|
||||
import ModeButtonFlash from '$lib/components/sidebar/ModeButtonFlash.svelte'
|
||||
import { overlayStack } from '$lib/components/common/overlayHost.svelte'
|
||||
import PageHeaderBar from '$lib/components/PageHeaderBar.svelte'
|
||||
import { BAR_HEIGHT_PX, pageHeader } from '$lib/components/pageHeaderRegistry.svelte'
|
||||
@@ -124,7 +126,7 @@
|
||||
import InstanceUiSync from '$lib/components/InstanceUiSync.svelte'
|
||||
import { onDestroy, onMount, setContext, tick, untrack } from 'svelte'
|
||||
import { cubicOut } from 'svelte/easing'
|
||||
import { Tooltip } from '$lib/components/meltComponents'
|
||||
import DropdownV2 from '$lib/components/DropdownV2.svelte'
|
||||
import { loadCopilot } from '$lib/components/copilot/loadCopilot'
|
||||
import SessionPicker from '$lib/components/sessions/SessionPicker.svelte'
|
||||
import {
|
||||
@@ -178,6 +180,16 @@
|
||||
// Operators never get the icon-only rail: their docked sidebar is always expanded (a sidebar
|
||||
// they want out of the way is what detaching is for).
|
||||
let isCollapsed = $derived(collapsedState && $roleCapabilities.code)
|
||||
// Expand on hover: the icon rail widens over the page while the pointer is on it. The page
|
||||
// keeps the icon rail's offset, so nothing beside the rail moves.
|
||||
const hoverExpandPref = useLocalStorageValue<boolean>(
|
||||
'nav_menu_expand_on_hover',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
let expandsOnHover = $derived(isCollapsed && hoverExpandPref.val)
|
||||
let hoverExpandedState = $state(false)
|
||||
let hoverExpanded = $derived(expandsOnHover && hoverExpandedState)
|
||||
|
||||
// Resizable desktop rail, sized in REM so it scales with the root font-size the
|
||||
// same way the old `w-52`/`w-12` classes did — `:root` jumps to 18px on screens
|
||||
@@ -246,11 +258,18 @@
|
||||
// Re-expanding a snap-collapsed rail restores the width it had before the drag.
|
||||
const widthAtStart = sidebarWidth
|
||||
const collapsedAtStart = collapsedState
|
||||
// A rail widened by hover resizes the width it widens to and stays in its mode: it has no
|
||||
// snap, since collapsing is what it does when the pointer leaves.
|
||||
const hoverResize = hoverExpanded
|
||||
// The rail is fixed at left:0, so the pointer's clientX is the width — in px.
|
||||
// Convert to rem (the unit the rail is sized in) via the root font-size. The
|
||||
// rail clamps at the min like a wall, until the pointer reaches the snap zone.
|
||||
const onMove = (ev: PointerEvent) => {
|
||||
const x = ev.clientX / rootFontPx()
|
||||
if (hoverResize) {
|
||||
sidebarWidth = Math.max(SIDEBAR_MIN_REM, x)
|
||||
return
|
||||
}
|
||||
const collapse = x < SIDEBAR_SNAP_COLLAPSE_REM
|
||||
// Operators have no icon-only rail to snap to, so the same gesture detaches
|
||||
// instead: dragging the sidebar off the left edge puts it behind the handle.
|
||||
@@ -287,6 +306,9 @@
|
||||
handle.releasePointerCapture(e.pointerId)
|
||||
} catch {}
|
||||
stopSidebarResize = null
|
||||
if (hoverResize && !document.getElementById('sidebar')?.matches(':hover')) {
|
||||
scheduleRailCollapse()
|
||||
}
|
||||
}
|
||||
stopSidebarResize = stop
|
||||
window.addEventListener('pointermove', onMove)
|
||||
@@ -538,22 +560,45 @@
|
||||
const PEEK_CLOSE_DELAY_MS = 200
|
||||
// Both the card and the band open menus, and a menu portals to `body` (overlayPortalTarget),
|
||||
// so the pointer moving into one leaves the surface that opened it. A surface has to outlive
|
||||
// its own menus or it slides out from under the one being read: hold while the pointer is in a
|
||||
// menu, and take the close from the leave of that instead.
|
||||
function pointerInMenu(): boolean {
|
||||
return !!document.querySelector('[role="menu"]:hover')
|
||||
// its own menus or it slides out from under the one being read, so it holds while one is open,
|
||||
// hovered or not: the way from a menu to its submenu crosses neither.
|
||||
function menuIsOpen(): boolean {
|
||||
return !!document.querySelector('[role="menu"]:not([hidden])')
|
||||
}
|
||||
// Sessions being selected for a batch action hold the surface the same way, until Done.
|
||||
function holdsSurface(): boolean {
|
||||
return menuIsOpen() || !!document.querySelector('[data-sessions-selecting]')
|
||||
}
|
||||
// Once its menus close, a surface the pointer is back on stays: its own leave closes it later.
|
||||
function pointerOnSidebar(): boolean {
|
||||
return !!document.querySelector(
|
||||
'[data-nav-card]:hover, [data-nav-handle]:hover, #sidebar:hover'
|
||||
)
|
||||
}
|
||||
// A click on the handle pins the card: it then outlives the pointer leaving. Only meaningful
|
||||
// while open — every open from closed starts unpinned.
|
||||
let menuPinned = $state(false)
|
||||
const { debounced: schedulePeekClose, clearDebounce: cancelPeekClose } = debounce(() => {
|
||||
if (!peeksOnHover || menuPinned) return
|
||||
if (pointerInMenu()) {
|
||||
if (holdsSurface()) {
|
||||
schedulePeekClose()
|
||||
return
|
||||
}
|
||||
if (pointerOnSidebar()) return
|
||||
menuOpen = false
|
||||
}, PEEK_CLOSE_DELAY_MS)
|
||||
// The close waits just long enough for the pointer to cross into a menu the rail opened.
|
||||
const RAIL_HOVER_CLOSE_DELAY_MS = 80
|
||||
const { debounced: scheduleRailCollapse, clearDebounce: cancelRailCollapse } = debounce(() => {
|
||||
// A drag of the widened rail's edge ends outside it; the drag's end decides.
|
||||
if (resizingSidebar) return
|
||||
if (holdsSurface()) {
|
||||
scheduleRailCollapse()
|
||||
return
|
||||
}
|
||||
if (pointerOnSidebar()) return
|
||||
hoverExpandedState = false
|
||||
}, RAIL_HOVER_CLOSE_DELAY_MS)
|
||||
|
||||
// A page that owns the right edge from the top — a session's side panel — makes the band float
|
||||
// and stop where that column starts, instead of running over it.
|
||||
@@ -584,19 +629,31 @@
|
||||
const target = e.target
|
||||
if (!(target instanceof Element) || !pageColumn?.contains(target)) return
|
||||
if (target.closest('[data-nav-handle]')) return
|
||||
if (document.querySelector('[data-sessions-selecting]')) return
|
||||
menuOpen = false
|
||||
}
|
||||
// A press inside an iframe (a session's preview) never reaches this window; focus moving into one does.
|
||||
function closeCardOnFrameFocus() {
|
||||
if (!menuOpen || !useDrawer) return
|
||||
setTimeout(() => {
|
||||
if (document.activeElement instanceof HTMLIFrameElement) menuOpen = false
|
||||
if (
|
||||
document.activeElement instanceof HTMLIFrameElement &&
|
||||
!document.querySelector('[data-sessions-selecting]')
|
||||
)
|
||||
menuOpen = false
|
||||
})
|
||||
}
|
||||
|
||||
const viewportOverlays = overlayStack()
|
||||
function onWindowKeydown(e: KeyboardEvent) {
|
||||
onSearchShortcutBeforeLoad(e)
|
||||
// Cmd/Ctrl+\ (Notion's binding): Cmd+B is the raw app editor's file sidebar.
|
||||
if ((e.metaKey || e.ctrlKey) && !e.shiftKey && !e.altKey && e.key === '\\') {
|
||||
if (!$roleCapabilities.code || navDetached.val || innerWidth < 768) return
|
||||
e.preventDefault()
|
||||
setSidebarMode(isCollapsed ? 'expanded' : 'icons')
|
||||
return
|
||||
}
|
||||
if (e.key !== 'Escape' || !menuOpen || !useDrawer) return
|
||||
// Read now: the overlay this Esc closes is off the stack by the time the timeout runs.
|
||||
if (viewportOverlays.val.length > 0) return
|
||||
@@ -620,13 +677,83 @@
|
||||
menuOpen = false
|
||||
navDetached.val = detached
|
||||
}
|
||||
type SidebarMode = 'expanded' | 'icons' | 'hover' | 'hidden'
|
||||
function currentSidebarMode(): SidebarMode {
|
||||
return navDetached.val
|
||||
? 'hidden'
|
||||
: expandsOnHover
|
||||
? 'hover'
|
||||
: isCollapsed
|
||||
? 'icons'
|
||||
: 'expanded'
|
||||
}
|
||||
function sidebarModeItems(withModes = true): Item[] {
|
||||
const mode = currentSidebarMode()
|
||||
const customize: Item = {
|
||||
sectionTitle: withModes ? undefined : 'Sidebar',
|
||||
displayName: 'Customize',
|
||||
submenuItems: [
|
||||
{
|
||||
displayName: 'Favorites section',
|
||||
icon: Star,
|
||||
toggle: sidebarPrefs.favorites.val,
|
||||
action: () => (sidebarPrefs.favorites.val = !sidebarPrefs.favorites.val)
|
||||
},
|
||||
{
|
||||
displayName: 'AI chats section',
|
||||
icon: MessagesSquare,
|
||||
toggle: sidebarPrefs.aiChats.val,
|
||||
action: () => (sidebarPrefs.aiChats.val = !sidebarPrefs.aiChats.val)
|
||||
}
|
||||
]
|
||||
}
|
||||
if (!withModes) return [customize]
|
||||
return [
|
||||
{
|
||||
sectionTitle: 'Sidebar',
|
||||
displayName: 'Expanded',
|
||||
selected: mode === 'expanded',
|
||||
action: () => setSidebarMode('expanded')
|
||||
},
|
||||
{
|
||||
displayName: 'Collapsed',
|
||||
shortcut: `${getModifierKey()}\\`,
|
||||
selected: mode === 'icons',
|
||||
hide: !$roleCapabilities.code,
|
||||
action: () => setSidebarMode('icons')
|
||||
},
|
||||
{
|
||||
displayName: 'Expand on hover',
|
||||
selected: mode === 'hover',
|
||||
hide: !$roleCapabilities.code,
|
||||
action: () => setSidebarMode('hover')
|
||||
},
|
||||
{
|
||||
displayName: 'Hidden, show on hover',
|
||||
selected: mode === 'hidden',
|
||||
action: () => setSidebarMode('hidden')
|
||||
},
|
||||
customize
|
||||
]
|
||||
}
|
||||
navHandleSlot.setModeItems(() => sidebarModeItems())
|
||||
function setSidebarMode(mode: SidebarMode) {
|
||||
if (mode !== currentSidebarMode()) navHandleSlot.flashModeButton()
|
||||
// The collapse preference is one key for both roles, and only a developer's rail reads it:
|
||||
// an operator writing it would reset the icon rail they chose as a developer elsewhere.
|
||||
if (mode !== 'hidden' && $roleCapabilities.code) {
|
||||
collapsedState = mode !== 'expanded'
|
||||
collapsePref.val = collapsedState
|
||||
hoverExpandPref.val = mode === 'hover'
|
||||
}
|
||||
if (navDetached.val !== (mode === 'hidden')) setDetached(mode === 'hidden')
|
||||
}
|
||||
// Docking and detaching move and resize the rail itself between its docked box and the detached
|
||||
// card's (top at the band's bottom edge, bottom and left insets, rounded corners); detaching
|
||||
// also slides it off the left edge, where the closed card lives. No opacity: the rail never
|
||||
// fades.
|
||||
// The footer's icon buttons wear the rail's own row box — 32px square, 16px glyph — so the
|
||||
// pair that hides and collapses the sidebar lines up with the links above them, collapsed or
|
||||
// not. Padding alone drifted: two different paddings, two icon sizes and a negative margin.
|
||||
// The footer's mode button wears the rail's own row box — 32px square, 16px glyph — so it
|
||||
// lines up with the links above it, collapsed or not.
|
||||
const SIDEBAR_ICON_BUTTON =
|
||||
'h-8 w-8 flex items-center justify-center rounded hover:bg-surface-hover flex-shrink-0'
|
||||
|
||||
@@ -1216,37 +1343,22 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
|
||||
<!-- Windmill brand mark anchoring the sidebar bottom (the header slot is taken
|
||||
by the workspace picker). -->
|
||||
<!-- Detaching is the operator's control: they have no icon-only rail to collapse to, so hiding the
|
||||
sidebar is how they give the page its width back. A developer collapses instead, and never
|
||||
detaches — but one who detached before this was so keeps the way back, or they would be stuck
|
||||
with a sidebar they cannot return. -->
|
||||
{#snippet sidebarToggle()}
|
||||
{@const hidden = navDetached.val}
|
||||
{#if hidden || !$roleCapabilities.code}
|
||||
<Tooltip class="flex" placement="bottom" small>
|
||||
<button
|
||||
class={SIDEBAR_ICON_BUTTON}
|
||||
aria-label={hidden ? 'Show sidebar' : 'Hide sidebar'}
|
||||
onclick={() => setDetached(!hidden)}
|
||||
>
|
||||
{#if hidden}
|
||||
<PanelLeft size={16} class="flex-shrink-0 text-hint" />
|
||||
{:else}
|
||||
<PanelLeftDashed size={16} class="flex-shrink-0 text-hint" />
|
||||
{/if}
|
||||
</button>
|
||||
{#snippet text()}{hidden ? 'Show sidebar' : 'Hide sidebar'}{/snippet}
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
{#snippet brandMark(collapsed: boolean)}
|
||||
<div class="flex items-center gap-x-1.5 text-xs font-semibold text-emphasis">
|
||||
<WindmillIcon white={darkMode} height="16px" width="16px" />
|
||||
{#if !collapsed}
|
||||
{$whitelabelNameStore ? capitalize($whitelabelNameStore) : 'Windmill'}
|
||||
{/if}
|
||||
</div>
|
||||
<!-- Operators get no "Collapsed": their docked sidebar is always expanded. -->
|
||||
{#snippet sidebarModeMenu(withModes: boolean)}
|
||||
<span class="relative inline-flex">
|
||||
<ModeButtonFlash />
|
||||
<DropdownV2
|
||||
placement="top-start"
|
||||
fixedHeight={false}
|
||||
class={SIDEBAR_ICON_BUTTON}
|
||||
items={sidebarModeItems(withModes)}
|
||||
>
|
||||
{#snippet buttonReplacement()}
|
||||
<PanelLeft size={16} class="flex-shrink-0 text-hint" />
|
||||
<span class="sr-only">Sidebar mode</span>
|
||||
{/snippet}
|
||||
</DropdownV2>
|
||||
</span>
|
||||
{/snippet}
|
||||
|
||||
<!-- Settings / instance section: the last section inside the nav's unified scroll area. -->
|
||||
@@ -1267,7 +1379,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
whenever the nav is detached. The shells differ, the sections do not, so a change to the
|
||||
rail cannot miss the panel. -->
|
||||
{#snippet sidebarColumn(panel: boolean)}
|
||||
{@const collapsed = panel ? false : isCollapsed}
|
||||
{@const collapsed = panel ? false : isCollapsed && !hoverExpanded}
|
||||
<div
|
||||
class={twMerge(
|
||||
'flex flex-col',
|
||||
@@ -1297,55 +1409,54 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
which is why nothing names the workspace here. -->
|
||||
<div class="flex-shrink-0 px-2 h-12 flex flex-row items-center gap-0.5">
|
||||
<div class="flex-1 min-w-0">
|
||||
<!-- The brand is the way home, so it stands in for a Home icon and label. -->
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
label="Home"
|
||||
label={($whitelabelNameStore ? capitalize($whitelabelNameStore) : 'Windmill') +
|
||||
(homeRowLearned.val ? '' : ' / Home')}
|
||||
hint="Go to Home"
|
||||
href="/"
|
||||
icon={Home}
|
||||
onclick={() => {
|
||||
// A click on Home itself goes nowhere, so it teaches nothing.
|
||||
if (page.url.pathname !== '/') homeRowLearned.val = true
|
||||
}}
|
||||
icon={WindmillIcon}
|
||||
iconProps={{ white: darkMode, width: '16px', height: '16px' }}
|
||||
isCollapsed={collapsed}
|
||||
aiId="sidebar-menu-link-home"
|
||||
aiDescription="Button to navigate to home which contains all the user's scripts, flows and apps"
|
||||
/>
|
||||
</div>
|
||||
<!-- Expanded, Search shares Home's row; the collapsed rail keeps it in the nav below. -->
|
||||
{#if !collapsed}
|
||||
<Button
|
||||
unifiedSize="sm"
|
||||
variant="subtle"
|
||||
startIcon={{ icon: Search }}
|
||||
title="Search"
|
||||
aria-label="Search"
|
||||
btnClasses="text-secondary gap-1 px-1.5"
|
||||
onClick={() => openSearchModal()}
|
||||
>
|
||||
<span class="text-2xs text-hint font-normal">{getModifierKey()}K</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
<!-- Pulled up into the Home band's slack under its centred row (48px band; rows 30px, 32px
|
||||
on the rail), so the next row sits 2px under Home, as the nav's rows sit apart. Kept
|
||||
outside the scroll area: a negative margin inside it would clip that row. -->
|
||||
<div class={twMerge('flex flex-col flex-1 min-h-0', collapsed ? '-mt-1.5' : '-mt-[7px]')}>
|
||||
<!-- Pulled up into the Home band's slack under its centred row (48px band, 32px rows), so
|
||||
the next row sits 2px under Home, as the nav's rows sit apart. Kept outside the scroll
|
||||
area: a negative margin inside it would clip that row. -->
|
||||
<div class="flex flex-col flex-1 min-h-0 -mt-1.5">
|
||||
<!-- Search stays with Home, above the list that scrolls. -->
|
||||
<div class="flex-shrink-0 px-2 pb-0.5">
|
||||
<MenuButton
|
||||
stopPropagationOnClick={true}
|
||||
on:click={() => openSearchModal()}
|
||||
isCollapsed={collapsed}
|
||||
icon={Search}
|
||||
label="Search"
|
||||
class="!text-xs"
|
||||
shortcut={`${getModifierKey()}K`}
|
||||
/>
|
||||
</div>
|
||||
<!-- The workspace nav: Runs → Settings scroll as ONE block with an
|
||||
overflow fade hint. The sections (Runs + workspace items / AI sessions /
|
||||
instance settings) are spaced by the scroll area's
|
||||
gap rather than each scrolling on its own. -->
|
||||
<SidebarScrollArea color={darkMode ? SIDEBAR_BG_DARK : SIDEBAR_BG}>
|
||||
<!-- Section 1: Search (collapsed) + Runs, then the workspace items, spaced as one list. -->
|
||||
<!-- Keyed to the mode rather than to `collapsed`: a scrollbar appearing as the rail opens on
|
||||
hover would shift the rows mid-animation. -->
|
||||
<SidebarScrollArea
|
||||
color={darkMode ? SIDEBAR_BG_DARK : SIDEBAR_BG}
|
||||
hideScrollbar={!panel && isCollapsed}
|
||||
>
|
||||
<!-- Section 1: Runs, then the workspace items, spaced as one list. -->
|
||||
<div class="flex flex-col gap-0.5">
|
||||
<div class="px-2 flex flex-col gap-0.5">
|
||||
<!-- Collapsed, Search stays right under Home, where it sits beside it expanded. -->
|
||||
{#if collapsed}
|
||||
<MenuButton
|
||||
stopPropagationOnClick={true}
|
||||
on:click={() => openSearchModal()}
|
||||
isCollapsed={collapsed}
|
||||
icon={Search}
|
||||
label="Search"
|
||||
class="!text-xs"
|
||||
shortcut={`${getModifierKey()}k`}
|
||||
/>
|
||||
{/if}
|
||||
{@render quickLinks(collapsed)}
|
||||
</div>
|
||||
<SidebarContent
|
||||
@@ -1358,7 +1469,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- The starred items, when "Customize sidebar" turns them on; hidden in the rail. -->
|
||||
<!-- The starred items, when the sidebar menu's Customize turns them on; hidden in the rail. -->
|
||||
<div class="px-2 empty:hidden">
|
||||
<FavoritesSection isCollapsed={collapsed} />
|
||||
</div>
|
||||
@@ -1370,10 +1481,12 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- The flow and agent chats stored in the workspace; hidden in the collapsed rail. -->
|
||||
<div class="px-2 empty:hidden">
|
||||
<AiChatsSection isCollapsed={collapsed} />
|
||||
</div>
|
||||
<!-- The flow and agent chats stored in the workspace, unless Customize turned them off. -->
|
||||
{#if sidebarPrefs.aiChats.val}
|
||||
<div class="px-2 empty:hidden">
|
||||
<AiChatsSection isCollapsed={collapsed} />
|
||||
</div>
|
||||
{/if}
|
||||
</SidebarScrollArea>
|
||||
</div>
|
||||
|
||||
@@ -1388,37 +1501,37 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
<SidebarUsage isCollapsed={collapsed} />
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex-shrink-0 flex pb-3.5 {collapsed
|
||||
? 'flex-col items-center gap-1 pt-4'
|
||||
: 'items-center justify-between px-4 pt-1'}"
|
||||
>
|
||||
{@render brandMark(collapsed)}
|
||||
<div class="flex {collapsed ? 'flex-col gap-1' : 'gap-3'}">
|
||||
{#if !panel || navDetached.val}
|
||||
{@render sidebarToggle()}
|
||||
{/if}
|
||||
<!-- Collapsing belongs to the rail: the panel is over the page already, and the way
|
||||
out of it is the handle in the band or a click outside. -->
|
||||
{#if !panel && $roleCapabilities.code}
|
||||
<!-- Below 768px the panel is the only shell there is, so there is no mode to pick: the
|
||||
menu holds Customize alone. -->
|
||||
<!-- Where the card slides in on hover, the handle that slides it in holds this menu too. -->
|
||||
{#if !panel || innerWidth < 768 || (navDetached.val && !hoverPointer)}
|
||||
<div
|
||||
class="flex-shrink-0 flex px-2 mt-1 mb-3.5 {collapsed
|
||||
? 'flex-col items-start gap-1'
|
||||
: 'flex-row items-center gap-1 h-8'}"
|
||||
>
|
||||
{@render sidebarModeMenu(!panel || innerWidth >= 768)}
|
||||
<!-- One click between Expanded and Collapsed, as before the mode menu existed; only in
|
||||
those two modes, the others have no such pair. -->
|
||||
{#if !panel && $roleCapabilities.code && !expandsOnHover}
|
||||
<button
|
||||
class={SIDEBAR_ICON_BUTTON}
|
||||
title={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}
|
||||
onclick={() => {
|
||||
collapsedState = !collapsedState
|
||||
// Manual toggle is the persisted preference (auto-collapse isn't).
|
||||
collapsePref.val = collapsedState
|
||||
}}
|
||||
title={`${isCollapsed ? 'Expand' : 'Collapse'} sidebar (${getModifierKey()}\\)`}
|
||||
onclick={() => setSidebarMode(isCollapsed ? 'expanded' : 'icons')}
|
||||
>
|
||||
{#if collapsed}
|
||||
{#if isCollapsed}
|
||||
<PanelLeftOpen size={16} class="flex-shrink-0 text-hint" />
|
||||
{:else}
|
||||
<PanelLeftClose size={16} class="flex-shrink-0 text-hint" />
|
||||
{/if}
|
||||
<span class="sr-only">{isCollapsed ? 'Expand sidebar' : 'Collapse sidebar'}</span>
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{:else if navDetached.val}
|
||||
<!-- Without the footer the last row would sit on the card's bottom edge. -->
|
||||
<div class="flex-shrink-0 h-3"></div>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
|
||||
@@ -1523,16 +1636,26 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div
|
||||
id="sidebar"
|
||||
class={classNames(
|
||||
dockToggled ? '' : 'wm-sidebar-in',
|
||||
// The rail owns the full height of the left edge; the band starts to its right.
|
||||
'flex flex-col fixed inset-y-0 z-40 ',
|
||||
sidebarTransitionClass,
|
||||
expandsOnHover && !resizingSidebar
|
||||
? 'transition-[width] duration-100 ease-out'
|
||||
: sidebarTransitionClass,
|
||||
hoverExpanded ? 'shadow-lg' : '',
|
||||
devOnly ? '!hidden' : ''
|
||||
)}
|
||||
style:width="{railWidth}rem"
|
||||
style:width="{hoverExpanded ? sidebarWidth : railWidth}rem"
|
||||
onmouseenter={() => {
|
||||
if (!expandsOnHover || resizingSidebar) return
|
||||
cancelRailCollapse()
|
||||
hoverExpandedState = true
|
||||
}}
|
||||
onmouseleave={() => scheduleRailCollapse()}
|
||||
in:railMorph={{ offscreen: false }}
|
||||
out:railMorph={{ offscreen: true }}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user