import { Box, BoxProps, Typography, TypographyProps } from '@mui/material'; import Grid from '@mui/material/Grid'; import clsx from 'clsx'; import { memo, ReactNode, useMemo } from 'react'; import { When } from 'react-if'; import { Button } from '../../Button/Button'; import css from './ActionBar.module.scss'; export interface ActionBarProps { /** The title to show in the ActionBar */ title: ReactNode; /** * Whether an action button should be displayed in the ActionBar * @default false */ shouldHaveButton?: boolean; /** * Whether the button should be disabled * Only relevant when `shouldHaveButton` is set to true * @default false */ shouldDisableButton?: boolean; /** The text that should be shown in the button */ buttonLabel?: string; /** Additional props to apply to the Typography component */ TypographyProps?: TypographyProps; /** Additional props to pass to the encompasing Box component */ BoxProps?: BoxProps; /** Data-qa tag to apply action bar bounding box */ 'data-qa'?: string; /** The action that should be invoked when the button is clicked */ buttonAction?: (...args: any[]) => any; } /** * Creates an action bar using pre-defined Rijkswaterstaat styling * @param props Props to pass to the actionbar * @example * ```jsx * * ``` */ export const ActionBar = memo( ({ title, 'data-qa': dataQa, shouldDisableButton = false, shouldHaveButton = false, buttonAction, buttonLabel, BoxProps, TypographyProps }: ActionBarProps) => { const getTitle = useMemo(() => { if (typeof title === 'string') { return ( {title} ); } if (typeof title === 'function') return title(); return title; }, [TypographyProps, title]); return ( {getTitle}