All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 11s
Build & Deploy / 🧪 QA (push) Successful in 1m25s
Build & Deploy / 🏗️ Build (push) Successful in 2m51s
Build & Deploy / 🚀 Deploy (push) Successful in 16s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 1m18s
Build & Deploy / 🔔 Notify (push) Successful in 2s
Nightly QA / 💨 Smoke & Health (push) Successful in 1m1s
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import { Text, View } from '@react-pdf/renderer';
|
|
|
|
import type { KeyValueItem } from '../../model/types';
|
|
import { styles } from '../styles';
|
|
|
|
export function KeyValueGrid(props: { items: KeyValueItem[] }): React.ReactElement | null {
|
|
const items = (props.items || []).filter((i) => i.label && i.value);
|
|
if (!items.length) return null;
|
|
|
|
// 2-column layout: (label, value)
|
|
return (
|
|
<View style={styles.kvGrid}>
|
|
{items.map((item, rowIndex) => {
|
|
const isLast = rowIndex === items.length - 1;
|
|
const value = item.unit ? `${item.value} ${item.unit}` : item.value;
|
|
|
|
return (
|
|
<View
|
|
key={`${item.label}-${rowIndex}`}
|
|
style={[
|
|
styles.kvRow,
|
|
rowIndex % 2 === 0 ? styles.kvRowAlt : null,
|
|
isLast ? styles.kvRowLast : null,
|
|
]}
|
|
wrap={false}
|
|
minPresenceAhead={12}
|
|
>
|
|
<View style={[styles.kvCell, { width: '50%' }]}>
|
|
<Text style={styles.kvLabelText}>{item.label}</Text>
|
|
</View>
|
|
<View style={[styles.kvCell, { width: '50%' }]}>
|
|
<Text style={styles.kvValueText}>{value}</Text>
|
|
</View>
|
|
</View>
|
|
);
|
|
})}
|
|
</View>
|
|
);
|
|
}
|