UNPKG

@craftercms/studio-ui

Version:

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

125 lines (123 loc) 4.43 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/>. */ var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === 'function') for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; 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: Object.assign( { display: 'flex', textAlign: 'center', alignItems: 'center', flexDirection: 'column', justifyContent: 'center', margin: `${theme.spacing(2)} auto`, minHeight: '100%' }, root ), graphicRoot: Object.assign({ display: 'flex', justifyContent: 'center' }, graphicRoot), title: Object.assign({ marginTop: '40px', marginBottom: '15px' }, title), subtitle: Object.assign({ marginBottom: '10px' }, subtitle), graphic: Object.assign({ 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 === null || propClasses === void 0 ? void 0 : propClasses.root) }, props.title && React.createElement( Typography, { variant: 'h6', component: 'h3', className: cx(classes.title, propClasses === null || propClasses === void 0 ? void 0 : propClasses.title) }, props.title ), props.subtitle && React.createElement( Typography, { variant: 'subtitle1', component: 'p', className: cx( classes.subtitle, propClasses === null || propClasses === void 0 ? void 0 : propClasses.subtitle ) }, props.subtitle ), React.createElement( 'div', { className: cx( classes.graphicRoot, propClasses === null || propClasses === void 0 ? void 0 : propClasses.graphicRoot ) }, React.createElement( Graphic, Object.assign( { className: cx( classes.graphic, propClasses === null || propClasses === void 0 ? void 0 : propClasses.graphic ) }, props.graphicProps ) ) ) ); } export function ConditionalLoadingState(props) { const { children, isLoading } = props, loadingStateProps = __rest(props, ['children', 'isLoading']); return isLoading ? React.createElement(LoadingState, Object.assign({}, loadingStateProps)) : React.createElement(React.Fragment, null, children); } export default LoadingState;