/******************************************************************************** * Copyright (c) 2020 TypeFox and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import { FunctionComponent, PropsWithChildren } from 'react'; import { Box, Button, Collapse, IconButton } from '@mui/material'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import WarningAmberRoundedIcon from '@mui/icons-material/WarningAmberRounded'; import CloseIcon from '@mui/icons-material/Close'; const VARIANTS = { info: { Icon: InfoOutlinedIcon, bg: 'accentSoft', accent: 'secondary.light' }, warning: { Icon: WarningAmberRoundedIcon, bg: 'warningSoft', accent: 'warningAccent' } } as const; export const Banner: FunctionComponent> = props => { const { color = 'info', open, showDismissButton, dismissButtonLabel, dismissButtonOnClick, children } = props; const { Icon, bg, accent } = VARIANTS[color]; return ( {children} {showDismissButton && (dismissButtonLabel ? ( ) : ( ))} ); }; interface BannerProps { open: boolean; showDismissButton?: boolean; dismissButtonLabel?: string; dismissButtonOnClick?: () => void; color?: 'info' | 'warning'; }