@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
96 lines (94 loc) • 3.33 kB
JavaScript
/*
* 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 { parseDashletContentHeight } from '../SiteDashboard/utils';
import Card from '@mui/material/Card';
import CardHeader from '@mui/material/CardHeader';
import Divider from '@mui/material/Divider';
import CardContent from '@mui/material/CardContent';
import Box from '@mui/material/Box';
import { UNDEFINED } from '../../utils/constants';
export function DashletCard(props) {
const {
sxs,
children,
actionsBar,
title,
borderLeftColor,
contentHeight: contentHeightProp,
actionsBarHeight = 35,
headerAction
} = props;
const contentHeight = contentHeightProp
? // Subtract toolbar height to avoid misalignment with other widgets
parseDashletContentHeight(contentHeightProp) - (actionsBar ? actionsBarHeight : 0)
: UNDEFINED;
return React.createElement(
Card,
{ sx: Object.assign({ borderLeft: 5, borderLeftColor }, sxs === null || sxs === void 0 ? void 0 : sxs.card) },
React.createElement(CardHeader, {
title: title,
titleTypographyProps: { variant: 'h6', component: 'h2' },
action: headerAction,
sx: sxs === null || sxs === void 0 ? void 0 : sxs.header
}),
React.createElement(Divider, null),
actionsBar &&
React.createElement(
Box,
{
sx: Object.assign(
{
display: 'flex',
position: 'relative',
borderBottom: '1px solid',
borderBottomColor: 'divider',
pr: 1,
pl: 1
},
sxs === null || sxs === void 0 ? void 0 : sxs.actionsBar
)
},
actionsBar
),
React.createElement(
CardContent,
{
sx: Object.assign(
{ overflow: 'auto', height: parseDashletContentHeight(contentHeight), pt: 0 },
sxs === null || sxs === void 0 ? void 0 : sxs.content
)
},
children
)
);
}
export default DashletCard;