Skip to content

Commit 9982e3b

Browse files
committed
refactor: use CSS variables for layout dimensions
Replaced hardcoded Tailwind classes with CSS variables for maintainability: - --navbar-height: 3.5rem (56px) - --sidebar-width: 15rem (240px) - --sidebar-width-collapsed: 4rem (64px) Now if navbar height changes, update ONE variable instead of hunting through multiple files. Uses Tailwind arbitrary values syntax: h-[var(--navbar-height)], pt-[var(--navbar-height)], etc. Files updated: - index.css: Added layout CSS variables - TopNav.tsx: h-14 → h-[var(--navbar-height)] - DashboardLayout.tsx: pt-14, ml-16/60 → CSS variables - Sidebar.tsx: top-14, w-16/60 → CSS variables
1 parent 55919b6 commit 9982e3b

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

frontend/src/components/dashboard/DashboardLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export function DashboardLayout({ children }: DashboardLayoutProps) {
5757
/>
5858

5959
<main
60-
className={`flex-1 transition-all duration-300 pt-14 ${
61-
sidebarCollapsed ? 'ml-16' : 'ml-60'
60+
className={`flex-1 transition-all duration-300 pt-[var(--navbar-height)] ${
61+
sidebarCollapsed ? 'ml-[var(--sidebar-width-collapsed)]' : 'ml-[var(--sidebar-width)]'
6262
}`}
6363
>
6464
<div className="p-6">

frontend/src/components/dashboard/Sidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ export function Sidebar({ collapsed, onToggle }: SidebarProps) {
8888
return (
8989
<aside
9090
className={`
91-
fixed left-0 top-14 bottom-0 z-40
91+
fixed left-0 top-[var(--navbar-height)] bottom-0 z-40
9292
flex flex-col border-r border-border bg-background
9393
transition-all duration-300
94-
${collapsed ? 'w-16' : 'w-60'}
94+
${collapsed ? 'w-[var(--sidebar-width-collapsed)]' : 'w-[var(--sidebar-width)]'}
9595
`}
9696
>
9797
<nav className="flex-1 p-3 space-y-1">

frontend/src/components/dashboard/TopNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function TopNav({ onToggleSidebar, sidebarCollapsed, onOpenCommandPalette
3434
}
3535

3636
return (
37-
<nav className="fixed top-0 left-0 right-0 z-50 h-14 border-b border-border bg-background/80 backdrop-blur-xl">
37+
<nav className="fixed top-0 left-0 right-0 z-50 h-[var(--navbar-height)] border-b border-border bg-background/80 backdrop-blur-xl">
3838
<div className="h-full px-4 flex items-center justify-between">
3939
{/* Left Section */}
4040
<div className="flex items-center gap-4">

frontend/src/index.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ html {
1717

1818
@layer base {
1919
:root {
20+
/* Layout */
21+
--navbar-height: 3.5rem; /* 56px = h-14 */
22+
--sidebar-width: 15rem; /* 240px = w-60 */
23+
--sidebar-width-collapsed: 4rem; /* 64px = w-16 */
24+
2025
/* Background */
2126
--color-bg-primary: #09090b;
2227
--color-bg-secondary: #0f0f11;

0 commit comments

Comments
 (0)