1 import type { PropsWithChildren } from 'react';
2 import { forwardRef } from 'react';
4 import { EmptyViewContainer } from '@proton/components';
5 import clsx from '@proton/utils/clsx';
6 import isTruthy from '@proton/utils/isTruthy';
8 type MaybeString = string | false | null | undefined;
9 type Props = PropsWithChildren<{
12 subtitle?: MaybeString | MaybeString[];
18 const filterSubtitles = (subtitle: MaybeString | MaybeString[]): string[] => {
19 if (Array.isArray(subtitle)) {
20 return subtitle.filter(isTruthy);
31 * Common template for empty views across Drive.
33 export const DriveEmptyView = forwardRef<HTMLDivElement, Props>(
34 ({ image, title, subtitle, dataTestId, onClick, children }, ref) => (
35 // onClick is used for context menu, so we don't need to care about keyboard events
36 // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
37 <div ref={ref} onClick={onClick} className="flex w-full flex flex-1 overflow-auto">
45 data-testid={dataTestId}
47 <div className={clsx(!!children && 'mb-8')}>
48 <h3 className="text-bold">{title}</h3>
49 {filterSubtitles(subtitle).map((text) => (
50 <p key={text} className={'color-weak m-0 mt-2'}>
60 DriveEmptyView.displayName = 'DriveEmptyView';