feat(webui): in-place dashboard edit overlays + inline sidebar reorder
Rework the layout edit mode from a separate panel to in-place affordances: - Each dashboard widget gets a semi-transparent floating overlay in edit mode: a "拖动" grip bar (the whole card is the drag target — forgiving + discoverable), an eye to show/hide, and a gear that opens the per-widget settings in a dialog. Hidden widgets show as re-enableable "已隐藏" ghosts; the bottom-right resize grip is now clearly visible. - The sidebar nav becomes a drag-to-reorder list directly in the sidebar (show/hide + locked pinned items + a 完成 button); editing force-expands the sidebar (and disables the collapse toggle). Edit mode is a shared LayoutContext flag so one "编辑布局" toggle drives both the grid and the nav. - The separate editor panel (overview-layout-editor) is removed; the gear opens config in a dialog instead. Also: stat-tile typography tightened (leading-tight, smaller value, overflow clip) so text no longer hugs the edge on small/short tiles. Verified by an adversarial review round (no MUST-FIX).
This commit is contained in:
9 files changed
+339
-349
No files matched your search
@@ -7,6 +7,7 @@ import { Sidebar } from '@/components/layout/sidebar';
|
||||
import { TopBar } from '@/components/layout/top-bar';
|
||||
import { useMediaQuery } from '@/hooks/use-media-query';
|
||||
import { useTheme } from '@/contexts/ThemeContext';
|
||||
import { useLayout } from '@/contexts/LayoutContext';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface MainLayoutProps {
|
||||
@@ -27,6 +28,10 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
|
||||
return appearance.sidebarDefaultCollapsed;
|
||||
});
|
||||
const customBg = appearance.background.type !== 'none';
|
||||
const { editing } = useLayout();
|
||||
// Force the sidebar open while editing layout so its drag-to-reorder list
|
||||
// has room (it returns to the user's collapsed pref on 完成).
|
||||
const effectiveCollapsed = collapsed && !editing;
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const pathname = useRouterState({ select: (s) => s.location.pathname });
|
||||
|
||||
@@ -40,11 +45,11 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
|
||||
{!isMobile && (
|
||||
<motion.aside
|
||||
initial={false}
|
||||
animate={{ width: collapsed ? 64 : 248 }}
|
||||
animate={{ width: effectiveCollapsed ? 64 : 248 }}
|
||||
transition={{ type: 'spring', stiffness: 280, damping: 32 }}
|
||||
className="relative h-full shrink-0 border-r overflow-hidden"
|
||||
>
|
||||
<Sidebar collapsed={collapsed} />
|
||||
<Sidebar collapsed={effectiveCollapsed} />
|
||||
</motion.aside>
|
||||
)}
|
||||
|
||||
@@ -66,11 +71,12 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
|
||||
<div className="flex min-w-0 flex-1 flex-col">
|
||||
<TopBar
|
||||
status={status}
|
||||
collapsed={collapsed}
|
||||
collapsed={effectiveCollapsed}
|
||||
onToggleCollapse={() => setCollapsed((v) => !v)}
|
||||
onOpenMobile={() => setMobileOpen(true)}
|
||||
onLogout={onLogout}
|
||||
isMobile={isMobile}
|
||||
editing={editing}
|
||||
/>
|
||||
|
||||
<main className={cn('flex min-h-0 flex-1 flex-col')}>
|
||||
|
||||
Reference in new issue
Block a user