import React from 'dom-chef'; import {RequireAllOrNone} from 'type-fest'; export type BannerProps = RequireAllOrNone<{ icon?: JSX.Element; text: Array | string | JSX.Element; classes?: string[]; action: string | React.MouseEventHandler; buttonLabel: JSX.Element | string; }, 'action' | 'buttonLabel'>; // Classes copied from "had recent pushes" banner from repo home const classes = 'flex-shrink-0 btn btn-sm ml-sm-3 mt-2 mt-sm-n2 mb-sm-n2 mr-sm-n1 flex-self-center'; // This could be a `` element but dom-chef doesn't pass props // https://github.com/vadimdemedes/dom-chef/issues/77 export default function createBanner(props: BannerProps): JSX.Element { let button: JSX.Element | undefined; if (typeof props.action === 'string') { button = ( {props.buttonLabel} ); } else if (typeof props.action === 'function') { button = ( ); } return (
{props.icon} {props.text}
{button}
); }