mirror of
https://github.com/tabler/tabler.git
synced 2026-08-29 13:21:29 +04:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
37 lines
1.1 KiB
Plaintext
37 lines
1.1 KiB
Plaintext
---
|
|
// 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>
|