import type { RoleSemantics, SurfaceTheme } from '@ankhorage/surface'; import React from 'react'; import type { ZoraColor } from '../../../../types/theme'; import type { TimelineItem, TimelineProps } from '../../../../types/timeline'; import { Icon } from '../../../icon/public'; import { resolveIconSize } from '../../../icon/utils/resolveIconSize'; import { View } from '../../../layout/public'; import { withZoraThemeScope } from '../../../theme/adapters/inbound/withZoraThemeScope'; import { useZoraTheme } from '../../../theme/composition/useZoraTheme'; import { Heading } from '../../../typography/public'; import { Text } from '../../../typography/public'; function resolveRoleSemantics(theme: SurfaceTheme, color: ZoraColor): RoleSemantics { switch (color) { case 'secondary': return theme.semantics.secondary; case 'tertiary': return theme.semantics.accent; case 'quaternary': return theme.semantics.highlight; case 'error': return theme.semantics.error; case 'info': return theme.semantics.info; case 'primary': return theme.semantics.action.primary; case 'danger': return theme.semantics.action.danger; case 'success': return theme.semantics.success; case 'warning': return theme.semantics.warning; case 'neutral': default: return theme.semantics.action.neutral; } } function TimelineInner({ themeId: _themeId, mode: _mode, interactionPolicy: _interactionPolicy, testID, items, compact = false, }: TimelineProps) { const { theme } = useZoraTheme(); const gap = compact ? 'm' : 'l'; const connectorHeight = compact ? 20 : 36; const renderItem = (item: TimelineItem, index: number) => { const status = item.status ?? 'neutral'; const role = resolveRoleSemantics(theme, status); const showConnector = index < items.length - 1; const iconSize = Math.max(12, resolveIconSize('s')); return ( {item.icon ? ( ) : null} {showConnector ? ( ) : null} {item.title} {item.meta ? ( {item.meta} ) : null} {item.description ? ( {item.description} ) : null} ); }; return ( {items.map(renderItem)} ); } /*** * Timeline pattern for displaying a sequence of events. * */ export const Timeline = withZoraThemeScope(TimelineInner);