File size: 547 Bytes
a8fb296
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
/**
 * Readable label for a coarse `primary_theme` code (#499):
 * "economic_development" / "ECONOMIC_DEVELOPMENT" → "Economic development".
 * Returns null for empty or the "__unthemed__" sentinel so callers can hide it.
 */
export function themeLabel(code: string | null | undefined): string | null {
  const raw = (code ?? '').trim()
  if (!raw || raw === '__unthemed__') return null
  const words = raw.replace(/[_-]+/g, ' ').replace(/\s+/g, ' ').trim().toLowerCase()
  return words ? words.charAt(0).toUpperCase() + words.slice(1) : null
}