'use client'; import React, { useId } from 'react'; import { useBreakpoint } from '../../hook/breakpoints.hook.js'; import { resolveResponsiveVariant } from '../../utils/breakpoint.util.js'; import { Icon } from '../icon/icon.component.js'; import { Label } from '../label/label.component.js'; import { styles as ProgressIndicatorStyles } from './progress-indicator.styles.js'; import { ProgressIndicatorProps } from './progress-indicator.types.js'; export function ProgressIndicator({ color = 'hero', label, size = 'medium', icon: EmbedIcon, className, 'aria-label': ariaLabel = 'Loading', ...props }: ProgressIndicatorProps) { const breakpoint = useBreakpoint(); const resolvedSize = resolveResponsiveVariant(size, breakpoint) || 'medium'; const styles = ProgressIndicatorStyles({ size: resolveResponsiveVariant(resolvedSize, breakpoint), color: resolveResponsiveVariant(color, breakpoint), }); const id = useId(); const sizeMap: Record = { xlarge: { strokeWidth: 4 }, large: { strokeWidth: 4 }, medium: { strokeWidth: 15 }, small: { strokeWidth: 20 }, xsmall: { strokeWidth: 30 }, }; // TODO: fix this properly const strokeHalfWidth = sizeMap[resolvedSize.toString()].strokeWidth / 2; return (
<> {EmbedIcon && resolvedSize === 'large' && }
{label && resolvedSize === 'large' && }
); }