umami/components/layout/Page.js
2023-04-01 15:44:30 -07:00

19 lines
562 B
JavaScript

import classNames from 'classnames';
import { Banner, Loading } from 'react-basics';
import useMessages from 'hooks/useMessages';
import styles from './Page.module.css';
export default function Page({ className, error, loading, children }) {
const { formatMessage, messages } = useMessages();
if (error) {
return <Banner variant="error">{formatMessage(messages.error)}</Banner>;
}
if (loading) {
return <Loading icon="spinner" size="xl" position="page" />;
}
return <div className={classNames(styles.page, className)}>{children}</div>;
}