UNPKG

aws-northstar

Version:
88 lines (84 loc) 4.42 kB
/** ******************************************************************************************************************* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 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. * ******************************************************************************************************************** */ var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Typography from '@material-ui/core/Typography'; import clsx from 'clsx'; const useStyles = makeStyles((theme) => ({ containerRoot: { marginBottom: theme.spacing(2), boxShadow: '0 1px 1px 0 rgba(0,28,36,.3), 1px 1px 1px 0 rgba(0,28,36,.15), -1px 1px 1px 0 rgba(0,28,36,.15)', }, containerHeader: { backgroundColor: theme.palette.grey[100], padding: (props) => (props.headerGutters ? '1rem 1rem 0.5rem 1rem' : 0), borderTop: `1px solid ${theme.palette.grey[200]}`, borderBottom: `1px solid ${theme.palette.grey[200]}`, }, containerHeaderStripe: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', marginBottom: '5px', }, containerHeaderTitle: { maxWidth: '100%', }, containerContent: { backgroundColor: theme.palette.background.paper, overflowX: 'auto', padding: (props) => (props.gutters ? '0.9rem 1rem' : 0), }, containerSubtitle: { marginTop: '5px', }, containerFooter: { borderTop: `1px solid ${theme.palette.grey[200]}`, padding: '1rem', background: theme.palette.background.paper, display: 'flex', justifyContent: 'end', }, noLineHeight: { lineHeight: 'initial', }, })); /** * Containers allow users to view a group of related content. */ const Container = (_a) => { var { children, title, subtitle, actionGroup, headerContent, footerContent, gutters = true, headerGutters = true, headingVariant = 'h2', style } = _a, props = __rest(_a, ["children", "title", "subtitle", "actionGroup", "headerContent", "footerContent", "gutters", "headerGutters", "headingVariant", "style"]); const classes = useStyles({ gutters, headerGutters }); return (React.createElement("div", { style: style, className: classes.containerRoot, "data-testid": props['data-testid'] }, !title && !subtitle && !actionGroup && !headerContent ? null : (React.createElement("div", { className: classes.containerHeader }, React.createElement("div", { className: classes.containerHeaderStripe }, React.createElement("div", { className: clsx(classes.containerHeaderTitle, classes.noLineHeight) }, title && (React.createElement(Typography, { variant: headingVariant, className: classes.noLineHeight }, title)), subtitle && (React.createElement(Typography, { variant: "subtitle1", component: "div", className: clsx(classes.noLineHeight, classes.containerSubtitle) }, subtitle))), React.createElement("div", null, actionGroup)), headerContent)), React.createElement("div", { className: classes.containerContent }, children), footerContent && React.createElement("div", { className: classes.containerFooter }, footerContent))); }; export default Container;