@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
44 lines (43 loc) • 2.15 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/*
* Copyright 2025 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Box from '@mui/material/Box';
import React from 'react';
import BackLink from './BackLink';
import SectionHeader from './SectionHeader';
export function SectionBox(props) {
const { title, subtitle, children, headerProps = { noPadding: false, headerStyle: 'subsection' }, outterBoxProps = {}, backLink, ...otherProps } = props;
let titleElem;
// If backLink is a boolean, then we want to use the browser's history if true.
const actualBackLink = typeof backLink === 'boolean' ? (!!backLink ? '' : undefined) : backLink;
if (typeof title === 'string') {
titleElem = (_jsx(SectionHeader, { title: title, subtitle: subtitle, ...headerProps }));
}
else {
titleElem = title;
}
return (_jsxs(_Fragment, { children: [actualBackLink !== undefined && _jsx(BackLink, { to: actualBackLink }), _jsxs(Box, { py: 0, ...outterBoxProps, children: [title && titleElem, _jsx(Box, { sx: theme => ({
paddingTop: 0,
paddingBottom: 0,
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
[theme.breakpoints.down('sm')]: {
paddingLeft: 0,
paddingRight: 0,
},
}), ...otherProps, children: React.Children.toArray(children) })] })] }));
}
export default SectionBox;