Skip to content

Commit 16a0a7c

Browse files
authored
feat(frontend): move theme switch to Settings → Appearance page (floci-io#216)
The light/dark toggle was hard to find in the topbar. Move it into a dedicated Settings page under Appearance. Add /settings route and sidebar nav item. Extract shared theme state into a zustand store so Layout and SettingsPage stay in sync. Closes floci-io#213 ## Summary <!-- What does this PR do? Link any related issues with "Closes #N" --> ## Type of change - [ ] Bug fix (`fix:`) - [ ] New feature / service UI (`feat:`) - [ ] Breaking change (`feat!:` or `fix!:`) - [ ] Docs / chore ## Area - [ ] Frontend (`packages/frontend`) - [ ] API / Cloud Proxy (`packages/api`) - [ ] Cloud Explorer adapter / schema - [ ] Build / CI / Docker ## Verification <!-- How did you verify this? Which cloud + service did you test against (e.g. AWS S3 via Floci core, Azure Blob via Floci-AZ)? --> <!-- For UI changes, please attach before/after screenshots. --> ## Checklist - [ ] `pnpm lint`, `pnpm type-check`, `pnpm test`, and `pnpm build` pass locally - [ ] New or updated tests added where it makes sense (`bun test` in `packages/api`) - [ ] No fake/mock data added — unwired states stay empty or show an explicit placeholder - [ ] Commit messages / PR title follow [Conventional Commits](https://www.conventionalcommits.org/)
1 parent b1fa147 commit 16a0a7c

5 files changed

Lines changed: 222 additions & 20 deletions

File tree

‎packages/frontend/src/App.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {SecretsManagerPage} from '@/features/secretsmanager/SecretsManagerPage'
44
import {CloudExplorerPage} from '@/pages/CloudExplorerPage'
55
import {CloudConsoleHomePage} from '@/pages/CloudConsoleHomePage'
66
import {DatabaseDataPage} from '@/pages/DatabaseDataPage'
7+
import {SettingsPage} from '@/pages/SettingsPage'
78

89
export default function App() {
910
return (
@@ -18,6 +19,8 @@ export default function App() {
1819
<Route path="/cloud-explorer/:cloud/:service" element={<CloudExplorerPage/>}/>
1920
<Route path="/cloud-explorer/:cloud/:service/:resourceId/data" element={<DatabaseDataPage/>}/>
2021
<Route path="/secretsmanager" element={<SecretsManagerPage/>}/>
22+
<Route path="/console/:cloud/settings" element={<SettingsPage/>}/>
23+
<Route path="/settings" element={<SettingsPage/>}/>
2124
<Route path="*" element={<Navigate to="/console/aws" replace/>}/>
2225
</Route>
2326
</Routes>

‎packages/frontend/src/components/Layout.tsx‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {NavLink, Outlet, useLocation, useSearchParams} from 'react-router-dom'
2-
import {AlertTriangle, ChevronsLeft, ChevronsRight, LayoutDashboard, Moon, Search, Sun} from 'lucide-react'
2+
import {AlertTriangle, ChevronsLeft, ChevronsRight, LayoutDashboard, Search, Settings} from 'lucide-react'
33
import {useCallback, useEffect, useRef, useState} from 'react'
44
import flociWhite from '@/assets/floci-white.svg'
55
import flociBlack from '@/assets/floci-black.svg'
@@ -161,7 +161,7 @@ function groupByGroup(services: CloudServiceDescriptor[]): Array<[string, CloudS
161161
export function Layout() {
162162
const location = useLocation()
163163
const activeCloud = activeCloudFromPath(location.pathname)
164-
const {theme, toggle} = useTheme()
164+
const {theme} = useTheme()
165165
const {collapsed, toggle: toggleSidebar, toggleRef} = useSidebar()
166166
const isDark = theme === 'dark'
167167
const {data, isError} = useQuery({
@@ -189,6 +189,7 @@ export function Layout() {
189189
<div className="nav-section">
190190
<span className="nav-label">General</span>
191191
<NavItem to={`/console/${activeCloud}`} icon={LayoutDashboard} label="Console Home" collapsed={collapsed}/>
192+
<NavItem to={`/console/${activeCloud}/settings`} icon={Settings} label="Settings" collapsed={collapsed}/>
192193
</div>
193194
<CloudServiceNav collapsed={collapsed}/>
194195
</nav>
@@ -213,15 +214,6 @@ export function Layout() {
213214
<div className="shell">
214215
<header className="topbar">
215216
<TopbarSearch/>
216-
<button
217-
className="icon-btn"
218-
type="button"
219-
onClick={toggle}
220-
title={isDark ? 'Switch to light theme' : 'Switch to dark theme'}
221-
aria-label={isDark ? 'Switch to light theme' : 'Switch to dark theme'}
222-
>
223-
{isDark ? <Sun size={14} aria-hidden="true"/> : <Moon size={14} aria-hidden="true"/>}
224-
</button>
225217
<div id="topbar-status" className="topbar-status"/>
226218
<AccountSwitcher/>
227219
<div className={`connection ${isConnected ? 'connected' : 'disconnected'}`}>

‎packages/frontend/src/index.css‎

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4150,3 +4150,155 @@ button.console-service-card {
41504150
grid-template-rows: auto auto;
41514151
}
41524152
}
4153+
/* ── Settings page ── */
4154+
4155+
.settings-section {
4156+
border: 1px solid var(--border);
4157+
border-radius: 6px;
4158+
background: var(--surface);
4159+
}
4160+
4161+
.settings-section h3 {
4162+
margin: 0;
4163+
padding: 12px 16px;
4164+
border-bottom: 1px solid var(--border-faint);
4165+
color: var(--text-bright);
4166+
font-size: 13px;
4167+
font-weight: 600;
4168+
}
4169+
4170+
.settings-row {
4171+
display: flex;
4172+
align-items: center;
4173+
justify-content: space-between;
4174+
gap: 16px;
4175+
padding: 14px 16px;
4176+
}
4177+
4178+
.settings-row + .settings-row {
4179+
border-top: 1px solid var(--border-faint);
4180+
}
4181+
4182+
.settings-row-text {
4183+
display: grid;
4184+
gap: 2px;
4185+
min-width: 0;
4186+
}
4187+
4188+
.settings-label {
4189+
color: var(--text);
4190+
font-size: 13px;
4191+
font-weight: 500;
4192+
}
4193+
4194+
.settings-description {
4195+
color: var(--text-3);
4196+
font-size: 11px;
4197+
}
4198+
4199+
.settings-toggle-group {
4200+
display: flex;
4201+
border: 1px solid var(--border);
4202+
border-radius: 4px;
4203+
overflow: hidden;
4204+
}
4205+
4206+
.settings-toggle-btn {
4207+
padding: 5px 14px;
4208+
border: 0;
4209+
background: transparent;
4210+
color: var(--text-2);
4211+
font-size: 12px;
4212+
cursor: pointer;
4213+
transition: background 120ms, color 120ms;
4214+
}
4215+
4216+
.settings-toggle-btn + .settings-toggle-btn {
4217+
border-left: 1px solid var(--border);
4218+
}
4219+
4220+
.settings-toggle-btn:hover {
4221+
background: var(--hover);
4222+
}
4223+
4224+
.settings-toggle-btn.active {
4225+
background: var(--accent-tint);
4226+
color: var(--text-bright);
4227+
font-weight: 600;
4228+
}
4229+
/* ── Settings page ── */
4230+
4231+
.settings-section {
4232+
border: 1px solid var(--border);
4233+
border-radius: 6px;
4234+
background: var(--surface);
4235+
}
4236+
4237+
.settings-section h3 {
4238+
margin: 0;
4239+
padding: 12px 16px;
4240+
border-bottom: 1px solid var(--border-faint);
4241+
color: var(--text-bright);
4242+
font-size: 13px;
4243+
font-weight: 600;
4244+
}
4245+
4246+
.settings-row {
4247+
display: flex;
4248+
align-items: center;
4249+
justify-content: space-between;
4250+
gap: 16px;
4251+
padding: 14px 16px;
4252+
}
4253+
4254+
.settings-row + .settings-row {
4255+
border-top: 1px solid var(--border-faint);
4256+
}
4257+
4258+
.settings-row-text {
4259+
display: grid;
4260+
gap: 2px;
4261+
min-width: 0;
4262+
}
4263+
4264+
.settings-label {
4265+
color: var(--text);
4266+
font-size: 13px;
4267+
font-weight: 500;
4268+
}
4269+
4270+
.settings-description {
4271+
color: var(--text-3);
4272+
font-size: 11px;
4273+
}
4274+
4275+
.settings-toggle-group {
4276+
display: flex;
4277+
border: 1px solid var(--border);
4278+
border-radius: 4px;
4279+
overflow: hidden;
4280+
}
4281+
4282+
.settings-toggle-btn {
4283+
padding: 5px 14px;
4284+
border: 0;
4285+
background: transparent;
4286+
color: var(--text-2);
4287+
font-size: 12px;
4288+
cursor: pointer;
4289+
transition: background 120ms, color 120ms;
4290+
}
4291+
4292+
.settings-toggle-btn + .settings-toggle-btn {
4293+
border-left: 1px solid var(--border);
4294+
}
4295+
4296+
.settings-toggle-btn:hover {
4297+
background: var(--hover);
4298+
}
4299+
4300+
.settings-toggle-btn.active {
4301+
background: var(--accent-tint);
4302+
color: var(--text-bright);
4303+
font-weight: 600;
4304+
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
import {useEffect, useState} from 'react'
1+
import {useEffect} from 'react'
2+
import {create} from 'zustand'
23

34
type Theme = 'dark' | 'light'
45

5-
function getStored(): Theme {
6-
const v = localStorage.getItem('floci-theme')
7-
return v === 'light' ? 'light' : 'dark'
8-
}
6+
const useThemeStore = create<{
7+
theme: Theme
8+
setTheme: (theme: Theme) => void
9+
}>()((set) => ({
10+
theme: (localStorage.getItem('floci-theme') === 'light' ? 'light' : 'dark') as Theme,
11+
setTheme: (theme) => set({theme}),
12+
}))
913

14+
/** Subscribe to theme changes and apply to DOM + localStorage. */
1015
export function useTheme() {
11-
const [theme, setTheme] = useState<Theme>(getStored)
16+
const theme = useThemeStore((s) => s.theme)
17+
const setTheme = useThemeStore((s) => s.setTheme)
1218

1319
useEffect(() => {
1420
document.documentElement.setAttribute('data-theme', theme)
1521
localStorage.setItem('floci-theme', theme)
1622
}, [theme])
1723

18-
const toggle = () => setTheme(t => t === 'dark' ? 'light' : 'dark')
19-
20-
return {theme, toggle}
24+
return {theme, setTheme}
2125
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import {Settings} from 'lucide-react'
2+
import {useTheme} from '@/lib/useTheme'
3+
4+
export function SettingsPage() {
5+
const {theme, setTheme} = useTheme()
6+
7+
return (
8+
<>
9+
<div className="page-header">
10+
<div className="page-title">
11+
<Settings size={20}/>
12+
<div>
13+
<h2>Settings</h2>
14+
<p className="muted">Application preferences</p>
15+
</div>
16+
</div>
17+
</div>
18+
<div className="content">
19+
<div className="settings-section">
20+
<h3>Appearance</h3>
21+
<div className="settings-row">
22+
<div className="settings-row-text">
23+
<span className="settings-label">Theme</span>
24+
<span className="settings-description">Switch between light and dark mode</span>
25+
</div>
26+
<div className="settings-toggle-group" role="radiogroup" aria-label="Theme">
27+
<button
28+
type="button"
29+
className={`settings-toggle-btn${theme === 'dark' ? ' active' : ''}`}
30+
role="radio"
31+
aria-checked={theme === 'dark'}
32+
onClick={() => setTheme('dark')}
33+
>
34+
Dark
35+
</button>
36+
<button
37+
type="button"
38+
className={`settings-toggle-btn${theme === 'light' ? ' active' : ''}`}
39+
role="radio"
40+
aria-checked={theme === 'light'}
41+
onClick={() => setTheme('light')}
42+
>
43+
Light
44+
</button>
45+
</div>
46+
</div>
47+
</div>
48+
</div>
49+
</>
50+
)
51+
}

0 commit comments

Comments
 (0)