54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
// The strip that appears above a table once rows are checked, in the shape the
|
|
// project list and the plantafel established: a count badge, the actions, and
|
|
// the way out of the selection.
|
|
//
|
|
// Pure/presentational. It renders nothing while the selection is empty, so a
|
|
// screen cannot end up reserving room for a bar that has nothing to act on.
|
|
// Captions come in resolved, keeping this free of i18n lookups.
|
|
|
|
import type { ReactNode } from "react";
|
|
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
|
import { Button } from "~/ui/components/Button";
|
|
|
|
export type BulkActionBarProps = {
|
|
/** How many rows are checked. Zero renders nothing at all. */
|
|
selectedCount: number;
|
|
/** Resolved caption stating the count, e.g. "3 Kontakte ausgewählt". */
|
|
countLabel: string;
|
|
/**
|
|
* Resolved note about the part of the selection that is not on screen. A
|
|
* selection spanning pages is otherwise unreviewable: the reader cannot see
|
|
* what the action would touch.
|
|
*/
|
|
offPageLabel?: string | null;
|
|
/** The actions themselves — buttons, in the order they should be offered. */
|
|
children: ReactNode;
|
|
/** Resolved caption of the button that drops the selection. */
|
|
clearLabel: string;
|
|
onClear: () => void;
|
|
disabled?: boolean;
|
|
uiId: string;
|
|
};
|
|
|
|
export function BulkActionBar(props: BulkActionBarProps) {
|
|
if (props.selectedCount <= 0) return null;
|
|
return (
|
|
<div className="flex w-full min-w-0 flex-wrap items-center gap-3" data-ui-id={props.uiId}>
|
|
<BadgeFeedback farbe="subtle-neutral" size="small" data-ui-id={`${props.uiId}.count`}>
|
|
{props.countLabel}
|
|
</BadgeFeedback>
|
|
{props.offPageLabel ? (
|
|
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary" data-ui-id={`${props.uiId}.offPage`}>
|
|
{props.offPageLabel}
|
|
</span>
|
|
) : null}
|
|
{props.children}
|
|
<Button variant="neutral" size="small" disabled={props.disabled} onClick={props.onClear} data-ui-id={`${props.uiId}.clear`}>
|
|
{props.clearLabel}
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default BulkActionBar;
|