umami/components/layout/Page.js

19 lines
562 B
JavaScript
Raw Normal View History

2020-09-27 09:51:29 +02:00
import classNames from 'classnames';
import { Banner, Loading } from 'react-basics';
2023-04-02 00:44:30 +02:00
import useMessages from 'hooks/useMessages';
2023-03-22 05:28:36 +01:00
import styles from './Page.module.css';
export default function Page({ className, error, loading, children }) {
2023-04-02 00:44:30 +02:00
const { formatMessage, messages } = useMessages();
if (error) {
2023-04-02 00:44:30 +02:00
return <Banner variant="error">{formatMessage(messages.error)}</Banner>;
}
if (loading) {
2023-01-10 08:59:26 +01:00
return <Loading icon="spinner" size="xl" position="page" />;
}
2020-08-06 04:04:02 +02:00
2022-08-23 09:51:37 +02:00
return <div className={classNames(styles.page, className)}>{children}</div>;
2020-08-06 04:04:02 +02:00
}