package web
import (
"fmt"
"html/template"
)
// landingNum is how a page shows a landing's number: the state icon the
// lists already draw, then the number, named for a reader who cannot see
// the glyph ("landing 768, accepted"). It is the landing glyph in the
// state's tone, so it cannot be mistaken for a ticket's circle. Never "!768": the bang is what a
// person types, not what is shown. An unknown state draws the landing
// glyph and says just "landing 768".
func landingNum(n int, state string) template.HTML {
symbol, tone, label := "i-landing", "", fmt.Sprintf("landing %d", n)
switch state {
case "open":
tone = " g-open"
case "accepted":
tone = " g-done"
case "rejected":
tone = " g-rejected"
}
if state != "" {
label += ", " + state
}
return template.HTML(fmt.Sprintf(
`<span class="t-num" data-hook="landing-number" role="img" aria-label="%s" title="%s"><svg class="ic ref-ic%s" aria-hidden="true"><use href="#%s"/></svg>%d</span>`,
label, label, tone, symbol, n))
}
// landingNumText is landingNum for a row that already draws its own
// state glyph beside it: the number alone, with the same label.
func landingNumText(n int, state string) template.HTML {
label := fmt.Sprintf("landing %d", n)
if state != "" {
label += ", " + state
}
return template.HTML(fmt.Sprintf(`<span class="t-num" data-hook="landing-number" role="img" aria-label="%s" title="%s">%d</span>`, label, label, n))
}