UNPKG

@craftercms/studio-ui

Version:

Services, components, models & utils to build CrafterCMS authoring extensions.

98 lines (96 loc) 3.3 kB
/* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* * Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import React from 'react'; import { makeStyles } from 'tss-react/mui'; import Typography from '@mui/material/Typography'; import Gears from '../Gears/Gears'; const useStyles = makeStyles()((theme, { root, graphicRoot, title, subtitle, graphic } = {}) => ({ root: { display: 'flex', textAlign: 'center', alignItems: 'center', flexDirection: 'column', justifyContent: 'center', margin: `${theme.spacing(2)} auto`, minHeight: '100%', ...root }, graphicRoot: { display: 'flex', justifyContent: 'center', ...graphicRoot }, title: { marginTop: '40px', marginBottom: '15px', ...title }, subtitle: { marginBottom: '10px', ...subtitle }, graphic: { width: 120, ...graphic } })); export function LoadingState(props) { const { classes, cx } = useStyles(props.styles); const { graphic: Graphic = Gears, classes: propClasses } = props; return React.createElement( 'div', { className: cx(classes.root, propClasses?.root) }, props.title && React.createElement( Typography, { variant: 'h6', component: 'h3', className: cx(classes.title, propClasses?.title) }, props.title ), props.subtitle && React.createElement( Typography, { variant: 'subtitle1', component: 'p', className: cx(classes.subtitle, propClasses?.subtitle) }, props.subtitle ), React.createElement( 'div', { className: cx(classes.graphicRoot, propClasses?.graphicRoot) }, React.createElement(Graphic, { className: cx(classes.graphic, propClasses?.graphic), ...props.graphicProps }) ) ); } export function ConditionalLoadingState(props) { const { children, isLoading, ...loadingStateProps } = props; return isLoading ? React.createElement(LoadingState, { ...loadingStateProps }) : React.createElement(React.Fragment, null, children); } export default LoadingState;