mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-14 13:22:37 +00:00
Sidebar polish round. Menus. `dropdown-menu` and `context-menu` were two copies of one engine that differed only in how the trigger fires — identical from `computePosition` down — and neither could nest. Both are now thin wrappers over `components/ui/menu/`, which owns anchoring, a pure page-stack navigation model, and one presentation fork: flyout on pointer, pushed pages in a sheet on compact. All 31 call sites are unchanged. Items got a rounded inset fill, a visible separator, and `selected` (a check) split from `active` (a fill). Sidebar display preferences. The flat wall of four sections becomes one row per decision with its value, and per-feature toggles over what a workspace row shows: host, pull request, checks, scripts. Each is independent — a ticked toggle that draws nothing is a lie. `display-preferences/` hides that grouping lives in zustand while title source and row items are app settings. Timestamps. "Last activity" now ticks itself. The label rounds to the minute and never shows seconds; past a week it becomes a date. The timer lives in the leaf `<Text>`, at most one per resolution tier shared by every row, and a tick only re-renders when the string actually changed — so a memoized row that legitimately never re-renders still stays current. Colour. Full status tier regenerated at 90% of gamut max (was 85), same rule as the muted tier, lightness and hue untouched. File icons are pulled toward neutral in OKLab behind `getFileIconSvg` — material-icon-theme picks its palette for a tree where the icon is the only colour on the row, and ours is not. New/deleted files use the forge square-plus/square-minus glyphs at muted weight instead of tinted pills. Project icons round a little more; uploaded icons never do. The project status badge is a knockout again: it fills with the colour of the row behind it, so the ring reads as a gap in the icon rather than a white halo. File rows. The always-visible kebab is gone from the file explorer and diff tree in favour of right-click, which also reclaims the reserved action slot.
113 lines
3.7 KiB
TypeScript
113 lines
3.7 KiB
TypeScript
import { useCallback, useMemo } from "react";
|
|
import {
|
|
useAppSettings,
|
|
type SidebarWorkspaceTrailing,
|
|
type WorkspaceTitleSource,
|
|
} from "@/hooks/use-settings";
|
|
import { useSidebarViewStore, type SidebarGroupMode } from "@/stores/sidebar-view-store";
|
|
import { DEFAULT_SIDEBAR_ROW_ITEMS, type SidebarRowItem, type SidebarRowItems } from "./row-items";
|
|
|
|
/** The trailing slot holds one thing, so these are a choice rather than toggles. */
|
|
export type SidebarTrailingChoice = Exclude<SidebarWorkspaceTrailing, "none">;
|
|
|
|
export interface SidebarDisplayPreferences {
|
|
grouping: SidebarGroupMode;
|
|
setGrouping: (mode: SidebarGroupMode) => void;
|
|
titleSource: WorkspaceTitleSource;
|
|
setTitleSource: (source: WorkspaceTitleSource) => void;
|
|
rowItems: SidebarRowItems;
|
|
toggleRowItem: (item: SidebarRowItem) => void;
|
|
trailing: SidebarWorkspaceTrailing;
|
|
/** Picking the choice that is already showing clears the slot. */
|
|
toggleTrailing: (choice: SidebarTrailingChoice) => void;
|
|
hostFilters: readonly string[];
|
|
toggleHostFilter: (serverId: string) => void;
|
|
clearHostFilters: () => void;
|
|
}
|
|
|
|
/**
|
|
* Every decision the sidebar's display-preferences menu can make, behind one interface.
|
|
*
|
|
* Grouping and host filters live in a local zustand store while the title source and row items
|
|
* are synced app settings — a split that exists for good reasons (a filter is transient view
|
|
* state; a preference follows you) and that the menu has no business knowing about. Callers ask
|
|
* this for a value and set it; where it lands is this module's problem.
|
|
*/
|
|
export function useSidebarDisplayPreferences(): SidebarDisplayPreferences {
|
|
const grouping = useSidebarViewStore((state) => state.groupMode);
|
|
const setGrouping = useSidebarViewStore((state) => state.setGroupMode);
|
|
const hostFilters = useSidebarViewStore((state) => state.hostFilters);
|
|
const toggleHostFilter = useSidebarViewStore((state) => state.toggleHostFilter);
|
|
const clearHostFilters = useSidebarViewStore((state) => state.clearHostFilters);
|
|
|
|
const {
|
|
settings: { workspaceTitleSource, sidebarWorkspaceTrailing, sidebarRowItems },
|
|
updateSettings,
|
|
} = useAppSettings();
|
|
|
|
const setTitleSource = useCallback(
|
|
(source: WorkspaceTitleSource) => {
|
|
void updateSettings({ workspaceTitleSource: source });
|
|
},
|
|
[updateSettings],
|
|
);
|
|
|
|
const toggleRowItem = useCallback(
|
|
(item: SidebarRowItem) => {
|
|
void updateSettings({
|
|
sidebarRowItems: { ...sidebarRowItems, [item]: !sidebarRowItems[item] },
|
|
});
|
|
},
|
|
[updateSettings, sidebarRowItems],
|
|
);
|
|
|
|
const toggleTrailing = useCallback(
|
|
(choice: SidebarTrailingChoice) => {
|
|
void updateSettings({
|
|
sidebarWorkspaceTrailing: sidebarWorkspaceTrailing === choice ? "none" : choice,
|
|
});
|
|
},
|
|
[updateSettings, sidebarWorkspaceTrailing],
|
|
);
|
|
|
|
return useMemo(
|
|
() => ({
|
|
grouping,
|
|
setGrouping,
|
|
titleSource: workspaceTitleSource,
|
|
setTitleSource,
|
|
rowItems: sidebarRowItems,
|
|
toggleRowItem,
|
|
trailing: sidebarWorkspaceTrailing,
|
|
toggleTrailing,
|
|
hostFilters,
|
|
toggleHostFilter,
|
|
clearHostFilters,
|
|
}),
|
|
[
|
|
grouping,
|
|
setGrouping,
|
|
workspaceTitleSource,
|
|
setTitleSource,
|
|
sidebarRowItems,
|
|
toggleRowItem,
|
|
sidebarWorkspaceTrailing,
|
|
toggleTrailing,
|
|
hostFilters,
|
|
toggleHostFilter,
|
|
clearHostFilters,
|
|
],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Just the row items, for the row renderers. They re-render per workspace, so they subscribe to
|
|
* the one field they use rather than to every preference in the menu.
|
|
*/
|
|
export function useSidebarRowItems(): SidebarRowItems {
|
|
const {
|
|
settings: { sidebarRowItems },
|
|
} = useAppSettings();
|
|
return sidebarRowItems ?? DEFAULT_SIDEBAR_ROW_ITEMS;
|
|
}
|