FlagRenderer型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 type { FlagRenderer } from "@johnmorrisdotca/taisen-brackets/layout";
ほかのエクスポート元: @johnmorrisdotca/taisen-brackets
定義
type FlagRenderer = (code: string, request: FlagRequest) => string | null | undefined;
例
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"));true出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。