Skip to the content

Kuni国

Look up countries, codes, names and subdivisions, load country data on demand and mount a native country card.

Kuni (国) is Japanese for a country. About the name

Contents

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

NameTypeDescription
textstring | 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
null

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kuni 1.4.0.