first commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
/** Public assets in `public/` — filenames must match deployed files. */
|
||||
const LOGO_LIGHT = '/logo-light.png';
|
||||
const LOGO_DARK = '/logo-dark.png';
|
||||
|
||||
export function rivusLogoSrc(isDark: boolean): string {
|
||||
return isDark ? LOGO_DARK : LOGO_LIGHT;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
export type SectionId =
|
||||
| 'services'
|
||||
| 'adaptivework'
|
||||
| 'process'
|
||||
| 'whyus'
|
||||
| 'contact';
|
||||
|
||||
export const NAV_SECTIONS: { id: SectionId; labelKey: `nav.${string}` }[] = [
|
||||
{ id: 'services', labelKey: 'nav.services' },
|
||||
{ id: 'adaptivework', labelKey: 'nav.adaptivework' },
|
||||
{ id: 'process', labelKey: 'nav.process' },
|
||||
{ id: 'whyus', labelKey: 'nav.whyus' },
|
||||
{ id: 'contact', labelKey: 'nav.contact' },
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
export const THEME_STORAGE_KEY = 'rivus-theme';
|
||||
|
||||
export type StoredTheme = 'light' | 'dark';
|
||||
|
||||
export function getStoredTheme(): StoredTheme | null {
|
||||
const raw = localStorage.getItem(THEME_STORAGE_KEY);
|
||||
if (raw === 'light' || raw === 'dark') return raw;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveDark(stored: string | null, prefersDark: boolean): boolean {
|
||||
if (stored === 'dark') return true;
|
||||
if (stored === 'light') return false;
|
||||
return prefersDark;
|
||||
}
|
||||
|
||||
export function applyTheme(isDark: boolean): void {
|
||||
document.documentElement.dataset.theme = isDark ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
export function readEffectiveDark(): boolean {
|
||||
return document.documentElement.dataset.theme === 'dark';
|
||||
}
|
||||
|
||||
export function toggleStoredTheme(): boolean {
|
||||
const nextDark = !readEffectiveDark();
|
||||
localStorage.setItem(THEME_STORAGE_KEY, nextDark ? 'dark' : 'light');
|
||||
applyTheme(nextDark);
|
||||
return nextDark;
|
||||
}
|
||||
Reference in New Issue
Block a user