NTP_V2/web/src/components/ViewItem.tsx

24 lines
1.1 KiB
TypeScript

import type { ReactNode } from 'react';
import { Box, Typography } from '@mui/material';
/**
* Read-only caption + value used on every view screen (record pages): the caption in the primary blue at regular weight, the
* value below it in the brand navy at regular weight, an empty value as a grey dash. One definition so all views match.
*/
export function ViewItem({ label, children, empty, preWrap }: { label: ReactNode; children?: ReactNode; empty?: boolean; preWrap?: boolean }) {
const isEmpty = empty ?? (children === undefined || children === null || children === '' || children === false);
return (
<Box sx={{ minWidth: 0 }}>
<Typography component="div" sx={{ fontSize: 13.5, fontWeight: 400, color: 'primary.main', lineHeight: 1.5 }}>
{label}
</Typography>
<Typography
component="div"
sx={{ fontSize: 14, fontWeight: 400, lineHeight: 1.5, wordBreak: 'break-word', overflowWrap: 'anywhere', whiteSpace: preWrap ? 'pre-wrap' : undefined, color: isEmpty ? 'text.disabled' : 'text.primary' }}
>
{isEmpty ? '—' : children}
</Typography>
</Box>
);
}