--- import Icon from './Icon.astro' interface Props { /** a number, or a signed string such as "+9.5" that is rendered as written */ value: number | string unit?: string | undefined class?: string } const { value, unit = '%', class: className } = Astro.props const amount = Number(value) if (Number.isNaN(amount)) { throw new Error(`Trending: value "${value}" is not a number`) } const trendingColor = amount > 0 ? 'green' : amount === 0 ? 'muted' : 'red' const trendingIcon = amount > 0 ? 'arrow-up' : amount === 0 ? 'minus' : 'arrow-down' const classes = [`text-${trendingColor} d-inline-flex align-items-center lh-1`, className] --- {amount > 0 ? 'Increased by' : amount < 0 ? 'Decreased by' : 'No change,'} {value}{unit}