feat: add loader to views

This commit is contained in:
Carlos Valente
2024-10-07 12:00:26 +02:00
committed by Carlos Valente
parent bad9dab0a0
commit 4cba970cda
12 changed files with 186 additions and 115 deletions
+32
View File
@@ -0,0 +1,32 @@
import { PropsWithChildren } from 'react';
import { overrideStylesURL } from '../common/api/constants';
import { useRuntimeStylesheet } from '../common/hooks/useRuntimeStylesheet';
import useViewSettings from '../common/hooks-query/useViewSettings';
import style from './ViewLoader.module.scss';
export default function ViewLoader({ children }: PropsWithChildren) {
const { data } = useViewSettings();
const { shouldRender } = useRuntimeStylesheet(data.overrideStyles && overrideStylesURL);
// eventually we would want to leverage suspense here
// while the feature is not ready, we simply trigger a loader
// suspense would have the advantage of being triggered also by react-query
if (!shouldRender) {
return (
<div className={style.loader}>
<div className={style.ellipsis}>
<div />
<div />
<div />
<div />
</div>
</div>
);
}
// eslint-disable-next-line react/jsx-no-useless-fragment -- ensuring JSX return
return <>{children}</>;
}