Skip to content

Commit

Permalink
test adding new theme toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanie56 committed Apr 19, 2024
1 parent c3d3b33 commit c849daf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions apps/demo/app/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ import { useIsScrolled } from '../../hooks/use-is-scrolled';
type IconType = React.ComponentType<React.SVGProps<SVGSVGElement>>;

const modes = ['dark-mode', 'light-mode'];
const themes = ['saddles', 'photostop'];
/** This should be integrated into a Page layout component, currently a WIP in design */
const pageMaxWidth = 1280;

export default function Index() {
const [mode, setMode] = useState(1);
const [theme, setTheme] = useState(1);
const isScrolled = useIsScrolled();

const toggleMode = () => {
Expand All @@ -44,6 +46,13 @@ export default function Index() {
setMode(mode ^ 1);
};

const toggleTheme = () => {
const themeElement = document.querySelector(`.${themes[theme]}`);
themeElement?.classList.remove(themes[theme]);
themeElement?.classList.add(themes[theme ^ 1]);
setTheme(theme ^ 1);
};

return (
<RadiusAutoLayout
direction="vertical"
Expand Down Expand Up @@ -91,6 +100,15 @@ export default function Index() {
onClick: toggleMode,
icon: (mode ? DarkMode : LightMode) as IconType,
},
{
'aria-label': theme
? 'Switch to New Theme'
: 'Switch to Default Theme',
title: theme ? 'Switch to New Theme' : 'Switch to Default Theme',
as: 'button',
onClick: toggleTheme,
icon: (theme ? DarkMode : LightMode) as IconType,
},
]}
logos={
<>
Expand Down

0 comments on commit c849daf

Please sign in to comment.