- add section icons to all breadcrumbs across every page - fix breadcrumb nav display:flex so icons align vertically with buttons - wrap all page breadcrumbs in pageToolbar div for consistent layout - add Breadcrumbs to AllRunsPage which previously used a plain h1 - fix envCardHeader flex:1 so settings button hugs the right edge - remove card header from environment create/edit forms (duplicated breadcrumb)
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import styles from './DescriptionList.module.css';
|
|
|
|
function extractText(node: React.ReactNode): string {
|
|
if (typeof node === 'string' || typeof node === 'number') return String(node);
|
|
if (Array.isArray(node)) return node.map(extractText).join('');
|
|
if (React.isValidElement<{ children?: React.ReactNode }>(node))
|
|
return extractText(node.props.children);
|
|
return '';
|
|
}
|
|
|
|
export interface DescriptionListItem {
|
|
term: React.ReactNode;
|
|
detail: React.ReactNode;
|
|
}
|
|
|
|
export interface DescriptionListProps {
|
|
items: DescriptionListItem[];
|
|
/** 'compact' stacks term above detail; 'inline' places them side by side; 'comfortable' adds generous spacing with dividers (default); 'grid' flows items into a responsive multi-column grid */
|
|
layout?: 'inline' | 'compact' | 'comfortable' | 'grid';
|
|
/** Truncate detail values with ellipsis; full value shown in a tooltip on hover */
|
|
truncate?: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
export function DescriptionList({
|
|
items,
|
|
layout = 'inline',
|
|
truncate,
|
|
className,
|
|
}: DescriptionListProps) {
|
|
return (
|
|
<dl className={[styles.list, styles[layout], className].filter(Boolean).join(' ')}>
|
|
{items.map((item, i) => (
|
|
<div key={i} className={styles.row}>
|
|
<dt className={styles.term}>{item.term}</dt>
|
|
<dd
|
|
className={[styles.detail, truncate ? styles.truncate : ''].filter(Boolean).join(' ')}
|
|
title={truncate ? extractText(item.detail) : undefined}
|
|
>
|
|
{item.detail}
|
|
</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
);
|
|
}
|