@kinvolk/headlamp-plugin
Version:
The needed infrastructure for building Headlamp plugins.
38 lines (37 loc) • 2.44 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } 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 Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import React from 'react';
export default function SectionHeader(props) {
const { noPadding = false, headerStyle = 'main', titleSideActions = [] } = props;
const actions = props.actions || [];
const titleVariants = {
main: 'h1',
subsection: 'h2',
normal: 'h3',
label: 'h4',
};
return (_jsxs(Grid, { container: true, alignItems: "center", justifyContent: "space-between", sx: theme => ({
padding: theme.spacing(noPadding ? 0 : 2),
paddingTop: theme.spacing(noPadding ? 0 : 3),
}), spacing: 2, children: [_jsxs(Grid, { item: true, children: [(!!props.title || titleSideActions.length > 0) && (_jsxs(Box, { display: "flex", alignItems: "center", children: [!!props.title && (_jsx(Typography, { variant: titleVariants[headerStyle], noWrap: true, sx: theme => ({
...theme.palette.headerStyle[headerStyle || 'normal'],
whiteSpace: 'pre-wrap',
}), children: props.title })), !!titleSideActions && (_jsx(Box, { ml: 1, justifyContent: "center", children: titleSideActions.map((action, i) => (_jsx(React.Fragment, { children: action }, i))) }))] })), !!props.subtitle && (_jsx(Typography, { variant: "h6", component: "p", sx: { fontStyle: 'italic' }, children: props.subtitle }))] }), actions.length > 0 && (_jsx(Grid, { item: true, children: _jsx(Grid, { item: true, container: true, alignItems: "center", justifyContent: "flex-end", sx: { minHeight: '40px' }, children: actions.map((action, i) => (_jsx(Grid, { item: true, children: action }, i))) }) }))] }));
}