/** ******************************************************************************************************************* 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. * ******************************************************************************************************************** */ import React, { Fragment, FunctionComponent, ReactElement, useMemo } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Divider from '@material-ui/core/Divider'; import LaunchOutlined from '@material-ui/icons/LaunchOutlined'; import Typography from '@material-ui/core/Typography'; import Stack from '../../layouts/Stack'; import Link from '../Link'; import Box from '../../layouts/Box'; import LoadingIndicator from '../LoadingIndicator'; import Heading from '../Heading'; const useStyles = makeStyles((theme) => ({ header: { fontSize: '18px', padding: '20px 56px 20px 30px', paddingRight: theme.spacing(3), paddingLeft: theme.spacing(3), }, content: { paddingTop: '10px', paddingLeft: theme.spacing(3), paddingRight: theme.spacing(3), }, divider: { marginTop: '25px', marginBottom: '25px', }, learnMore: { display: 'flex', alignItems: 'center', '& svg': { marginLeft: theme.spacing(0.5), }, }, })); export interface HelpPanelProps { /** Header to display */ header?: string; /** List of links to documentation */ learnMoreFooter?: ReactElement[]; /** Renders the help panel in a loading state */ loading?: boolean; } /** A help panel, designed to be rendered as part of the App Layout */ const HelpPanel: FunctionComponent = ({ header: headerLabel = '', children, learnMoreFooter, loading = false, ...props }) => { const styles = useStyles(); const testId = props['data-testid'] || 'app-help-panel'; const header = useMemo(() => { return ( {headerLabel} ); }, [headerLabel, styles, testId]); const content = useMemo(() => { return ( {children} {learnMoreFooter && (
Learn more {learnMoreFooter.map((link, index) => ( {link} ))}
)}
); }, [children, learnMoreFooter, styles, testId]); return ( {loading ? ( ) : ( <> {header} {content} )} ); }; export default HelpPanel;