/
githubmirror
/
tabler
Обзор
Документация
Войти
/
githubmirror
/
tabler
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
shared/ui/Steps.astro
36 строк
1 KB
Paweł Kuna
Narrow component prop types, remove unused props and dead code (#2838)
10 авг 2026, 00:14
Не верифицирован
10 авг 2026, 00:14
4f7beec
Код
Авторство
О чём код?
--- // Step styling uses strict equality for `active`, so a string (e.g. active="2") never matches the integer loop index. interface Props { count?: number | string active?: number | string numbers?: boolean } const { count = 4, active = 3, numbers } = Astro.props const classes = ['steps', numbers && 'steps-counter'] const activeNum = Number(active) const total = Number(count) const steps = Array.from({ length: total }, (_, i) => i + 1) --- <ol class:list={classes} aria-label="Progress"> { steps.map((i) => { const isFuture = i > activeNum const isCurrent = i === activeNum const isDone = i < activeNum const Element = isFuture ? 'span' : 'a' const itemClass = ['step-item', isCurrent ? 'active' : ''] const fallbackLabel = `Step ${i}${isCurrent ? ' (current)' : isDone ? ' (completed)' : ''}` return ( <li class:list={itemClass}> <Element href={isFuture ? undefined : '#'} aria-current={isCurrent ? 'step' : undefined}> <span class="visually-hidden">{fallbackLabel}</span> </Element> </li> ) }) } </ol>