Skip to the content

Taisen Brackets対戦

Knockout brackets as SVG, from a list of ties.

Taisen (対戦, たいせん) is Japanese for a matchup: two sides facing each other. About the name

Contents

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"));
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/taisen-brackets 0.20.0.