Reference · Where every tie sits
FlagRenderertype
A function from a country code and a request to an SVG string, or null or undefined for a code it has no flag for. It must be
synchronous: a drawing is a pure function of its options. @johnmorrisdotca/hata's flag() is asynchronous, so load the flags first
(await flag(code, { shape: "round" }) for each code) and pass (code) => loaded[code].
Import it
import type { FlagRenderer } from "@johnmorrisdotca/taisen-brackets/layout";
Also exported from: @johnmorrisdotca/taisen-brackets
Definition
type FlagRenderer = (code: string, request: FlagRequest) => string | null | undefined;
Examples
import { drawBracket, type FlagRenderer } from "@johnmorrisdotca/taisen-brackets";
const flags: FlagRenderer = (code) => `<svg viewBox="0 0 30 20"><rect width="30" height="20" fill="#2f5d4a"/><title>${code}</title></svg>`;
const svg = drawBracket({ teams: [{ id: "JPN", name: "Japan", flag: "JP" }], matchups: [{ sides: ["JPN", "CAN"], score: [1, 0] }] }, { flags });
console.log(svg.startsWith("<svg"));trueWhat it prints (run when this page was built)