Sidebar redesign, dropdown fixes, and soft-delete UI #57

Merged
uz1mani merged 50 commits from staging into main 2026-03-19 00:08:16 +00:00
14 changed files with 1587 additions and 309 deletions
Showing only changes of commit 7ed04fb85c - Show all commits

View File

@@ -1,9 +1,12 @@
'use client' 'use client'
import { useState, useCallback } from 'react' import { useState, useCallback } from 'react'
import Sidebar from './Sidebar' import dynamic from 'next/dynamic'
import ContentHeader from './ContentHeader' import ContentHeader from './ContentHeader'
// Load sidebar only on the client — prevents any SSR flash of text/labels
const Sidebar = dynamic(() => import('./Sidebar'), { ssr: false })
export default function DashboardShell({ export default function DashboardShell({
siteId, siteId,
children, children,

View File

@@ -240,16 +240,10 @@ export default function Sidebar({
const [sites, setSites] = useState<Site[]>([]) const [sites, setSites] = useState<Site[]>([])
const [pendingHref, setPendingHref] = useState<string | null>(null) const [pendingHref, setPendingHref] = useState<string | null>(null)
const wasCollapsedRef = useRef(false) const wasCollapsedRef = useRef(false)
const [ready, setReady] = useState(false) // Safe to read localStorage directly — this component is loaded with ssr:false
const [collapsed, setCollapsed] = useState(true) const [collapsed, setCollapsed] = useState(() => {
return localStorage.getItem(SIDEBAR_KEY) !== 'false'
// Read saved state and reveal sidebar in one frame — no flash })
useEffect(() => {
const saved = localStorage.getItem(SIDEBAR_KEY)
if (saved === 'false') setCollapsed(false)
// Reveal after state is set — React batches these, so sidebar appears at correct width
requestAnimationFrame(() => setReady(true))
}, [])
useEffect(() => { listSites().then(setSites).catch(() => {}) }, []) useEffect(() => { listSites().then(setSites).catch(() => {}) }, [])
useEffect(() => { setPendingHref(null); onMobileClose() }, [pathname, onMobileClose]) useEffect(() => { setPendingHref(null); onMobileClose() }, [pathname, onMobileClose])
@@ -340,17 +334,13 @@ export default function Sidebar({
return ( return (
<> <>
{/* Desktop — empty shell until ready, then real content */} {/* Desktop — ssr:false means this only renders on client, no hydration flash */}
{!ready ? (
<div className="hidden md:block shrink-0 border-r border-neutral-200/60 dark:border-neutral-800/60 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl" style={{ width: COLLAPSED }} />
) : (
<aside <aside
className="hidden md:flex flex-col shrink-0 border-r border-neutral-200/60 dark:border-neutral-800/60 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl overflow-hidden" className="hidden md:flex flex-col shrink-0 border-r border-neutral-200/60 dark:border-neutral-800/60 bg-white/90 dark:bg-neutral-900/90 backdrop-blur-xl overflow-hidden"
style={{ width: collapsed ? COLLAPSED : EXPANDED, transition: 'width 200ms cubic-bezier(0.4, 0, 0.2, 1)' }} style={{ width: collapsed ? COLLAPSED : EXPANDED, transition: 'width 200ms cubic-bezier(0.4, 0, 0.2, 1)' }}
> >
{sidebarContent(false)} {sidebarContent(false)}
</aside> </aside>
)}
{/* Mobile overlay */} {/* Mobile overlay */}
{mobileOpen && ( {mobileOpen && (