Style bug hotfix and Loader testing

This commit is contained in:
Sean Edmunds
2025-04-10 15:36:59 -05:00
parent b0f003f476
commit 12f6ac82a0
5 changed files with 53 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import {
mergeMantineTheme, mergeMantineTheme,
} from '@mantine/core'; } from '@mantine/core';
import { useCommonHooks, useQueryAPI } from 'hooks'; import { useCommonHooks, useQueryAPI } from 'hooks';
import { useEffect } from 'react'; import { useEffect, useState } from 'react';
import { import {
Navigate, Navigate,
Route, Route,
@@ -17,6 +17,7 @@ import { MainLayout, ThemeProvider } from './components';
import '@mantine/core/styles.css'; //import Mantine V7 styles needed by MRT import '@mantine/core/styles.css'; //import Mantine V7 styles needed by MRT
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import './index.css'; import './index.css';
import Loading from 'components/Loading';
import { Homepage, Settings } from 'pages'; import { Homepage, Settings } from 'pages';
import { ToastContainer } from 'react-toastify'; import { ToastContainer } from 'react-toastify';
import type { Theme, ThemePlaylist } from 'types'; import type { Theme, ThemePlaylist } from 'types';
@@ -30,6 +31,7 @@ function App() {
}); });
const { theme, setTheme, themeName, handleThemeChange, currentThemePlaylist } = const { theme, setTheme, themeName, handleThemeChange, currentThemePlaylist } =
useCommonHooks(); useCommonHooks();
const [loaded, setLoaded] = useState(false);
const overrides = createTheme({ const overrides = createTheme({
white: theme?.backgroundColor, white: theme?.backgroundColor,
fontFamily: '-apple-system,Jost,BlinkMacSystemFont,Helvetica Neue,Roboto,sans-serif', fontFamily: '-apple-system,Jost,BlinkMacSystemFont,Helvetica Neue,Roboto,sans-serif',
@@ -64,6 +66,7 @@ function App() {
if (themeName !== 'random') { if (themeName !== 'random') {
const temp = allThemes.find((t: Theme) => t.name === themeName); const temp = allThemes.find((t: Theme) => t.name === themeName);
setTheme(temp); setTheme(temp);
setLoaded(true);
} else { } else {
handleThemeChange(allThemes, false); handleThemeChange(allThemes, false);
} }
@@ -78,6 +81,7 @@ function App() {
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]), t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
), ),
); );
setLoaded(true);
} else { } else {
const themeList = JSON.parse( const themeList = JSON.parse(
themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist) themePlaylists.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
@@ -85,6 +89,7 @@ function App() {
); );
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id)); const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
setTheme('random'); setTheme('random');
setLoaded(true);
handleThemeChange(filteredThemes, false); handleThemeChange(filteredThemes, false);
} }
} }
@@ -96,6 +101,7 @@ function App() {
<MantineProvider theme={mantineTheme}> <MantineProvider theme={mantineTheme}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<ToastContainer /> <ToastContainer />
<Loading loaded={loaded} />
<RouterProvider router={router} /> <RouterProvider router={router} />
<ReactQueryDevtools initialIsOpen={false} /> <ReactQueryDevtools initialIsOpen={false} />
</ThemeProvider> </ThemeProvider>

View File

@@ -0,0 +1,21 @@
import { Center, Loader, Stack } from '@mantine/core';
import { stackClasses } from 'styles';
function Loading({ loaded }: any) {
return (
<Stack
align='center'
justify='center'
pos={'fixed'}
className={stackClasses.fadeAway}
classNames={stackClasses}
data-loaded={loaded}
>
<Center>
<Loader color={'gray'} size='xl' />
</Center>
</Stack>
);
}
export default Loading;

View File

@@ -1,5 +1,14 @@
import { atom } from 'jotai'; import { atom } from 'jotai';
const appTheme = atom<any>({}); const appTheme = atom<any>({
id: undefined,
name: 'default',
backgroundImage: 'none',
backgroundColor: '#EEEEEE',
searchColor: '#00000033',
primaryColor: '#222222',
accentColor: '#5c5c5c',
borderColor: '#5c5c5c',
});
export { appTheme }; export { appTheme };

View File

@@ -92,7 +92,6 @@ function SettingsButton() {
setAllThemeData(allThemes); setAllThemeData(allThemes);
} }
}, [allThemes, isAllThemesFetched]); }, [allThemes, isAllThemesFetched]);
return ( return (
<> <>
{overlayOpened && <Overlay pos={'fixed'} />} {overlayOpened && <Overlay pos={'fixed'} />}
@@ -189,7 +188,7 @@ function SettingsButton() {
style={{ style={{
backgroundColor: backgroundColor:
currentTheme === 'random' currentTheme === 'random'
? `${theme.searchColor === theme.primaryColor ? theme.searchColor.substring(0, 7) : theme.primaryColor.substring(0, 7)}88` ? `${theme?.searchColor === theme.primaryColor ? theme.searchColor?.substring(0, 7) : theme.primaryColor?.substring(0, 7)}88`
: 'transparent', : 'transparent',
color: color:
currentTheme === 'random' currentTheme === 'random'

View File

@@ -53,3 +53,17 @@
background-color: var(--color-search-background); background-color: var(--color-search-background);
border-radius: 10px; border-radius: 10px;
} }
.fadeAway {
background-color: #121212;
transition: all .5s ease-in-out;
height: 100vh;
width: 100%;
opacity: 1;
display: flex;
backdrop-filter: blur(5px);
&[data-loaded="true"] {
opacity: 0;
z-index: -1;
}
}