Reference · Country card element
readCardColorsfunction
Read the card's bounded code:hex-colour attribute without accepting CSS or markup fragments.
Import it
import { readCardColors } from "@johnmorrisdotca/kuni/element";
Also exported from: @johnmorrisdotca/kuni/element/define
Definition
function readCardColors(text: string | null): Record<string, string> | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | Comma-separated pairs; null or empty means the theme colour. |
Returns
Record<string, string> | null
Validated colour pairs, or null when any pair is malformed.
Examples
import { readCardColors } from "@johnmorrisdotca/kuni/element";
console.log(readCardColors("JP:#2f6b4f")?.JP); // "#2f6b4f"
console.log(readCardColors("JP:url(evil)")); // null#2f6b4f
nullWhat it prints (run when this page was built)