UNPKG

@craftercms/studio-ui

Version:

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

108 lines (106 loc) 3.89 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 ArrowBackIcon from '@mui/icons-material/ArrowBack'; import Fab from '@mui/material/Fab'; import crack from '../../assets/full-crack.svg'; import { nnou } from '../../utils/object'; const useStyles = makeStyles()((theme, { root, image, title, message, button } = {}) => ({ root: Object.assign( { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', padding: theme.spacing(1), paddingBottom: '0' }, root ), image: Object.assign({ maxWidth: '100%', marginBottom: theme.spacing(1) }, image), title: Object.assign({ marginBottom: theme.spacing(1) }, title), message: Object.assign({ textAlign: 'center', marginBottom: theme.spacing(1), wordBreak: 'break-all' }, message), button: Object.assign( { color: theme.palette.text.secondary, background: theme.palette.background.default, marginBottom: theme.spacing(1) }, button ) })); export function ErrorState(props) { var _a, _b, _c, _d, _e; const { classes, cx } = useStyles(props.styles); const { title, message, buttonText = 'Back', buttonIcon = React.createElement(ArrowBackIcon, null), onButtonClick, imageUrl = crack, children } = props; return React.createElement( 'section', { className: cx(classes.root, (_a = props.classes) === null || _a === void 0 ? void 0 : _a.root) }, React.createElement('img', { className: cx(classes.image, (_b = props.classes) === null || _b === void 0 ? void 0 : _b.image), src: imageUrl, alt: '' }), nnou(title) && React.createElement(Typography, { variant: 'body1', component: 'h3', className: cx(classes.title, (_c = props.classes) === null || _c === void 0 ? void 0 : _c.title), children: title }), nnou(message) && React.createElement(Typography, { variant: 'body2', component: 'p', className: cx(classes.message, (_d = props.classes) === null || _d === void 0 ? void 0 : _d.message), children: message }), children, onButtonClick && React.createElement(Fab, { onClick: onButtonClick, 'aria-label': buttonText, className: cx(classes.button, (_e = props.classes) === null || _e === void 0 ? void 0 : _e.button), children: buttonIcon }) ); } export default ErrorState;