feat(ui): add UI scale selector (100% / 110% / 125%)
Three-level zoom control in sidebar footer. Uses CSS zoom property, persisted to localStorage via Zustand store. Applied on mount via AppLayout useEffect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
import { type ReactNode } from 'react'
|
import { type ReactNode, useEffect } from 'react'
|
||||||
import { Sidebar } from './Sidebar'
|
import { Sidebar } from './Sidebar'
|
||||||
import { ShortcutsDialog } from './ShortcutsDialog'
|
import { ShortcutsDialog } from './ShortcutsDialog'
|
||||||
import { CommandPalette } from '@/components/command-palette/CommandPalette'
|
import { CommandPalette } from '@/components/command-palette/CommandPalette'
|
||||||
import { Toaster } from '@/components/ui/toast'
|
import { Toaster } from '@/components/ui/toast'
|
||||||
|
import { useUIStore } from '@/lib/store'
|
||||||
|
|
||||||
interface AppLayoutProps {
|
interface AppLayoutProps {
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AppLayout({ children }: AppLayoutProps) {
|
export function AppLayout({ children }: AppLayoutProps) {
|
||||||
|
// Apply persisted UI scale on mount
|
||||||
|
const uiScale = useUIStore((s) => s.uiScale)
|
||||||
|
useEffect(() => {
|
||||||
|
document.documentElement.style.zoom = `${uiScale}%`
|
||||||
|
}, [uiScale])
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen overflow-hidden bg-background">
|
<div className="flex h-screen overflow-hidden bg-background">
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ export function Sidebar() {
|
|||||||
setSelectedTenantId,
|
setSelectedTenantId,
|
||||||
theme,
|
theme,
|
||||||
setTheme,
|
setTheme,
|
||||||
|
uiScale,
|
||||||
|
setUIScale,
|
||||||
} = useUIStore()
|
} = useUIStore()
|
||||||
const { connectionState } = useEventStreamContext()
|
const { connectionState } = useEventStreamContext()
|
||||||
const routerState = useRouterState()
|
const routerState = useRouterState()
|
||||||
@@ -418,6 +420,23 @@ export function Sidebar() {
|
|||||||
<LogOut className="h-3 w-3" />
|
<LogOut className="h-3 w-3" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Scale selector */}
|
||||||
|
<div className="flex items-center gap-px rounded-[var(--radius-control)] border border-border-subtle overflow-hidden mb-1">
|
||||||
|
{([100, 110, 125] as const).map((s) => (
|
||||||
|
<button
|
||||||
|
key={s}
|
||||||
|
onClick={() => setUIScale(s)}
|
||||||
|
className={cn(
|
||||||
|
'flex-1 text-[8px] py-px text-center transition-[background-color,color] duration-[50ms]',
|
||||||
|
uiScale === s
|
||||||
|
? 'bg-accent-soft text-text-primary font-medium'
|
||||||
|
: 'text-text-muted hover:text-text-secondary',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{s}%
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
{/* Connection + version row */}
|
{/* Connection + version row */}
|
||||||
<div className="flex items-center gap-1.5">
|
<div className="flex items-center gap-1.5">
|
||||||
<span
|
<span
|
||||||
|
|||||||
@@ -2,17 +2,21 @@ import { create } from 'zustand'
|
|||||||
import { persist } from 'zustand/middleware'
|
import { persist } from 'zustand/middleware'
|
||||||
import { applyTheme } from './theme'
|
import { applyTheme } from './theme'
|
||||||
|
|
||||||
|
type UIScale = 100 | 110 | 125
|
||||||
|
|
||||||
interface UIState {
|
interface UIState {
|
||||||
selectedTenantId: string | null
|
selectedTenantId: string | null
|
||||||
sidebarCollapsed: boolean
|
sidebarCollapsed: boolean
|
||||||
mobileSidebarOpen: boolean
|
mobileSidebarOpen: boolean
|
||||||
theme: 'dark' | 'light'
|
theme: 'dark' | 'light'
|
||||||
|
uiScale: UIScale
|
||||||
|
|
||||||
setSelectedTenantId: (id: string | null) => void
|
setSelectedTenantId: (id: string | null) => void
|
||||||
setSidebarCollapsed: (collapsed: boolean) => void
|
setSidebarCollapsed: (collapsed: boolean) => void
|
||||||
toggleSidebar: () => void
|
toggleSidebar: () => void
|
||||||
setMobileSidebarOpen: (open: boolean) => void
|
setMobileSidebarOpen: (open: boolean) => void
|
||||||
setTheme: (theme: 'dark' | 'light') => void
|
setTheme: (theme: 'dark' | 'light') => void
|
||||||
|
setUIScale: (scale: UIScale) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUIStore = create<UIState>()(
|
export const useUIStore = create<UIState>()(
|
||||||
@@ -22,6 +26,7 @@ export const useUIStore = create<UIState>()(
|
|||||||
sidebarCollapsed: false,
|
sidebarCollapsed: false,
|
||||||
mobileSidebarOpen: false,
|
mobileSidebarOpen: false,
|
||||||
theme: 'dark',
|
theme: 'dark',
|
||||||
|
uiScale: 100,
|
||||||
|
|
||||||
setSelectedTenantId: (id) => set({ selectedTenantId: id }),
|
setSelectedTenantId: (id) => set({ selectedTenantId: id }),
|
||||||
setSidebarCollapsed: (collapsed) => set({ sidebarCollapsed: collapsed }),
|
setSidebarCollapsed: (collapsed) => set({ sidebarCollapsed: collapsed }),
|
||||||
@@ -31,6 +36,10 @@ export const useUIStore = create<UIState>()(
|
|||||||
applyTheme(theme)
|
applyTheme(theme)
|
||||||
set({ theme })
|
set({ theme })
|
||||||
},
|
},
|
||||||
|
setUIScale: (scale) => {
|
||||||
|
document.documentElement.style.zoom = `${scale}%`
|
||||||
|
set({ uiScale: scale })
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
name: 'tod-ui-state',
|
name: 'tod-ui-state',
|
||||||
@@ -38,6 +47,7 @@ export const useUIStore = create<UIState>()(
|
|||||||
sidebarCollapsed: state.sidebarCollapsed,
|
sidebarCollapsed: state.sidebarCollapsed,
|
||||||
theme: state.theme,
|
theme: state.theme,
|
||||||
selectedTenantId: state.selectedTenantId,
|
selectedTenantId: state.selectedTenantId,
|
||||||
|
uiScale: state.uiScale,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user