55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package report
|
|
|
|
import "sort"
|
|
|
|
// themeAssets bundles everything a report or index page needs to render in
|
|
// one visual theme: the shared stylesheet (cards, tables, nav, badges, ...),
|
|
// report-only CSS (map + map label), and the color/URL values referenced by
|
|
// the inline Chart.js / Leaflet JS.
|
|
type themeAssets struct {
|
|
CSS string // shared :root + component stylesheet
|
|
ExtraCSS string // report-only overrides (map, map label)
|
|
|
|
ChartFont string // Chart.js font-family
|
|
ChartText string // Chart.js default text color
|
|
ChartGrid string // Chart.js default grid/border color
|
|
|
|
Chart1 string // 2xx / success series color
|
|
Chart2 string // 3xx / timeline series color
|
|
Chart2Fill string // timeline area fill (rgba)
|
|
Chart3 string // top-paths bar color / decorative accent
|
|
ChartWarn string // 4xx series color
|
|
ChartErr string // 5xx series color
|
|
|
|
MapTileURL string
|
|
MapAttribution string
|
|
MarkerColor string
|
|
}
|
|
|
|
// DefaultTheme is used when no theme is specified or an unknown name is given.
|
|
const DefaultTheme = "cyberpunk"
|
|
|
|
var themeRegistry = map[string]themeAssets{
|
|
"cyberpunk": cyberpunkTheme,
|
|
"purplerain": purplerainTheme,
|
|
"cactus": cactusTheme,
|
|
}
|
|
|
|
// ThemeNames returns the sorted list of valid --theme values.
|
|
func ThemeNames() []string {
|
|
names := make([]string, 0, len(themeRegistry))
|
|
for name := range themeRegistry {
|
|
names = append(names, name)
|
|
}
|
|
sort.Strings(names)
|
|
return names
|
|
}
|
|
|
|
// themeFor looks up a theme by name, falling back to DefaultTheme for an
|
|
// empty or unrecognized name.
|
|
func themeFor(name string) themeAssets {
|
|
if t, ok := themeRegistry[name]; ok {
|
|
return t
|
|
}
|
|
return themeRegistry[DefaultTheme]
|
|
}
|