UNPKG

@craftercms/studio-ui

Version:

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

76 lines (74 loc) 2.67 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 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: { textTransform: 'uppercase', fontWeight: 600, margin: '0 0 10px 0', '& > .muted': { textTransform: 'none', marginLeft: '0.315em', color: theme.palette.text.secondary }, ...title }, nav: { display: 'flex', flexWrap: 'wrap', ...nav } })); export function LauncherSectionUI(props) { 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, props.classes?.title) }, title ), React.createElement( 'nav', { className: cx(classes.nav, props.classes?.nav) }, children ? children : renderWidgets(props.widgets, { userRoles: props.user.rolesBySite[props.site] }) ) ); } export default LauncherSectionUI;