@johnmorrisdotca/taisen-brackets 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -1
- package/NOTICE.md +5 -2
- package/README.md +195 -23
- package/dist/background.d.ts +19 -0
- package/dist/background.js +66 -0
- package/dist/backgrounds-entry.d.ts +2 -0
- package/dist/backgrounds-entry.js +1 -0
- package/dist/family-backgrounds.d.ts +61 -0
- package/dist/family-backgrounds.js +453 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +5 -2
- package/dist/locales.js +30 -0
- package/dist/marks.d.ts +18 -1
- package/dist/marks.js +89 -3
- package/dist/matchup.js +1 -0
- package/dist/render.d.ts +1 -1
- package/dist/render.js +473 -87
- package/dist/road-entry.d.ts +2 -0
- package/dist/road-entry.js +1 -0
- package/dist/road.d.ts +28 -0
- package/dist/road.draw.d.ts +4 -0
- package/dist/road.draw.js +259 -0
- package/dist/road.js +58 -0
- package/dist/road.model.d.ts +63 -0
- package/dist/road.model.js +312 -0
- package/dist/road.types.d.ts +115 -0
- package/dist/road.types.js +1 -0
- package/dist/text.d.ts +14 -1
- package/dist/text.js +50 -4
- package/dist/theme.d.ts +29 -2
- package/dist/theme.js +50 -11
- package/dist/types.d.ts +120 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +18 -3
package/dist/theme.js
CHANGED
|
@@ -4,10 +4,24 @@ export const THEMES = Object.freeze({
|
|
|
4
4
|
dark: { bg: "#141614", ink: "#ece8dc", muted: "#9aa095", line: "#6c7168", box: "#1e211d", edge: "#3b403a", win: "#e0705a", gold: "#e0b43b", plain: "#3b403a" },
|
|
5
5
|
poster: { bg: "#0a1130", ink: "#f6f1e3", muted: "#a9b2d3", line: "#d9b24c", box: "#111b47", edge: "#8e7632", win: "#f0c64a", gold: "#f0c64a", plain: "#26336b" },
|
|
6
6
|
});
|
|
7
|
+
export const ROAD_THEMES = Object.freeze({
|
|
8
|
+
light: { ring: "#ffffff", edge: "rgba(0,0,0,.3)", panel: "#e7e3d6", spine: "#b9b39f" },
|
|
9
|
+
dark: { ring: "#e9ece6", edge: "rgba(0,0,0,.6)", panel: "#252b28", spine: "#4a524d" },
|
|
10
|
+
poster: { ring: "#f6f1e3", edge: "rgba(0,0,0,.5)", panel: "#1b2766", spine: "#d9b24c" },
|
|
11
|
+
});
|
|
7
12
|
const FONT = 'system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Sans", "Yu Gothic UI", "Noto Sans CJK JP", Meiryo, sans-serif';
|
|
13
|
+
/** A palette and a road palette from a background's ink. */
|
|
14
|
+
function fromInk(ink) {
|
|
15
|
+
return [
|
|
16
|
+
{ bg: ink.base, ink: ink.text, muted: ink.muted, line: ink.line, box: ink.box, edge: ink.edge, win: ink.accent, gold: ink.accent, plain: ink.plain },
|
|
17
|
+
{ ring: ink.ring, edge: ink.dark ? "rgba(0,0,0,.55)" : "rgba(0,0,0,.35)", panel: ink.panel, spine: ink.spine },
|
|
18
|
+
];
|
|
19
|
+
}
|
|
8
20
|
/** The rules for one palette, each colour read from its custom property with the palette's value as the fallback. */
|
|
9
|
-
function rules(p, poster, withFont) {
|
|
21
|
+
function rules(p, r, poster, withFont, parts, side) {
|
|
10
22
|
const v = (name) => `var(--tb-${name}, ${p[name]})`;
|
|
23
|
+
const rv = (name, css) => `var(--tb-${css}, ${r[name]})`;
|
|
24
|
+
const road = parts.road === true || parts.chart === true;
|
|
11
25
|
const list = [
|
|
12
26
|
[[".tb-bg"], `fill:${v("bg")}`],
|
|
13
27
|
[[".tb-line"], `stroke:${v("line")};stroke-width:${poster ? 1.6 : 1.3};fill:none;stroke-opacity:${poster ? 0.95 : 0.8}`],
|
|
@@ -17,17 +31,38 @@ function rules(p, poster, withFont) {
|
|
|
17
31
|
[[".tb-muted", ".tb-round", ".tb-sub"], `fill:${v("muted")}`],
|
|
18
32
|
[[".tb-won .tb-name", ".tb-won .tb-score"], "font-weight:700"],
|
|
19
33
|
[[".tb-lost .tb-name", ".tb-lost .tb-score", ".tb-lost .tb-mark"], "opacity:.55"],
|
|
20
|
-
|
|
21
|
-
|
|
34
|
+
road
|
|
35
|
+
? [[".tb-ring"], `fill:none;stroke:${rv("ring", "mark-ring")}`]
|
|
36
|
+
: [[".tb-ring"], `fill:none;stroke:${v("edge")};stroke-width:1`],
|
|
37
|
+
...(road ? [] : [[[".tb-won .tb-ring"], `stroke:${v("win")};stroke-width:2`]]),
|
|
22
38
|
[[".tb-plain"], `fill:${v("plain")}`],
|
|
23
39
|
[[".tb-initials"], `fill:${v("ink")}`],
|
|
24
40
|
[[".tb-half"], `fill:${v("ink")}`],
|
|
25
41
|
[[".tb-gold"], `fill:${v("gold")}`],
|
|
26
42
|
[[".tb-emblem"], `color:${v("ink")}`],
|
|
27
|
-
[[".tb-champ .tb-ring"], `stroke:${v("gold")};stroke-width:3`],
|
|
43
|
+
road ? [[".tb-champ .tb-ring"], `stroke:${v("gold")}`] : [[".tb-champ .tb-ring"], `stroke:${v("gold")};stroke-width:3`],
|
|
28
44
|
[[".tb-champ-label"], `fill:${v("gold")}`],
|
|
29
45
|
[[".tb-halo"], `paint-order:stroke;stroke:${v("bg")};stroke-width:4px;stroke-linejoin:round`],
|
|
30
46
|
];
|
|
47
|
+
if (road) {
|
|
48
|
+
list.push([[".tb-edge"], `fill:none;stroke:${rv("edge", "mark-edge")}`], [[".tb-lost .tb-ring-r", ".tb-lost .tb-edge"], "opacity:.55"], [[".tb-panel"], `fill:${rv("panel", "panel")}`], [[".tb-lab"], `fill:${v("ink")};font-weight:700`], [[".tb-spine"], `stroke:${rv("spine", "spine")};fill:none;stroke-linecap:round`], [[".tb-tagbox"], `fill:${rv("panel", "panel")}`], [[".tb-tag"], `fill:${v("ink")};font-weight:700`], [[".tb-code", ".tb-vs"], `fill:${v("muted")};font-weight:700`]);
|
|
49
|
+
}
|
|
50
|
+
if (parts.road === true) {
|
|
51
|
+
list.push([[".tb-name"], "font-weight:700"], [[".tb-score"], "font-weight:800"], [[".tb-lost .tb-score"], `fill:${v("muted")};opacity:1`], [[".tb-line"], `stroke-linecap:round;stroke-linejoin:round;stroke-width:${poster ? 2 : 1.8};stroke-opacity:.55`]);
|
|
52
|
+
}
|
|
53
|
+
if (parts.chart === true) {
|
|
54
|
+
list.push([[".tb-r-t"], `fill:${v("ink")};font-weight:800`], [[".tb-r-s", ".tb-r-e", ".tb-r-sub", ".tb-r-code", ".tb-r-vs", ".tb-r-dash"], `fill:${v("muted")};font-weight:700`], [[".tb-r-name", ".tb-r-n"], `fill:${v("ink")};font-weight:800`], [[".tb-r-n.tb-r-low"], `fill:${v("muted")}`], [[".tb-r-dim"], "opacity:.5"], [["text"], "font-variant-numeric:tabular-nums"]);
|
|
55
|
+
}
|
|
56
|
+
if (parts.follow === true) {
|
|
57
|
+
list.push([[".tb-tie"], "opacity:.4"], [[".tb-tie.tb-on-path"], "opacity:1"], [[".tb-on-path .tb-box"], `stroke:${v("win")};stroke-width:2.2`], [[".tb-line"], "stroke-opacity:.25"], [[".tb-line.tb-path"], `stroke:${v("win")};stroke-width:4.5;stroke-opacity:1;stroke-linecap:round;stroke-dasharray:.1 9`]);
|
|
58
|
+
}
|
|
59
|
+
if (parts.links === true) {
|
|
60
|
+
list.push([[".tb-link"], "cursor:pointer;outline:none"], [[".tb-link:hover .tb-box", ".tb-link:focus-visible .tb-box"], `stroke:${v("win")};stroke-width:2.5`], [[".tb-link:hover .tb-name", ".tb-link:focus-visible .tb-name"], "text-decoration:underline"], [[".tb-link:focus-visible"], `outline:2px solid ${v("win")};outline-offset:2px`]);
|
|
61
|
+
}
|
|
62
|
+
if (parts.bgAuto === true)
|
|
63
|
+
list.push(side === "dark" ? [[".tb-bgl"], "display:none"] : [[".tb-bgd"], "display:none"]);
|
|
64
|
+
if (parts.bgAuto === true && side === "dark")
|
|
65
|
+
list.push([[".tb-bgd"], "display:inline"]);
|
|
31
66
|
if (withFont)
|
|
32
67
|
list.push([["text"], `font-family:var(--tb-font, ${FONT})`]);
|
|
33
68
|
return list;
|
|
@@ -36,18 +71,22 @@ const write = (scope, list, before = "") => list.map(([sel, body]) => `${sel.map
|
|
|
36
71
|
/**
|
|
37
72
|
* The `<style>` text of a drawing. `auto` is the light look and, under `prefers-color-scheme: dark` or a page that says
|
|
38
73
|
* `data-theme="dark"` on `<html>`, the dark one; `light`, `dark` and `poster` are one look always. Every colour can be
|
|
39
|
-
* set from the page with a `--tb-*` custom property.
|
|
74
|
+
* set from the page with a `--tb-*` custom property. `parts` adds the rules the road look, the road chart, links and a highlighted path need.
|
|
40
75
|
*/
|
|
41
|
-
export function styleFor(scope, theme) {
|
|
76
|
+
export function styleFor(scope, theme, parts = {}, inks = {}) {
|
|
77
|
+
// A look takes the ink of the picture drawn for it; a picture asked for in the other variant (`background.theme`) gives its ink to both.
|
|
78
|
+
const only = inks.light ?? inks.dark;
|
|
79
|
+
const [lp, lr] = (inks.light ?? only) ? fromInk((inks.light ?? only)) : [THEMES.light, ROAD_THEMES.light];
|
|
80
|
+
const [dp, dr] = (inks.dark ?? only) ? fromInk((inks.dark ?? only)) : [THEMES.dark, ROAD_THEMES.dark];
|
|
42
81
|
if (theme === "light")
|
|
43
|
-
return write(scope, rules(
|
|
82
|
+
return write(scope, rules(lp, lr, false, true, parts, "light"));
|
|
44
83
|
if (theme === "dark")
|
|
45
|
-
return write(scope, rules(
|
|
84
|
+
return write(scope, rules(dp, dr, false, true, parts, "dark"));
|
|
46
85
|
if (theme === "poster")
|
|
47
|
-
return write(scope, rules(THEMES.poster, true, true));
|
|
48
|
-
const dark = rules(
|
|
86
|
+
return write(scope, only ? rules(dp, dr, true, true, parts, "dark") : rules(THEMES.poster, ROAD_THEMES.poster, true, true, parts, "dark"));
|
|
87
|
+
const dark = rules(dp, dr, false, false, parts, "dark");
|
|
49
88
|
return [
|
|
50
|
-
write(scope, rules(
|
|
89
|
+
write(scope, rules(lp, lr, false, true, parts, "light")),
|
|
51
90
|
`@media (prefers-color-scheme: dark){\n${write(scope, dark, ':root:not([data-theme="light"]) ')}\n}`,
|
|
52
91
|
write(scope, dark, ':root[data-theme="dark"] '),
|
|
53
92
|
].join("\n");
|
package/dist/types.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export interface Team {
|
|
|
12
12
|
abbr?: string;
|
|
13
13
|
/** The seed, shown beside the name when `seeds` is on. */
|
|
14
14
|
seed?: number;
|
|
15
|
+
/** A tag for the road look's seed tags (`C1`, `WC2`, `M3`): written small beside the mark when `seeds` is on, in place of the number. A tie's `seeds` win over it. */
|
|
16
|
+
tag?: string;
|
|
15
17
|
/**
|
|
16
18
|
* The team's mark: a logo or a flag. Either the address of an image (`https://`, `data:image/…`, or a relative
|
|
17
19
|
* path) or inline SVG markup (`<svg …>`; a round flag from `@johnmorrisdotca/hata` goes here as it is).
|
|
@@ -25,6 +27,11 @@ export interface Team {
|
|
|
25
27
|
names?: Readonly<Record<string, string>>;
|
|
26
28
|
/** An ISO 3166 region code (`DE`), for `countryName` and a `teamName` that uses it. */
|
|
27
29
|
region?: string;
|
|
30
|
+
/**
|
|
31
|
+
* A country code (`ca`, `GB-ENG`) for a round flag drawn by the `flags` option's renderer (`@johnmorrisdotca/hata` has one). With no
|
|
32
|
+
* renderer, or one that has no flag for the code, the team's `mark` is drawn, or its initials: it never throws.
|
|
33
|
+
*/
|
|
34
|
+
flag?: string;
|
|
28
35
|
}
|
|
29
36
|
/** One game of a tie: a match of a knockout, a game of a series, a leg of an aggregate, a replay. */
|
|
30
37
|
export interface Game {
|
|
@@ -95,6 +102,8 @@ export interface Matchup {
|
|
|
95
102
|
/** This is the third-place match: it leads nowhere and is drawn apart. */
|
|
96
103
|
third?: boolean;
|
|
97
104
|
note?: string;
|
|
105
|
+
/** The seed tags of the two sides for this tie (`["C1", "WC2"]`), written beside the marks in the road look when `seeds` is on; a side's `Team.tag` is used where this has none. */
|
|
106
|
+
seeds?: readonly [string | number | null, string | number | null];
|
|
98
107
|
}
|
|
99
108
|
/** What a tie came to, worked out from its games. */
|
|
100
109
|
export interface Result {
|
|
@@ -129,6 +138,8 @@ export interface Tie {
|
|
|
129
138
|
third: boolean;
|
|
130
139
|
walkover: boolean;
|
|
131
140
|
note: string | null;
|
|
141
|
+
/** The seed tags given for the tie's sides (`Matchup.seeds`). */
|
|
142
|
+
seeds?: readonly [string | number | null, string | number | null];
|
|
132
143
|
}
|
|
133
144
|
/** Where the layout put a tie. */
|
|
134
145
|
export type Place = "l" | "r" | "f" | "o";
|
|
@@ -259,6 +270,33 @@ export interface Words {
|
|
|
259
270
|
columnDate: string;
|
|
260
271
|
/** The `<title>` of a drawing with no `title` option. */
|
|
261
272
|
title: string;
|
|
273
|
+
/** The road-to-the-final chart (`roadToFinal`): its title, the "v" between two finalists, the group stage, FT, AET, `{a}`, `{b}` the shoot-out, and the results. */
|
|
274
|
+
roadTitle: string;
|
|
275
|
+
roadVs: string;
|
|
276
|
+
roadGroup: string;
|
|
277
|
+
roadFt: string;
|
|
278
|
+
roadAet: string;
|
|
279
|
+
roadPens: string;
|
|
280
|
+
roadWon: string;
|
|
281
|
+
roadLost: string;
|
|
282
|
+
roadDrew: string;
|
|
283
|
+
/** The names of the two rounds a road names one match of (the other rounds come from the round names of the language). */
|
|
284
|
+
roadQuarterFinal: string;
|
|
285
|
+
roadSemiFinal: string;
|
|
286
|
+
/** The road's table: the headings, the caption (`{a}`, `{b}`), the chart's name (`{a}`, `{b}`, `{title}`), the summary (`{a}`, `{b}`, `{an}`, `{bn}`) and its sentences. */
|
|
287
|
+
roadTableTeam: string;
|
|
288
|
+
roadTableOpponent: string;
|
|
289
|
+
roadTableScore: string;
|
|
290
|
+
roadTableDecided: string;
|
|
291
|
+
roadTableResult: string;
|
|
292
|
+
roadCaption: string;
|
|
293
|
+
roadName: string;
|
|
294
|
+
roadSummary: string;
|
|
295
|
+
/** `{a}`, `{b}`, `{score}`, `{how}`. */
|
|
296
|
+
roadFinal: string;
|
|
297
|
+
/** `{name}`. */
|
|
298
|
+
roadChampion: string;
|
|
299
|
+
roadToPlay: string;
|
|
262
300
|
}
|
|
263
301
|
/** A language: its words, the names of the rounds (by their English names), and the tag `Intl` formats numbers and dates for. */
|
|
264
302
|
export interface Locale {
|
|
@@ -270,7 +308,7 @@ export interface Locale {
|
|
|
270
308
|
rounds: Readonly<Record<string, string>>;
|
|
271
309
|
}
|
|
272
310
|
export type ThemeName = "auto" | "light" | "dark" | "poster" | "none";
|
|
273
|
-
export type SizeName = "wide" | "square" | "phone";
|
|
311
|
+
export type SizeName = "wide" | "square" | "phone" | "card";
|
|
274
312
|
export interface Size {
|
|
275
313
|
/** The width of the drawing, in pixels. */
|
|
276
314
|
width: number;
|
|
@@ -279,6 +317,24 @@ export interface Size {
|
|
|
279
317
|
}
|
|
280
318
|
/** How much a box shows: both names and scores, an abbreviation and the score, or only the marks. */
|
|
281
319
|
export type Detail = "auto" | "full" | "compact" | "mark";
|
|
320
|
+
/** How a flag is framed: `round` in a circle, `square`, or `rect` in its own proportions. */
|
|
321
|
+
export type FlagShape = "round" | "square" | "rect";
|
|
322
|
+
/** What a drawing asks a `flags` renderer for. */
|
|
323
|
+
export interface FlagRequest {
|
|
324
|
+
shape: FlagShape;
|
|
325
|
+
/** Width and height in pixels (the diameter, for a round flag). */
|
|
326
|
+
size: number;
|
|
327
|
+
/** `light` or `dark` for a drawing in that look (`poster` is dark); `inherit` for `auto` and `none`. */
|
|
328
|
+
theme: "inherit" | "light" | "dark";
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 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
|
|
332
|
+
* synchronous: a drawing is a pure function of its options. `@johnmorrisdotca/hata`'s `flag()` is asynchronous, so load the flags first
|
|
333
|
+
* (`await flag(code, { shape: "round" })` for each code) and pass `(code) => loaded[code]`.
|
|
334
|
+
*/
|
|
335
|
+
export type FlagRenderer = (code: string, request: FlagRequest) => string | null | undefined;
|
|
336
|
+
/** How a bracket is drawn: `classic` (the default) or `road`, with large round marks, big scores and a dotted path. */
|
|
337
|
+
export type Look = "classic" | "road";
|
|
282
338
|
/** How an emblem is drawn; the names are those of `@johnmorrisdotca/dougu-sports`. */
|
|
283
339
|
export type EmblemStyle = "metal" | "line" | "color";
|
|
284
340
|
/** What `drawBracket` asks an `emblems` renderer for. */
|
|
@@ -293,8 +349,31 @@ export interface EmblemRequest {
|
|
|
293
349
|
}
|
|
294
350
|
/** A function from an emblem id and a request to an SVG string; `renderEmblem` of `@johnmorrisdotca/dougu-sports/emblems` is one. */
|
|
295
351
|
export type EmblemRenderer = (id: string, options: EmblemRequest) => string;
|
|
352
|
+
/** A background preset's name. */
|
|
353
|
+
export type { BackgroundPresetName } from "./family-backgrounds.ts";
|
|
354
|
+
import type { BackgroundPresetName } from "./family-backgrounds.ts";
|
|
355
|
+
/** A preset, tuned: your own colours (hex or `rgb()`, the first two the ground), the gradient's angle, how strong the pattern is (0 to 1, default 0.6), a seed for the scattered parts, and which of its two variants. */
|
|
356
|
+
export interface BackgroundOptions {
|
|
357
|
+
/** Default `midnight`. */
|
|
358
|
+
preset?: BackgroundPresetName;
|
|
359
|
+
colors?: readonly string[];
|
|
360
|
+
angle?: number;
|
|
361
|
+
intensity?: number;
|
|
362
|
+
seed?: number;
|
|
363
|
+
/** `light` or `dark`: the variant to draw. By default the one of the drawing's look. */
|
|
364
|
+
theme?: "light" | "dark";
|
|
365
|
+
}
|
|
366
|
+
/** Your own picture as the background: an image address (http(s), relative or `data:image/…`; anything else is refused), laid under a veil so the text reads. */
|
|
367
|
+
export interface BackgroundImageOptions {
|
|
368
|
+
image: string;
|
|
369
|
+
/** `cover` (the default) fills the drawing; `contain` shows all of the picture. */
|
|
370
|
+
fit?: "cover" | "contain";
|
|
371
|
+
/** How dark (or, in a light look, how pale) the veil is, 0 to 1. Default 0.5. */
|
|
372
|
+
dim?: number;
|
|
373
|
+
theme?: "light" | "dark";
|
|
374
|
+
}
|
|
296
375
|
export interface DrawOptions extends LayoutOptions {
|
|
297
|
-
/** `wide` 1200 by 675, `square` 1080 by 1080, `phone` 390 wide and as tall as it needs; or a size of your own. Default `wide`. */
|
|
376
|
+
/** `wide` 1200 by 675, `square` 1080 by 1080, `card` 1080 by 1350 (a tall post), `phone` 390 wide and as tall as it needs; or a size of your own. Default `wide`. */
|
|
298
377
|
size?: SizeName | {
|
|
299
378
|
width: number;
|
|
300
379
|
height?: number | null;
|
|
@@ -304,8 +383,16 @@ export interface DrawOptions extends LayoutOptions {
|
|
|
304
383
|
detail?: Detail;
|
|
305
384
|
/** `auto` follows the page's light or dark; `poster` is dark with gold lines; `none` writes no style, for your own CSS. Default `auto`. */
|
|
306
385
|
theme?: ThemeName;
|
|
307
|
-
/**
|
|
308
|
-
|
|
386
|
+
/**
|
|
387
|
+
* The background. `true` (the default) is the look's plain colour and `false` a transparent drawing. A preset's name (`"midnight"`, `"ice"`, see `BACKGROUND_PRESETS`) draws that
|
|
388
|
+
* poster background in the look's light or dark variant (`auto` draws both and shows the one that fits the page), and the text, lines, boxes and marks take the colours that
|
|
389
|
+
* read over it. An object tunes a preset (`{ preset, colors, angle, intensity, seed }`) or draws your own picture (`{ image, fit, dim }`).
|
|
390
|
+
*/
|
|
391
|
+
background?: boolean | BackgroundPresetName | BackgroundOptions | BackgroundImageOptions;
|
|
392
|
+
/** In the road look, write a small `vs` between the two marks of a box of marks alone. Default false. */
|
|
393
|
+
vs?: boolean;
|
|
394
|
+
/** In the road look, write each team's three-letter code under its mark in a box of marks alone. Default false for a bracket (a chart's `codes` is on by default). */
|
|
395
|
+
codes?: boolean;
|
|
309
396
|
title?: string;
|
|
310
397
|
subtitle?: string;
|
|
311
398
|
/** Names of the rounds, first round first (or just the last ones). Default: Final, Semi-finals, Quarter-finals, Round of 16… */
|
|
@@ -318,7 +405,7 @@ export interface DrawOptions extends LayoutOptions {
|
|
|
318
405
|
roundLabels?: boolean;
|
|
319
406
|
/** Show the scores. Default true. */
|
|
320
407
|
scores?: boolean;
|
|
321
|
-
/** Show seeds before
|
|
408
|
+
/** Show seeds: the number before the name in the classic look, and in the road look a small tag (`C1`, `WC2`: `Matchup.seeds`, else `Team.tag`, else `Team.seed`) beside each mark. Default false. */
|
|
322
409
|
seeds?: boolean;
|
|
323
410
|
/** `round` (the default), `square`, or `none` (names only). */
|
|
324
411
|
markShape?: "round" | "square" | "none";
|
|
@@ -339,6 +426,34 @@ export interface DrawOptions extends LayoutOptions {
|
|
|
339
426
|
emblemStyle?: EmblemStyle;
|
|
340
427
|
/** A colour for the emblem's main part (a hex colour or `rgb()`), passed to the renderer as `tint`. */
|
|
341
428
|
emblemTint?: string;
|
|
429
|
+
/**
|
|
430
|
+
* Draws the flag a team's `flag` code names: a synchronous function from a code and `{ shape, size, theme }` to an SVG string, such as one
|
|
431
|
+
* made from `@johnmorrisdotca/hata`. With none, or when it returns nothing for a code, the team's `mark` or its initials are drawn.
|
|
432
|
+
*/
|
|
433
|
+
flags?: FlagRenderer;
|
|
434
|
+
/**
|
|
435
|
+
* The address of the flag a team's `flag` code names, for a flag that is a picture to load (a file on your own server) and not SVG to inline, which can be 80 kB for one flag. Tried where `flags` gives
|
|
436
|
+
* none; the address must be http(s), relative or `data:image/…`, and is written once as a symbol however many times the flag appears.
|
|
437
|
+
*/
|
|
438
|
+
flagHref?: (code: string) => string | null | undefined;
|
|
439
|
+
/**
|
|
440
|
+
* A class for each tie's group, from the tie: `(tie) => tie.sides.some(inDivision) ? "mine" : "other"`. A word of letters, digits, `-` and `_` is added to the group's classes (anything else is left out),
|
|
441
|
+
* so that a page's own style can highlight or dim ties: `.mine .tb-box { stroke: … }`. `undefined` or an empty text adds none.
|
|
442
|
+
*/
|
|
443
|
+
tieClass?: (tie: Tie) => string | null | undefined;
|
|
444
|
+
/**
|
|
445
|
+
* `classic` (the default) or `road`: the look of the road-to-the-final chart, with large round marks, big bold scores, the loser quiet, the
|
|
446
|
+
* rounds named on pills and a dotted path. Every other option works in both.
|
|
447
|
+
*/
|
|
448
|
+
look?: Look;
|
|
449
|
+
/**
|
|
450
|
+
* A link for each tie's box, from the tie and, for a link on one team's row, its side (0 or 1). Called with the tie alone first: an address
|
|
451
|
+
* makes the whole box a link; when that gives none, each side is asked, and a row with an address is a link of its own. Each is a real
|
|
452
|
+
* `<a href>` in the SVG with an accessible name; an address that is not http(s), relative or a `#` fragment is refused. `undefined` is no link.
|
|
453
|
+
*/
|
|
454
|
+
href?: (tie: Tie, side?: 0 | 1) => string | null | undefined;
|
|
455
|
+
/** The id of a team whose path to the final is drawn as a dotted line in the look's highlight, the rest quieter. */
|
|
456
|
+
highlightPath?: SideId;
|
|
342
457
|
/** Where the third-place match goes: `below` the final (the default) or `hide`. */
|
|
343
458
|
thirdPlace?: "below" | "hide";
|
|
344
459
|
/** Highlight the side that went through. Default true. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.5.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.5.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/taisen-brackets",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Taisen Brackets 対戦, knockout brackets as SVG: from a list of ties (games, best-of series, two legs, replays, byes, a third-place match) it works out the rounds and halves and draws the bracket with the halves meeting at the final, or left to right, wide, square or for a phone, in light, dark or a gold-on-navy poster look, with each team's logo or round flag, the champion in the centre, and an accessible table. NHL, NBA, MLB, NFL, CFL, MLS and World Cup formats by era, in English, French, Japanese, Spanish and German. Zero dependencies.",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Taisen Brackets 対戦, knockout brackets as SVG: from a list of ties (games, best-of series, two legs, replays, byes, a third-place match) it works out the rounds and halves and draws the bracket with the halves meeting at the final, or left to right, wide, square, as a tall card or for a phone, in a classic or a road look (large round flags, big scores, a team's dotted path, a link on every box), in light, dark or a gold-on-navy poster look, on one of twenty-five poster backgrounds (the playing surfaces of five sports among them) or your own, with each team's logo or round flag, the champion in the centre, and an accessible table; and the road to the final of either finalist. NHL, NBA, MLB, NFL, CFL, MLS and World Cup formats by era, in English, French, Japanese, Spanish and German. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bracket",
|
|
7
7
|
"tournament",
|
|
@@ -62,6 +62,16 @@
|
|
|
62
62
|
"types": "./dist/presets-entry.d.ts",
|
|
63
63
|
"import": "./dist/presets-entry.js",
|
|
64
64
|
"default": "./dist/presets-entry.js"
|
|
65
|
+
},
|
|
66
|
+
"./road": {
|
|
67
|
+
"types": "./dist/road-entry.d.ts",
|
|
68
|
+
"import": "./dist/road-entry.js",
|
|
69
|
+
"default": "./dist/road-entry.js"
|
|
70
|
+
},
|
|
71
|
+
"./backgrounds": {
|
|
72
|
+
"types": "./dist/backgrounds-entry.d.ts",
|
|
73
|
+
"import": "./dist/backgrounds-entry.js",
|
|
74
|
+
"default": "./dist/backgrounds-entry.js"
|
|
65
75
|
}
|
|
66
76
|
},
|
|
67
77
|
"files": [
|
|
@@ -88,14 +98,19 @@
|
|
|
88
98
|
"flags": "node scripts/make-flags.mjs",
|
|
89
99
|
"site": "pnpm build && node scripts/site.mjs",
|
|
90
100
|
"test:demo": "pnpm site && playwright test",
|
|
101
|
+
"images": "pnpm site && node scripts/screenshots.mjs",
|
|
91
102
|
"screenshots": "pnpm site && node scripts/screenshots.mjs"
|
|
92
103
|
},
|
|
93
104
|
"peerDependencies": {
|
|
94
|
-
"@johnmorrisdotca/dougu-sports": ">=0.1.0 <1"
|
|
105
|
+
"@johnmorrisdotca/dougu-sports": ">=0.1.0 <1",
|
|
106
|
+
"@johnmorrisdotca/hata": ">=1.5.0 <2"
|
|
95
107
|
},
|
|
96
108
|
"peerDependenciesMeta": {
|
|
97
109
|
"@johnmorrisdotca/dougu-sports": {
|
|
98
110
|
"optional": true
|
|
111
|
+
},
|
|
112
|
+
"@johnmorrisdotca/hata": {
|
|
113
|
+
"optional": true
|
|
99
114
|
}
|
|
100
115
|
},
|
|
101
116
|
"devDependencies": {
|