@johnmorrisdotca/taisen-brackets 0.5.0 → 0.6.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 +25 -0
- package/NOTICE.md +2 -0
- package/README.md +159 -29
- package/dist/furniture.d.ts +10 -0
- package/dist/furniture.js +29 -0
- package/dist/groups.d.ts +50 -0
- package/dist/groups.js +204 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -2
- package/dist/layout.js +56 -6
- package/dist/layouts.d.ts +48 -0
- package/dist/layouts.js +388 -0
- package/dist/locales.js +10 -0
- package/dist/marks.d.ts +2 -0
- package/dist/marks.js +1 -0
- package/dist/matchup.js +1 -0
- package/dist/playin.d.ts +8 -0
- package/dist/playin.js +232 -0
- package/dist/render.d.ts +8 -1
- package/dist/render.js +223 -34
- package/dist/seeding.js +4 -2
- package/dist/table.js +6 -3
- package/dist/theme.d.ts +4 -0
- package/dist/theme.js +6 -0
- package/dist/types.d.ts +66 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,31 @@ All notable changes to this project are written here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.6.0] - 2026-10-14
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`layout`**: the same ties drawn eight ways. `"tree"` (the default) is the bracket as ever, drawn exactly as before; the rest take the tree's places, lines and round names or plan their own, and all work with `background`, both looks, the four sizes, the five languages, `href` links, seeds, codes, `flags` and `flagHref`, marks and tiles. [docs/layouts.md](docs/layouts.md).
|
|
14
|
+
- **`rows`**: each team a row, its name left and its mark right, a seed tag at the outer corner and a result slot (empty until played) at the end facing the centre.
|
|
15
|
+
- **`shields`**: marks in shield shapes with "vs" between, the matchups on both sides of the trophy, no lines.
|
|
16
|
+
- **`update`**: a compact score-update card: abbreviation, seed and series score a side, the rounds to come empty.
|
|
17
|
+
- **`columns`**: tall slots that grow toward the centre, the two halves in two colours (`--tb-conf-a`, `--tb-conf-b`, `CONFERENCE_COLORS`), "VS" tags, big seed numbers, the final as two tall slots. `at: true` writes "AT" in place of "VS" (a word in each language), the home side drawn second; `Matchup.home` names it.
|
|
18
|
+
- **`playin`**: the NBA's play-in: tiles for the seeds that need no game, the games in columns, a solid arrow for a winner and a dashed one for a loser, "Winner 9/10" and "Loser 7/8" until they are played, the seeds earned at the end.
|
|
19
|
+
- **`series`**: a tall card (1080 by 1350 unless a `size` is asked for) of one line a series, "BOS 4–0 MIA", the winner bold, the east above the west with the final between.
|
|
20
|
+
- **`groups`**: one card a group, a title tile and a row a team with its mark, name and record or points, the places that go through marked (`qualify`). `standings: "points"` (played, won, drawn, lost, goal difference, points) or `"record"` (won, lost, softball's). New `groupStandings(input)` (the tables as data) and `groupsTable(input)` (as HTML).
|
|
21
|
+
- A box too small for everything leaves out the seed tag, then the length of the names, then the score's slot; a geometry test over every layout, size and look holds that nothing sticks out.
|
|
22
|
+
- **Loser edges**: a `feeds` entry can be `{ tie, result: "winner" | "loser" }` (a string is still a winner), `Tie.from` says where each side comes from (`Source = { tie, result }`), and `Matchup.stage: "play-in"` keeps a game out of the tree (`layout.playIn`, `Tie.playIn`). A bracket with none of it is drawn exactly as before. A circle of feeds, or a tie that feeds itself, throws an error naming the ties. `advanceWinners` fills a side from a loser, `bracketTable` calls the games "Play-in" and says "Loser of A v B".
|
|
23
|
+
- **`headers: true`**: a big title tile over each half (West and East, AFC and NFC) in the colour of that half, in any layout.
|
|
24
|
+
- **A lone final is centred.** A tournament whose tree is a final alone with a third-place match (the World Cups of 1974 and 1978) is drawn with the final centred, the champion over it and the third place under it, in every layout, size and look, not off to one side.
|
|
25
|
+
- **One stylesheet for several drawings**: `styleScope` (a class that carries the rules in place of the drawing's own), `style: false` (leave the `<style>` out of a second drawing) and `bracketStyle(options)` (the rules, for a page that writes them once). The ids of the drawings stay apart.
|
|
26
|
+
- New words in the five languages: `vs`, `at`, `groupName`, `colPlayed` to `colPoints`, `playIn`, `playInWinner`, `playInLoser`, `seedSlot`, `winnerOf`, `loserOf`. The French and Japanese were read by native-language reviewers; the Spanish and German need one (docs/languages.md).
|
|
27
|
+
- The demo has a layout switcher on each sport (NHL rows and update, NFL columns, NBA play-in and series, World Cup shields, made-up groups, softball groups), "Headers" and "AT" chips, and a gallery of the layouts on their backgrounds. New demo data: the 2024 NBA play-in (typed from English Wikipedia, CC BY-SA 4.0) and two made-up group stages.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- The README's pictures are **WebP**, made in the browser by `pnpm images` (no tool beyond Chromium), two to three times smaller than the JPEG they replaced at no visible loss; the repository's `docs/images` shrinks with them.
|
|
32
|
+
- The README, docs/roadmap.md and docs/references.md say what 0.6.0 built and what is left.
|
|
33
|
+
|
|
9
34
|
## [0.5.0] - 2026-10-14
|
|
10
35
|
|
|
11
36
|
### Added
|
package/NOTICE.md
CHANGED
|
@@ -9,6 +9,8 @@ The code of this package is under the MIT licence (see [LICENSE](LICENSE)). The
|
|
|
9
9
|
| The demo's World Cup results of 2026 (`demo/data/worldcup-2026.js`) | openfootball/worldcup, https://github.com/openfootball/worldcup, read through spxn.com | CC0 |
|
|
10
10
|
| The demo's NHL results (`demo/data/nhl-2024.js`, `demo/data/nhl-1984.js`) | Every game of the 2024 and the 1984 Stanley Cup playoffs and each team's conference, from the NHL ("NHL", as spxn.com credits it), read through spxn.com | Facts; credited to the NHL |
|
|
11
11
|
| The demo's NBA results (`demo/data/nba-2024.js`) | Every game of the 2024 NBA playoffs and each team's conference, from English Wikipedia (https://en.wikipedia.org/wiki/2024_NBA_playoffs), read through spxn.com, which holds them as sourced from Wikipedia | **CC BY-SA 4.0** (https://creativecommons.org/licenses/by-sa/4.0/legalcode). That file is an adaptation and is shared under the same licence, with this credit; the pictures of the NBA bracket carry it too |
|
|
12
|
+
| The demo's NBA play-in results (`demo/data/nba-2024-playin.js`) | The six games of the 2024 NBA play-in tournament and the seeds of the teams that played in it, typed from English Wikipedia's article on the 2023-24 NBA season (https://en.wikipedia.org/wiki/2023%E2%80%9324_NBA_season#Play-in_tournament), read on 2026-10-14; not read through spxn.com | **CC BY-SA 4.0** (https://creativecommons.org/licenses/by-sa/4.0/legalcode). That file is an adaptation and is shared under the same licence, with this credit; the pictures of the play-in carry it too |
|
|
13
|
+
| The demo's group tables (`cupGroups`, `softballGroups` in `demo/data.js`) | Made up: the clubs and teams do not exist, and the results come from a fixed recipe in the file | Nothing to credit; MIT with the rest |
|
|
12
14
|
| The demo's MLS results (`demo/data/mls-2024.js`) | Every match of the 2024 MLS Cup Playoffs and each club's conference, read through spxn.com, whose MLS data is from openfootball/world (CC0, https://github.com/openfootball/world) checked against English Wikipedia (https://en.wikipedia.org/wiki/2024_MLS_Cup_Playoffs) | **CC BY-SA 4.0** (Wikipedia is in the mix, so the file is an adaptation shared under the same licence, with this credit); openfootball's part is CC0; the pictures of the MLS bracket carry the same licence |
|
|
13
15
|
| The demo's NFL results (`demo/data/nfl-2024.js`) | Every game of the playoffs of the 2024 NFL season (January and February 2025) and each team's conference, from nflverse (https://github.com/nflverse/nflverse-data), read through spxn.com | CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/), credited to nflverse |
|
|
14
16
|
| The demo's CFL results (`demo/data/cfl-2024.js`) | Every game of the 2024 CFL playoffs and each team's division, from English Wikipedia (https://en.wikipedia.org/wiki/2024_CFL_season), read through spxn.com | **CC BY-SA 4.0**, as for the NBA file above; the pictures of the CFL bracket carry it too |
|
package/README.md
CHANGED
|
@@ -11,22 +11,22 @@ Give it the games, series, two-legged ties or replays of a tournament and it wor
|
|
|
11
11
|
<img alt="TypeScript" src="https://img.shields.io/badge/types-TypeScript-3178c6">
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
|
-
<p align="center"><a href="https://johnmorrisdotca.github.io/taisen-brackets/"><strong>Open the demo →</strong></a> · <a href="./docs/layout.md">Layout</a> · <a href="./docs/drawing.md">Drawing</a> · <a href="./docs/road.md">Road to the final</a> · <a href="./docs/backgrounds.md">Backgrounds</a> · <a href="./docs/formats.md">Formats</a> · <a href="./docs/compare.md">How it compares</a></p>
|
|
14
|
+
<p align="center"><a href="https://johnmorrisdotca.github.io/taisen-brackets/"><strong>Open the demo →</strong></a> · <a href="./docs/layout.md">Layout</a> · <a href="./docs/layouts.md">Layouts</a> · <a href="./docs/drawing.md">Drawing</a> · <a href="./docs/road.md">Road to the final</a> · <a href="./docs/backgrounds.md">Backgrounds</a> · <a href="./docs/formats.md">Formats</a> · <a href="./docs/compare.md">How it compares</a></p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
17
|
<picture>
|
|
18
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-dark.
|
|
19
|
-
<img alt="The 2022 World Cup knockout: two halves of eight teams meeting at the final in the centre, with Argentina's round flag and the word Champion above it and the third-place match below. Each box has both teams' round flags, abbreviations and scores, with penalties in brackets." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-light.
|
|
18
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-dark.webp">
|
|
19
|
+
<img alt="The 2022 World Cup knockout: two halves of eight teams meeting at the final in the centre, with Argentina's round flag and the word Champion above it and the third-place match below. Each box has both teams' round flags, abbreviations and scores, with penalties in brackets." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-light.webp" width="720">
|
|
20
20
|
</picture>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
<table align="center">
|
|
24
24
|
<tr>
|
|
25
25
|
<td align="center" valign="top">
|
|
26
|
-
<img alt="The poster look: the 2026 World Cup knockout of 32 nations as round flags on dark navy joined by gold lines, Spain's flag in the centre above the word Champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/poster-desk.
|
|
26
|
+
<img alt="The poster look: the 2026 World Cup knockout of 32 nations as round flags on dark navy joined by gold lines, Spain's flag in the centre above the word Champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/poster-desk.webp" width="470"><br><em>The poster look: flags only, gold on navy (the 2026 World Cup).</em>
|
|
27
27
|
</td>
|
|
28
28
|
<td align="center" valign="top">
|
|
29
|
-
<img alt="The 2022 World Cup on a phone: the champion at the top, then the rounds as rows, the first round at the top and at the bottom, the final in the middle, and the third-place match at the foot." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/phone-light.
|
|
29
|
+
<img alt="The 2022 World Cup on a phone: the champion at the top, then the rounds as rows, the first round at the top and at the bottom, the final in the middle, and the third-place match at the foot." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/phone-light.webp" width="190"><br><em>On a phone the rounds are rows.</em>
|
|
30
30
|
</td>
|
|
31
31
|
</tr>
|
|
32
32
|
</table>
|
|
@@ -37,22 +37,22 @@ One layout draws them all, each from real results: the demo has a picker for the
|
|
|
37
37
|
|
|
38
38
|
<table>
|
|
39
39
|
<tr>
|
|
40
|
-
<td align="center" valign="top"><img alt="The 2024 NHL playoffs: Western and Eastern conferences, best-of-seven series, Florida Panthers as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nhl-desk-light.
|
|
41
|
-
<td align="center" valign="top"><img alt="The 1984 Stanley Cup playoffs: the Campbell and Wales conferences, a best-of-five first round, Edmonton Oilers as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nhl1984-desk-light.
|
|
42
|
-
<td align="center" valign="top"><img alt="The 2024 NBA playoffs: sixteen teams in two conferences, Boston Celtics as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nba-desk-light.
|
|
40
|
+
<td align="center" valign="top"><img alt="The 2024 NHL playoffs: Western and Eastern conferences, best-of-seven series, Florida Panthers as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nhl-desk-light.webp" width="360"><br><em>NHL 2024, series</em></td>
|
|
41
|
+
<td align="center" valign="top"><img alt="The 1984 Stanley Cup playoffs: the Campbell and Wales conferences, a best-of-five first round, Edmonton Oilers as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nhl1984-desk-light.webp" width="360"><br><em>NHL 1984, an older era</em></td>
|
|
42
|
+
<td align="center" valign="top"><img alt="The 2024 NBA playoffs: sixteen teams in two conferences, Boston Celtics as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nba-desk-light.webp" width="360"><br><em>NBA 2024</em></td>
|
|
43
43
|
</tr>
|
|
44
44
|
<tr>
|
|
45
|
-
<td align="center" valign="top"><img alt="The 2022 MLB postseason: byes for the top two seeds of each league, Houston Astros as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/byes-desk-light.
|
|
46
|
-
<td align="center" valign="top"><img alt="The playoffs of the 2024 NFL season: single games, byes for the top seed of each conference, the Super Bowl at the centre, Philadelphia Eagles as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nfl-desk-light.
|
|
47
|
-
<td align="center" valign="top"><img alt="The 2024 CFL playoffs: division semi-finals and finals, byes, the Grey Cup at the centre, Toronto Argonauts as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/cfl-desk-light.
|
|
45
|
+
<td align="center" valign="top"><img alt="The 2022 MLB postseason: byes for the top two seeds of each league, Houston Astros as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/byes-desk-light.webp" width="360"><br><em>MLB 2022, byes</em></td>
|
|
46
|
+
<td align="center" valign="top"><img alt="The playoffs of the 2024 NFL season: single games, byes for the top seed of each conference, the Super Bowl at the centre, Philadelphia Eagles as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/nfl-desk-light.webp" width="360"><br><em>NFL 2024 season, the Super Bowl</em></td>
|
|
47
|
+
<td align="center" valign="top"><img alt="The 2024 CFL playoffs: division semi-finals and finals, byes, the Grey Cup at the centre, Toronto Argonauts as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/cfl-desk-light.webp" width="360"><br><em>CFL 2024, the Grey Cup</em></td>
|
|
48
48
|
</tr>
|
|
49
49
|
<tr>
|
|
50
|
-
<td align="center" valign="top"><img alt="The 2022 World Cup knockout stage." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-light.
|
|
51
|
-
<td align="center" valign="top"><img alt="The 1938 World Cup: replays." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/replays-desk-light.
|
|
52
|
-
<td align="center" valign="top"><img alt="The 2026 World Cup as a flags-only poster, in Japanese." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/poster-desk-ja.
|
|
50
|
+
<td align="center" valign="top"><img alt="The 2022 World Cup knockout stage." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/hero-desk-light.webp" width="360"><br><em>World Cup 2022</em></td>
|
|
51
|
+
<td align="center" valign="top"><img alt="The 1938 World Cup: replays." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/replays-desk-light.webp" width="360"><br><em>World Cup 1938, replays</em></td>
|
|
52
|
+
<td align="center" valign="top"><img alt="The 2026 World Cup as a flags-only poster, in Japanese." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/poster-desk-ja.webp" width="360"><br><em>World Cup 2026 poster, in Japanese</em></td>
|
|
53
53
|
</tr>
|
|
54
54
|
<tr>
|
|
55
|
-
<td align="center" valign="top"><img alt="The 2024 MLS Cup Playoffs: a wild card match, a best-of-three round one, then single matches to the MLS Cup, LA Galaxy as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/mls-desk-light.
|
|
55
|
+
<td align="center" valign="top"><img alt="The 2024 MLS Cup Playoffs: a wild card match, a best-of-three round one, then single matches to the MLS Cup, LA Galaxy as champion." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/mls-desk-light.webp" width="360"><br><em>MLS 2024, best of three</em></td>
|
|
56
56
|
<td></td>
|
|
57
57
|
<td></td>
|
|
58
58
|
</tr>
|
|
@@ -64,25 +64,152 @@ One layout draws them all, each from real results: the demo has a picker for the
|
|
|
64
64
|
|
|
65
65
|
<table>
|
|
66
66
|
<tr>
|
|
67
|
-
<td align="center" valign="top"><img alt="The 2022 World Cup in the road look, wide: large round flags, big bold scores, the loser quiet, the rounds on pills, and Argentina's path to the final as a dotted line." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/path-desk-light.
|
|
68
|
-
<td align="center" valign="top"><img alt="The 2022 World Cup in the road look on a card, 1080 by 1350: the champion at the top, then the rounds as rows." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/card-light.
|
|
69
|
-
<td align="center" valign="top"><img alt="The road to the final of the 2022 World Cup on a phone in the dark: Argentina and France as large flags, and each one's matches with the score between the two flags." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-phone-dark.
|
|
67
|
+
<td align="center" valign="top"><img alt="The 2022 World Cup in the road look, wide: large round flags, big bold scores, the loser quiet, the rounds on pills, and Argentina's path to the final as a dotted line." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/path-desk-light.webp" width="460"><br><em>The road look, wide, with Argentina's path.</em></td>
|
|
68
|
+
<td align="center" valign="top"><img alt="The 2022 World Cup in the road look on a card, 1080 by 1350: the champion at the top, then the rounds as rows." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/card-light.webp" width="260"><br><em>A card, 1080 by 1350.</em></td>
|
|
69
|
+
<td align="center" valign="top"><img alt="The road to the final of the 2022 World Cup on a phone in the dark: Argentina and France as large flags, and each one's matches with the score between the two flags." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-phone-dark.webp" width="190"><br><em>The road to the final, on a phone.</em></td>
|
|
70
70
|
</tr>
|
|
71
71
|
<tr>
|
|
72
|
-
<td align="center" valign="top"><img alt="The same bracket in the classic look, which stays the default." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/classic-desk-light.
|
|
73
|
-
<td align="center" valign="top"><img alt="The road to the final of the 2024 Stanley Cup playoffs: Florida and Edmonton, each one's three series with the games won between the two logos." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-wide-nhl-light.
|
|
74
|
-
<td align="center" valign="top"><img alt="The road to the final of the 2022 World Cup on a card." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-card-light.
|
|
72
|
+
<td align="center" valign="top"><img alt="The same bracket in the classic look, which stays the default." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/classic-desk-light.webp" width="460"><br><em>The classic look, still the default.</em></td>
|
|
73
|
+
<td align="center" valign="top"><img alt="The road to the final of the 2024 Stanley Cup playoffs: Florida and Edmonton, each one's three series with the games won between the two logos." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-wide-nhl-light.webp" width="460"><br><em>The road to the final, a play-off (NHL 2024).</em></td>
|
|
74
|
+
<td align="center" valign="top"><img alt="The road to the final of the 2022 World Cup on a card." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/road-card-light.webp" width="260"><br><em>The road to the final, a card.</em></td>
|
|
75
75
|
</tr>
|
|
76
76
|
</table>
|
|
77
77
|
|
|
78
|
+
## Layouts
|
|
79
|
+
|
|
80
|
+
`layout` draws the same ties another way: the default, `"tree"`, is the bracket above; the others are `"rows"`, `"shields"`, `"update"`, `"columns"`, `"playin"`, `"series"` and `"groups"`. Each takes the `background`, both looks, the four sizes, the five languages, `href` links, seeds, codes, flags and logos, and a team with no picture is its tile. [docs/layouts.md](./docs/layouts.md) has the options and what each needs.
|
|
81
|
+
|
|
82
|
+
### rows
|
|
83
|
+
|
|
84
|
+
Each team a row, its name on the left and its mark on the right, its seed tag at the outer corner, and a slot for the result at the end that faces the centre (empty until the tie is played): the NHL poster's style.
|
|
85
|
+
|
|
86
|
+
<p align="center"><img alt="The 2024 NHL playoffs as rows: each team's abbreviation and seed tag, its logo tile and a slot with the games won, on an ice background." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-rows-nhl.webp" width="640"></p>
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import { drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
90
|
+
|
|
91
|
+
const ties = [
|
|
92
|
+
{ id: "a", sides: ["BOS", "MIA"], round: 1, bestOf: 7, score: [4, 1] },
|
|
93
|
+
{ id: "b", sides: ["NYK", "IND"], round: 1, bestOf: 7, score: [4, 3] },
|
|
94
|
+
{ id: "c", sides: ["BOS", "NYK"], round: 2, bestOf: 7, score: [2, 1] },
|
|
95
|
+
];
|
|
96
|
+
const svg = drawBracket(ties, { layout: "rows", look: "road", seeds: true });
|
|
97
|
+
console.log(svg.includes("tb-slot")); // true
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### shields
|
|
101
|
+
|
|
102
|
+
Marks in shield shapes with "vs" between the two of a tie, the matchups listed down both sides of the trophy; no connector lines.
|
|
103
|
+
|
|
104
|
+
<p align="center"><img alt="The 2022 World Cup as shields: each tie two round flags in shields with vs between them and the score under each, the final under the trophy." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-shields-wc2022.webp" width="640"></p>
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
import { drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
108
|
+
|
|
109
|
+
const svg = drawBracket([{ sides: ["ARG", "FRA"], score: [3, 3], pens: [4, 2] }], { layout: "shields" });
|
|
110
|
+
console.log(svg.includes("tb-shield"), svg.includes(">vs<")); // true true
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### update
|
|
114
|
+
|
|
115
|
+
A compact score-update card: each side's abbreviation, seed and series score, and empty cards for the rounds still to come, the final in the centre. Put the "as of" date in `subtitle`.
|
|
116
|
+
|
|
117
|
+
<p align="center"><img alt="A score-update card of the 2024 NHL playoffs: abbreviations with seeds and the games won in a cell on the right, on an aurora background." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-update-nhl.webp" width="640"></p>
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
import { drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
121
|
+
|
|
122
|
+
const teams = [{ id: "A", name: "Alpha", abbr: "ALP", seed: 1 }, { id: "B", name: "Beta", abbr: "BET", seed: 8 }];
|
|
123
|
+
const svg = drawBracket({ teams, matchups: [{ sides: ["A", "B"], round: 1, bestOf: 7, score: [4, 2] }] }, { layout: "update", subtitle: "as of May 1" });
|
|
124
|
+
console.log(svg.includes(">ALP<"), svg.includes(">as of May 1<")); // true true
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### columns
|
|
128
|
+
|
|
129
|
+
The NFL poster's style: each round a column of tall slots that get taller toward the centre, one conference in each of two colours, a "VS" tag between the two slots of a tie, a big seed number beside a team that has a `seed`, and the final as two tall slots side by side. `at: true` writes the language's "AT" in place of "VS", the second side being the one at home (or the side `Matchup.home` names). `headers: true` adds the conference tiles.
|
|
130
|
+
|
|
131
|
+
<p align="center"><img alt="The 2024 NFL playoffs as columns: tall slots growing toward the centre, the AFC in blue and the NFC in red, VS tags between the slots, the Super Bowl as two tall slots, with a title tile over each half." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-columns-nfl.webp" width="640"></p>
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import { drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
135
|
+
|
|
136
|
+
const ties = [{ sides: ["KC", "BUF"], round: 1, score: [27, 24], home: 0 }, { sides: ["PHI", "WAS"], round: 1, score: [28, 23] }];
|
|
137
|
+
const svg = drawBracket(ties, { layout: "columns", at: true });
|
|
138
|
+
console.log(svg.includes(">AT<"), svg.includes(">VS<")); // true false
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### playin
|
|
142
|
+
|
|
143
|
+
The NBA's play-in: the games of each half (a `stage: "play-in"` tie), with a **winner's arrow solid and a loser's dashed**, into the game that takes it ("Winner 9/10", "Loser 7/8") or the seed it earns, and the seeds that need no game as tiles. A tie says where a side comes from with `feeds`, whose entries can now be `{ tie, result: "winner" | "loser" }`; `Tie.from` has it back.
|
|
144
|
+
|
|
145
|
+
<p align="center"><img alt="The 2024 NBA play-in: for each conference the 7 v 8 and 9 v 10 games, a dashed arrow for the 7 v 8 loser into the decider with the 9 v 10 winner, and a solid arrow into the 7th and 8th seed slots, beside tiles for seeds 1 to 6." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-playin-nba.webp" width="640"></p>
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
import { drawBracket, layoutBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
149
|
+
|
|
150
|
+
const matchups = [
|
|
151
|
+
{ id: "p78", stage: "play-in", sides: ["T7", "T8"], score: [105, 104], seeds: [7, 8] },
|
|
152
|
+
{ id: "p910", stage: "play-in", sides: ["T9", "T10"], score: [131, 116], seeds: [9, 10] },
|
|
153
|
+
{ id: "dec", stage: "play-in", sides: ["T8", "T9"], score: [112, 91], feeds: [{ tie: "p78", result: "loser" }, { tie: "p910", result: "winner" }] },
|
|
154
|
+
];
|
|
155
|
+
console.log(JSON.stringify(layoutBracket({ matchups }).ties[2].from)); // [{"tie":0,"result":"loser"},{"tie":1,"result":"winner"}]
|
|
156
|
+
console.log(drawBracket({ matchups }, { layout: "playin" }).includes("tb-arrow-loser")); // true
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### series
|
|
160
|
+
|
|
161
|
+
A tall card of one line a series, "BOS 4–0 MIA", the winner bold, the seeds at the line's ends, the east on top and the west below with the final in the middle. It is a card (1080 by 1350) unless a `size` is asked for.
|
|
162
|
+
|
|
163
|
+
<p align="center"><img alt="The 2024 NBA playoffs as a series card: the Eastern Conference on top, one line a series such as BOS 4-1 MIA, the final in the middle and the Western Conference below, on a carbon background." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-series-nba.webp" width="360"></p>
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
import { drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
167
|
+
|
|
168
|
+
const svg = drawBracket([{ sides: ["BOS", "MIA"], round: 1, bestOf: 7, score: [4, 0] }], { layout: "series" });
|
|
169
|
+
console.log(svg.includes('viewBox="0 0 1080 1350"'), svg.includes(">4–0<")); // true true
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### groups
|
|
173
|
+
|
|
174
|
+
The group stage as one card a group: a title tile ("Group A"), a row a team with its flag or mark, its name and its record, the places that go through marked. The standings are worked out from the round-robin games (`round: 0`); `standings: "record"` is wins and losses (softball's), and `"points"` (the default) played, won, drawn, lost, goal difference and points. `qualify: 2` marks the top two of each group.
|
|
175
|
+
|
|
176
|
+
<p align="center"><img alt="The group stage of a made-up cup: four cards, each with a title tile and four teams with their marks and played, won, drawn, lost, goal difference and points, the top two of each marked." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-groups-cup.webp" width="640"></p>
|
|
177
|
+
|
|
178
|
+
<p align="center"><img alt="Softball pool play on a phone: three cards of four teams with their wins and losses, the top two of each marked, on a royal background." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-groups-softball.webp" width="260"></p>
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import { drawBracket, groupStandings } from "@johnmorrisdotca/taisen-brackets";
|
|
182
|
+
|
|
183
|
+
const games = [
|
|
184
|
+
{ sides: ["A", "B"], round: 0, score: [2, 0] }, { sides: ["A", "C"], round: 0, score: [1, 1] }, { sides: ["B", "C"], round: 0, score: [0, 3] },
|
|
185
|
+
];
|
|
186
|
+
console.log(groupStandings({ matchups: games })[0].rows.map((r) => `${r.team.id} ${r.points}`).join(", ")); // C 4, A 4, B 0
|
|
187
|
+
console.log(drawBracket({ matchups: games }, { layout: "groups", qualify: 2 }).includes("Group A")); // true
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Conference headers, a lone final, one stylesheet
|
|
191
|
+
|
|
192
|
+
`headers: true` puts a big title tile over each half (West and East, AFC and NFC) in the colour of that half, in any layout. A tournament that ended with a lone final and a third-place match (the World Cups of 1974 and 1978) is drawn with them centred, the champion over the final. And two sizes of the same bracket on one page can share one stylesheet: `styleScope` names the class that carries the rules, `style: false` leaves the `<style>` out of the second drawing, and `bracketStyle(options)` is the stylesheet for a page that writes it once itself.
|
|
193
|
+
|
|
194
|
+
<p align="center"><img alt="A lone final and a third-place match, centred: the champion above the final, the third place under it, on a pitch background." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/layout-lone-final.webp" width="560"></p>
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { bracketStyle, drawBracket } from "@johnmorrisdotca/taisen-brackets";
|
|
198
|
+
|
|
199
|
+
const ties = [{ sides: ["A", "B"], round: 1, score: [2, 1] }];
|
|
200
|
+
const desk = drawBracket(ties, { styleScope: "mine", size: "wide" });
|
|
201
|
+
const phone = drawBracket(ties, { styleScope: "mine", size: "phone", style: false });
|
|
202
|
+
console.log(desk.includes("<style>"), phone.includes("<style>"), desk.includes(bracketStyle({ styleScope: "mine" }))); // true false true
|
|
203
|
+
```
|
|
204
|
+
|
|
78
205
|
## Backgrounds
|
|
79
206
|
|
|
80
207
|
`background` draws a poster background under the bracket: a gradient, a glow, a pattern or the markings of a playing surface, all drawn in code, each in a dark and a light variant. The text, the lines, the boxes and the marks take the colours that read over it. The plain colour stays the default.
|
|
81
208
|
|
|
82
209
|
<p align="center">
|
|
83
210
|
<picture>
|
|
84
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/backgrounds-dark.
|
|
85
|
-
<img alt="The twenty-five backgrounds in a grid of five by five, each behind a different bracket: midnight, crimson, royal, emerald, pitch, ice, hardwood, infield, turf, ball-panels, swirl, waves, glow, floodlights, confetti, carbon, aurora, sunburst, chevrons, halftone, argyle, contour, stardust, mesh and spotlight." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/backgrounds-light.
|
|
211
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/backgrounds-dark.webp">
|
|
212
|
+
<img alt="The twenty-five backgrounds in a grid of five by five, each behind a different bracket: midnight, crimson, royal, emerald, pitch, ice, hardwood, infield, turf, ball-panels, swirl, waves, glow, floodlights, confetti, carbon, aurora, sunburst, chevrons, halftone, argyle, contour, stardust, mesh and spotlight." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/backgrounds-light.webp" width="900">
|
|
86
213
|
</picture>
|
|
87
214
|
</p>
|
|
88
215
|
|
|
@@ -148,6 +275,7 @@ Put the string in a page (`element.innerHTML = svg`), write it to a file, or sen
|
|
|
148
275
|
- **The road to the final**: `roadToFinal` draws the two finalists of the tournament you already have, with the ties each played on the way and the score between their flags, on a card, a square, wide or a phone.
|
|
149
276
|
- **Poster backgrounds**: twenty-five, drawn in code, each in a dark and a light variant, among them the playing surfaces of hockey, basketball, baseball, football and soccer; your own colours, or your own picture; and the text, lines and boxes take the colours that read over them (4.5 to 1, held by a test).
|
|
150
277
|
- **Seed tags, codes and a "vs"** in the road look, and a team with no picture drawn as a tile with its letters, so that nothing looks missing.
|
|
278
|
+
- **Eight layouts**: `layout` draws the same ties as the tree, as `rows` (a name, a mark and a result slot a team), `shields`, a score-`update` card, tall `columns` in two conference colours, the NBA's `playin` with winners' and losers' arrows, a `series` card, or the `groups` tables; with big conference `headers` over each half in any of them, a lone final centred, and one stylesheet for several drawings (`styleScope`, `style: false`).
|
|
151
279
|
- **Nothing sticks out**: marks, text and round names stay inside their boxes and off the connector lines, in every size and both looks, held by a geometry test.
|
|
152
280
|
- **A link on every box**: `href: (tie, side?) => address` makes each tie's box (or each team's row) a real `<a>` in the SVG with an accessible name.
|
|
153
281
|
- **Flags from a plug-in**: a team's `flag` code is drawn by the `flags` function you pass (Hata's round flags are one line), with no dependency added.
|
|
@@ -158,7 +286,7 @@ Put the string in a page (`element.innerHTML = svg`), write it to a file, or sen
|
|
|
158
286
|
- **Formats by era**: NHL, NBA, MLB, NFL, CFL, MLS and FIFA World Cup round names, series lengths and byes.
|
|
159
287
|
- **Five languages**: English, French, Japanese, Spanish and German, for every word the drawing, the tooltips, the description and the table write, with the football terms of each language; countries named by `Intl` from their ISO code; numbers and dates by `Intl`. Add a language of your own.
|
|
160
288
|
- **Deterministic**: no clock, no random number, no counter; the same input gives the same string, and ids come from a hash of the input.
|
|
161
|
-
- **No dependencies**, ESM with types, about
|
|
289
|
+
- **No dependencies**, ESM with types, about 140 kB packed.
|
|
162
290
|
|
|
163
291
|
## Use it in your project
|
|
164
292
|
|
|
@@ -504,8 +632,10 @@ The string is built from your data, with every name escaped; do not put untruste
|
|
|
504
632
|
|
|
505
633
|
Everything is exported from `@johnmorrisdotca/taisen-brackets`; the layout part from `/layout`, the formats from `/presets`. The types are in the package; each function's doc comment has its details.
|
|
506
634
|
|
|
507
|
-
- `drawBracket(input, options?)`: the SVG string. `input` is a list of matchups, `{ matchups, teams }` or a layout. Options: `size`, `orientation`, `shape`, `detail`, `theme`, `background` (a preset's name, a tuned preset or your own picture), `vs`, `codes`, `title`, `subtitle`, `roundNames`, `roundLabels`, `scores`, `seeds`, `markShape`, `champion`, `trophy`, `emblems`, `emblemStyle`, `emblemTint`, `thirdPlace`, `winnerHighlight`, `look`, `href`, `tieClass`, `highlightPath`, `flags`, `flagHref`, `locale`, `words`, `teamName`, `groupOrder`, `id`, `className`.
|
|
635
|
+
- `drawBracket(input, options?)`: the SVG string. `input` is a list of matchups, `{ matchups, teams }` or a layout. Options: `layout`, `headers`, `at`, `standings`, `qualify`, `style`, `styleScope`, `size`, `orientation`, `shape`, `detail`, `theme`, `background` (a preset's name, a tuned preset or your own picture), `vs`, `codes`, `title`, `subtitle`, `roundNames`, `roundLabels`, `scores`, `seeds`, `markShape`, `champion`, `trophy`, `emblems`, `emblemStyle`, `emblemTint`, `thirdPlace`, `winnerHighlight`, `look`, `href`, `tieClass`, `highlightPath`, `flags`, `flagHref`, `locale`, `words`, `teamName`, `groupOrder`, `id`, `className`.
|
|
508
636
|
- `roadToFinal(input, options?)`: the road to the final of a tournament or of two finalists: `{ options, title, summary, totals, draw(extra?), table(options?) }`. `input` is what `drawBracket` takes, or the two finalists with their paths. Options: `team`, `title`, `subtitle`, `final`, `labels`, `groupLabel`, `size`, `winner`, `codes`, `endnote`, and `locale`, `words`, `teamName`, `roundNames`, `markShape`, `flags`, `theme`, `background`, `id`, `className` as for `drawBracket`. The types `RoadChart`, `RoadFinalist`, `RoadMatch`, `RoadOptions` and the rest are exported too; it is also the one export of `/road`.
|
|
637
|
+
- `groupStandings(input, options?)`, `groupsTable(input, options?)`: the group stage's tables as data (`GroupTable`, `GroupRow`) and as HTML, from the round-robin games.
|
|
638
|
+
- `bracketStyle(options)`: the stylesheet of a drawing with those options and a `styleScope`, for a page that draws a bracket twice. `LAYOUTS` lists the layouts, `CONFERENCE_COLORS` the two half colours of the layouts that colour them (`--tb-conf-a` and `--tb-conf-b`).
|
|
509
639
|
- `layoutBracket(input, options?)`: the rounds, halves, rows, byes and results, without drawing. `shape: "ltr"` and `groupOrder` are its options.
|
|
510
640
|
- `bracketTable(input, options?)`: the HTML table.
|
|
511
641
|
- `describeBracket(input, options?)`: the sentence a screen reader gets.
|
|
@@ -540,7 +670,7 @@ for (const locale of ["en", "fr", "ja", "es", "de"]) console.log(describeBracket
|
|
|
540
670
|
// 2 Teams, 1 Runde. Finale: Argentinien 3, Frankreich 3 (nach Verlängerung, 4:2 im Elfmeterschießen). Sieger: Argentinien. Turniersieger: Argentinien.
|
|
541
671
|
```
|
|
542
672
|
|
|
543
|
-
<p align="center"><img alt="The same bracket, the World Cup of 2022 on a phone's layout, in English, French, Japanese, Spanish and German side by side: the rounds, the notes, the label under the champion and the names of the countries are each in their language." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/languages-wc2022.
|
|
673
|
+
<p align="center"><img alt="The same bracket, the World Cup of 2022 on a phone's layout, in English, French, Japanese, Spanish and German side by side: the rounds, the notes, the label under the champion and the names of the countries are each in their language." src="https://raw.githubusercontent.com/johnmorrisdotca/taisen-brackets/main/docs/images/languages-wc2022.webp" width="900"></p>
|
|
544
674
|
|
|
545
675
|
- `locale` is `"en"` (the default), `"fr"`, `"ja"`, `"es"`, `"de"`, or a `Locale` you made with `defineLocale`. It sets the words, the names of the rounds, the `lang` of the `<svg>` and of the `<table>`, the digits and the dates (`Intl`), and capitals by the language's rules (not for Japanese). `LOCALES` holds the tables and `LOCALE_CODES` lists the codes.
|
|
546
676
|
- **Round names** are the football terms of each language's Wikipedia article on the World Cup: *Huitièmes de finale*, *Octavos de final*, *Achtelfinale*, ラウンド16; the leagues' rounds (NHL, NBA, MLB, NFL, CFL) are the generic words translated, and a league's own name is kept in the form the language uses (*Finale de la Coupe Stanley*, *Stanley-Cup-Finale*, *Coupe Grey*, *Super Bowl*, スーパーボウル). [docs/languages.md](./docs/languages.md) lists every term, what it was checked against, and what still needs a native reader (Spanish and German).
|
|
@@ -586,7 +716,7 @@ The names are `bg`, `ink`, `muted`, `line`, `box`, `edge`, `win`, `gold`, `plain
|
|
|
586
716
|
|
|
587
717
|
## Limits
|
|
588
718
|
|
|
589
|
-
- A bracket is a tree: every tie feeds one tie. Double elimination
|
|
719
|
+
- A bracket is a tree: every tie feeds one tie. Double elimination is not drawn. A loser can go on to another tie (`feeds: [{ tie, result: "loser" }]`), but only the play-in layout draws that edge; round-robin games (`round: 0`) are drawn as group tables by the `groups` layout, and below the tree by the others.
|
|
590
720
|
- Text is measured by an estimate from character classes, not a font file, so that the string is the same on every machine; a long name is cut with an ellipsis a few percent early or late.
|
|
591
721
|
- A series with no `bestOf` and no winner is not decided, whatever the games won say.
|
|
592
722
|
- On a phone the champion is at the top and the third-place match at the foot; in a wide bracket of two halves they are in the centre.
|
|
@@ -602,11 +732,11 @@ Any current browser, and Node 22 or later. The package makes no network request
|
|
|
602
732
|
|
|
603
733
|
## Roadmap
|
|
604
734
|
|
|
605
|
-
- Double elimination, and
|
|
735
|
+
- Double elimination, and the group tables on one page with the knockout they lead to.
|
|
606
736
|
- More languages (Portuguese, Italian, Korean, Chinese), and native review of the Spanish and German words.
|
|
607
737
|
- A custom element and a React helper, as in the other packages of the family.
|
|
608
738
|
- A PNG renderer (through an optional peer).
|
|
609
|
-
-
|
|
739
|
+
- See [docs/roadmap.md](./docs/roadmap.md) for what is planned; the pictures that prompted the layouts of 0.6.0 are listed in [docs/references.md](./docs/references.md).
|
|
610
740
|
|
|
611
741
|
## The name
|
|
612
742
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DrawOptions } from "./types.ts";
|
|
2
|
+
import type { Voice } from "./locales.ts";
|
|
3
|
+
/** The width of a text set in bold: the package's generous estimate. */
|
|
4
|
+
export declare const bold: (text: string, size: number) => number;
|
|
5
|
+
/** The height the title and the subtitle take, with the gap under them. */
|
|
6
|
+
export declare function titleHeight(o: DrawOptions): number;
|
|
7
|
+
/** The title and the subtitle, centred on the drawing. */
|
|
8
|
+
export declare function headingTexts(v: Voice, o: DrawOptions, width: number, pad: number): string[];
|
|
9
|
+
/** The big title tile over a half (`headers`): its group's name in the colour of the half, `width` wide at most, centred on `cx`, its text on the baseline `y`. */
|
|
10
|
+
export declare function headTile(text: string, cx: number, width: number, y: number, conf: 0 | 1, coloured: boolean): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { emWidth, esc, fit, num } from "./text.js";
|
|
2
|
+
/** The width of a text set in bold: the package's generous estimate. */
|
|
3
|
+
export const bold = (text, size) => emWidth(text) * size;
|
|
4
|
+
/** The height the title and the subtitle take, with the gap under them. */
|
|
5
|
+
export function titleHeight(o) {
|
|
6
|
+
const poster = o.theme === "poster";
|
|
7
|
+
return (o.title ? (poster ? 46 : 38) : 0) + (o.subtitle ? 24 : 0) + (o.title || o.subtitle ? 10 : 0);
|
|
8
|
+
}
|
|
9
|
+
/** The title and the subtitle, centred on the drawing. */
|
|
10
|
+
export function headingTexts(v, o, width, pad) {
|
|
11
|
+
const poster = o.theme === "poster";
|
|
12
|
+
const out = [];
|
|
13
|
+
let y = pad + 24;
|
|
14
|
+
if (o.title) {
|
|
15
|
+
const text = poster ? v.upper(o.title) : o.title;
|
|
16
|
+
out.push(`<text class="tb-title" x="${num(width / 2)}" y="${num(y)}" font-size="${poster ? 26 : 24}" font-weight="800" ${poster ? 'letter-spacing=".14em" ' : ""}text-anchor="middle">${esc(text)}</text>`);
|
|
17
|
+
y += poster ? 24 : 22;
|
|
18
|
+
}
|
|
19
|
+
if (o.subtitle)
|
|
20
|
+
out.push(`<text class="tb-sub" x="${num(width / 2)}" y="${num(y)}" font-size="14" text-anchor="middle">${esc(o.subtitle)}</text>`);
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
/** The big title tile over a half (`headers`): its group's name in the colour of the half, `width` wide at most, centred on `cx`, its text on the baseline `y`. */
|
|
24
|
+
export function headTile(text, cx, width, y, conf, coloured) {
|
|
25
|
+
const w = Math.min(Math.max(width, 140), 360);
|
|
26
|
+
const size = 15;
|
|
27
|
+
const shown = fit(text, size, w - 20, (t, sz) => bold(t, sz) * 1.06);
|
|
28
|
+
return `<rect class="tb-head${coloured ? ` tb-c${conf}` : ""}" x="${num(cx - w / 2)}" y="${num(y - 17)}" width="${num(w)}" height="26" rx="7"/><text class="tb-head-t" x="${num(cx)}" y="${num(y + 1.5)}" font-size="${size}" font-weight="800" letter-spacing=".08em" text-anchor="middle">${esc(shown)}</text>`;
|
|
29
|
+
}
|
package/dist/groups.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { BracketInput, BracketLayout, DrawOptions, Matchup, Size, Team } from "./types.ts";
|
|
2
|
+
import { type Voice } from "./locales.ts";
|
|
3
|
+
import { type MarkContext } from "./marks.ts";
|
|
4
|
+
/** One team's line of a group's table. */
|
|
5
|
+
export interface GroupRow {
|
|
6
|
+
team: Team;
|
|
7
|
+
played: number;
|
|
8
|
+
won: number;
|
|
9
|
+
drawn: number;
|
|
10
|
+
lost: number;
|
|
11
|
+
goalsFor: number;
|
|
12
|
+
goalsAgainst: number;
|
|
13
|
+
/** Goals for minus goals against. */
|
|
14
|
+
diff: number;
|
|
15
|
+
/** Three for a win, one for a draw. */
|
|
16
|
+
points: number;
|
|
17
|
+
}
|
|
18
|
+
/** One group: its name in the language and its teams, the best first. */
|
|
19
|
+
export interface GroupTable {
|
|
20
|
+
/** The group's key: the teams' `group`, or a letter made for a group the teams do not name. */
|
|
21
|
+
key: string;
|
|
22
|
+
/** "Group A" in the language, or the teams' own `group` where it is a name and not a letter. */
|
|
23
|
+
name: string;
|
|
24
|
+
rows: GroupRow[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The tables of the group stage: one for each group, from the round-robin games (`round: 0`) of the ties. A team's group is its `group`; teams with none take the group of the teams they
|
|
28
|
+
* played (the games make groups of the teams they join), and a group the teams do not name is lettered A, B, C. Rows are in order of points, then goal difference, then goals scored, then
|
|
29
|
+
* name (`standings: "record"` orders by wins, then fewest losses).
|
|
30
|
+
*/
|
|
31
|
+
export declare function groupStandings(input: BracketLayout | readonly Matchup[] | BracketInput, options?: Pick<DrawOptions, "locale" | "words" | "teamName" | "standings">): GroupTable[];
|
|
32
|
+
/** The table of the groups as HTML, for a reader the drawing does not serve: one `<table>` a group, its caption the group's name, a row a team. */
|
|
33
|
+
export declare function groupsTable(input: BracketLayout | readonly Matchup[] | BracketInput, options?: Pick<DrawOptions, "locale" | "words" | "teamName" | "standings"> & {
|
|
34
|
+
className?: string;
|
|
35
|
+
}): string;
|
|
36
|
+
/** What a layout that plans itself hands back to the frame. */
|
|
37
|
+
export interface OwnDrawing {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
/** The parts, in drawing order. */
|
|
41
|
+
body: string[];
|
|
42
|
+
/** The title and the subtitle. */
|
|
43
|
+
texts: string[];
|
|
44
|
+
/** The description for a screen reader, in place of the tree's. */
|
|
45
|
+
desc?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Draws the group tables as cards in a grid. */
|
|
48
|
+
export declare function drawGroups(layout: BracketLayout, o: DrawOptions, v: Voice, size: Size, ctx: MarkContext, road: boolean, linked: {
|
|
49
|
+
count: number;
|
|
50
|
+
}): OwnDrawing;
|