Random themes

This commit is contained in:
Sean Edmunds
2024-12-05 16:32:28 -06:00
parent 62b2f4c661
commit 00c141d8d7
2 changed files with 55 additions and 2 deletions

View File

@@ -39,8 +39,13 @@ function App() {
const [theme, setTheme] = useAtom(appTheme);
useEffect(() => {
if (data && themeName) {
const temp = data.find((t: any) => t.name === themeName);
setTheme(temp);
if (themeName !== 'random') {
const temp = data.find((t: any) => t.name === themeName);
setTheme(temp);
} else {
const index = Math.floor(Math.random() * data.length);
setTheme(data[index]);
}
}
}, [isFetched, themeName]);