@janiscommerce/ui-native
Version:
components library for Janis app
32 lines (31 loc) • 1.5 kB
TypeScript
import React from 'react';
import { ViewProps } from 'react-native';
import type { ButtonProps } from '../../molecules/Button';
export interface ActionConfig extends ButtonProps {
flex?: number;
}
/**
* A row slot: an action config, or a falsy value that gets filtered out. The
* falsy union lets callers inline conditionals (`canDelete && deleteAction`),
* the same way React accepts a falsy `ReactNode` child.
*/
type Action = ActionConfig | null | false | undefined;
export type ActionsRows = Array<Action | Action[]>;
export interface ScreenActionsProps extends ViewProps {
actions?: ActionsRows;
backgroundColor?: string;
}
/**
* Bottom bar of screen action buttons. Layouts are declared through the
* `actions` config, where a nested array is a row and its items share the width
* by flex weights (`flex={0}` keeps a button's intrinsic width). Falsy entries
* are skipped, so callers can inline conditional actions without extra ternaries.
* It owns the bar framing (padding, gap, background) and gives icon-only actions a minimum width
* so they read as a pill instead of a circle; the rest of each action's visual
* hierarchy belongs to the Button itself.
*
* The bottom safe-area inset is owned by the screen/app root (a SafeAreaView
* with the `bottom` edge): reading it here too would add the inset twice.
*/
declare const ScreenActions: ({ actions, backgroundColor, style, ...props }: ScreenActionsProps) => React.JSX.Element | null;
export default ScreenActions;