@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
79 lines (77 loc) • 2.85 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 Typography from '@mui/material/Typography';
import { renderWidgets } from '../Widget';
import React from 'react';
import { makeStyles } from 'tss-react/mui';
import { usePossibleTranslation } from '../../hooks/usePossibleTranslation';
const useStyles = makeStyles()((theme, { title, nav } = {}) => ({
title: Object.assign(
{
textTransform: 'uppercase',
fontWeight: 600,
margin: '0 0 10px 0',
'& > .muted': {
textTransform: 'none',
marginLeft: '0.315em',
color: theme.palette.text.secondary
}
},
title
),
nav: Object.assign({ display: 'flex', flexWrap: 'wrap' }, nav)
}));
export function LauncherSectionUI(props) {
var _a, _b;
const { classes, cx } = useStyles(props.styles);
const title = usePossibleTranslation(props.title, props.translationValues);
const { children } = props;
return React.createElement(
React.Fragment,
null,
title &&
React.createElement(
Typography,
{
variant: 'subtitle1',
component: 'h2',
className: cx(classes.title, (_a = props.classes) === null || _a === void 0 ? void 0 : _a.title)
},
title
),
React.createElement(
'nav',
{ className: cx(classes.nav, (_b = props.classes) === null || _b === void 0 ? void 0 : _b.nav) },
children ? children : renderWidgets(props.widgets, { userRoles: props.user.rolesBySite[props.site] })
)
);
}
export default LauncherSectionUI;