Skip to content
quarry Artifact [6295a2a59d]
Login

Artifact [6295a2a59d]

Artifact 6295a2a59d6f484956fdaf1b661f57e0eb5884ed288719ed739873b775fec594:


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"). 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":
		symbol, tone = "i-tkt-open", " g-open"
	case "accepted", "rejected":
		symbol, tone = "i-tkt-done", " g-done"
	}
	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))
}