@johnmorrisdotca/dougu-sports 0.4.0 → 0.4.1
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 +10 -1
- package/dist/emblems/ball/ball.core.d.ts +4 -1
- package/dist/emblems/ball/ball.core.js +1 -1
- package/dist/emblems/ball/ball.face.d.ts +14 -9
- package/dist/emblems/ball/ball.face.js +6 -5
- package/dist/emblems/ball/ball.puck.print.js +1 -1
- package/dist/emblems/emblem.core.d.ts +4 -2
- package/dist/emblems-entry.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ All notable changes to this project are written here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.1] - 2026-10-14
|
|
10
|
+
|
|
11
|
+
The printed pucks take the same flag renderer as taisen-brackets.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **The puck's flag renderer is the one taisen-brackets takes.** `flags` is now an option of the call (`renderEmblem`, `emblemFrame`, `ballFrame`), beside `face`, and no longer a field of `face`; it is called `flags(code, { shape: "round" | "square" | "rect", size, theme: "inherit" | "light" | "dark" })` (the puck asks for `"rect"`), may return `null` or `undefined` for a code it has no flag for, and is synchronous, so one adapter over hata serves every package. New types `FlagRequest` and `FlagShape`. `FlagRenderer` changed accordingly; the 0.4.0 form (`face.flags`, shapes `4:3`/`1:1`/`round`) is gone.
|
|
16
|
+
|
|
9
17
|
## [0.4.0] - 2026-10-14
|
|
10
18
|
|
|
11
19
|
Printed pucks: eight souvenir pucks with a print on the top face that turns with the puck, and a `face` option that takes any picture, emblem or flag code. 194 emblems.
|
|
@@ -132,7 +140,8 @@ First preview: the name, the API and two sample emblems. The full set of trophie
|
|
|
132
140
|
- Tests for the drawing, the ids, the turns and the bundle size of one item; a package check that installs the packed tarball and bundles one item from it.
|
|
133
141
|
- The demo (a playground with a turn slider, and a gallery page), `docs/layout.md`, `docs/turning.md`, `docs/gallery.md`, the family header and footer, the CI, Pages and Release workflows, and `LICENSES/` and `NOTICE.md` ready for third-party art.
|
|
134
142
|
|
|
135
|
-
[Unreleased]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.4.
|
|
143
|
+
[Unreleased]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.4.1...HEAD
|
|
144
|
+
[0.4.1]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.4.0...v0.4.1
|
|
136
145
|
[0.4.0]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.3.2...v0.4.0
|
|
137
146
|
[0.3.2]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.3.1...v0.3.2
|
|
138
147
|
[0.3.1]: https://github.com/johnmorrisdotca/dougu-sports/compare/v0.3.0...v0.3.1
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PuckFace } from "./ball.face.ts";
|
|
1
|
+
import type { FlagRenderer, PuckFace } from "./ball.face.ts";
|
|
2
2
|
/** `metal` (also written `colour`): full colour, with shading. `line`: one outline in `currentColor`. */
|
|
3
3
|
export type PieceStyle = "metal" | "colour" | "color" | "line";
|
|
4
4
|
/** `inherit` (the default): the page's text colour. `auto`: dark ink on a light device and pale ink on a dark one. `light` and `dark` force one. */
|
|
@@ -21,6 +21,8 @@ export interface PieceOptions {
|
|
|
21
21
|
title?: string | false;
|
|
22
22
|
/** A puck: the print on its top face (see `PuckFace`). The printed pucks (`puck:*`) take it, and so does `ball:puck` through `renderEmblem`, `emblemFrame` and `ballFrame`. Anything else ignores it. */
|
|
23
23
|
face?: PuckFace;
|
|
24
|
+
/** A puck: a renderer for the flag codes this package does not draw (`face.flag`), `(code, { shape, size, theme }) => svg`, the one taisen-brackets takes. Synchronous. */
|
|
25
|
+
flags?: FlagRenderer;
|
|
24
26
|
}
|
|
25
27
|
/** A turn: `yaw` degrees about the vertical axis (0 is the default view), `pitch` the tilt toward you, `roll` the turn about the line of sight. */
|
|
26
28
|
export interface BallFrameOptions extends PieceOptions {
|
|
@@ -89,6 +91,7 @@ export interface ResolvedOptions {
|
|
|
89
91
|
accent: string | undefined;
|
|
90
92
|
grain: boolean | undefined;
|
|
91
93
|
face: PuckFace | undefined;
|
|
94
|
+
flags: FlagRenderer | undefined;
|
|
92
95
|
/** A string that tells two faces apart, for the ids of a drawing. */
|
|
93
96
|
faceKey: string;
|
|
94
97
|
}
|
|
@@ -58,7 +58,7 @@ export function resolveOptions(o) {
|
|
|
58
58
|
const theme = o?.theme === "auto" || o?.theme === "light" || o?.theme === "dark" ? o.theme : "inherit";
|
|
59
59
|
const tint = readColour(o?.tint);
|
|
60
60
|
const accent = readColour(o?.accent);
|
|
61
|
-
return { style: o?.style === "line" ? "line" : "colour", size, theme, tint: tint === undefined ? undefined : hexOf(tint), accent: accent === undefined ? undefined : hexOf(accent), grain: typeof o?.grain === "boolean" ? o.grain : undefined, face: typeof o?.face === "object" && o.face !== null ? o.face : undefined, faceKey: faceKeyOf(o?.face) };
|
|
61
|
+
return { style: o?.style === "line" ? "line" : "colour", size, theme, tint: tint === undefined ? undefined : hexOf(tint), accent: accent === undefined ? undefined : hexOf(accent), grain: typeof o?.grain === "boolean" ? o.grain : undefined, face: typeof o?.face === "object" && o.face !== null ? o.face : undefined, flags: typeof o?.flags === "function" ? o.flags : undefined, faceKey: faceKeyOf(o?.face) + (typeof o?.flags === "function" ? `|fn:${o.flags.name}` : "") };
|
|
62
62
|
}
|
|
63
63
|
/** The ink of a drawing when a theme sets it, and the page it is made to read on. */
|
|
64
64
|
export const PIECE_INK = { light: "#20262d", dark: "#eef1f3" };
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/** The designs a face starts from. */
|
|
2
2
|
export type PuckDesign = "canada" | "canada-red" | "canada-white" | "usa" | "usa-navy" | "player" | "souvenir";
|
|
3
|
-
/**
|
|
4
|
-
export type
|
|
5
|
-
|
|
3
|
+
/** How a flag is framed: `round` in a circle, `square`, or `rect` in its own proportions (the puck asks for `rect`). */
|
|
4
|
+
export type FlagShape = "round" | "square" | "rect";
|
|
5
|
+
/** What a drawing asks a `flags` renderer for: the shape, a width and height in pixels, and the look (`inherit` for a page whose ink is its own). */
|
|
6
|
+
export interface FlagRequest {
|
|
7
|
+
shape: FlagShape;
|
|
6
8
|
size: number;
|
|
7
|
-
theme: "
|
|
8
|
-
}
|
|
9
|
+
theme: "inherit" | "light" | "dark";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 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: the same renderer taisen-brackets and kyogijo take, so one adapter over hata serves them
|
|
13
|
+
* all. It must be synchronous (a drawing is a pure function of its options): hata's `flag()` is asynchronous, so load the flags first and pass `(code) => loaded[code]`. Pass it as the `flags` option of the call.
|
|
14
|
+
*/
|
|
15
|
+
export type FlagRenderer = (code: string, request: FlagRequest) => string | null | undefined;
|
|
9
16
|
/** The colours of a face, by name. The array form is the same list in this order: field, ring, ink, accent, signature. */
|
|
10
17
|
export interface FaceColors {
|
|
11
18
|
/** The disc's own colour. */
|
|
@@ -28,10 +35,8 @@ export interface PuckFace {
|
|
|
28
35
|
design?: PuckDesign;
|
|
29
36
|
/** Any SVG: a logo, a crest, a drawing. Made safe first (see `safeImage`): shapes, gradients and clip paths only. It is fitted into the middle of the face and replaces the design's own picture. */
|
|
30
37
|
image?: string;
|
|
31
|
-
/** A country code (`"ca"` and `"us"` are drawn by this package; another needs `flags`). It replaces the design's own picture. */
|
|
38
|
+
/** A country code (`"ca"` and `"us"` are drawn by this package; another needs the `flags` option of the call). It replaces the design's own picture. */
|
|
32
39
|
flag?: string;
|
|
33
|
-
/** A renderer for the flag codes this package does not draw: `(code, { shape, size, theme }) => svg`, the shape of the function hata exports. */
|
|
34
|
-
flags?: FlagRenderer;
|
|
35
40
|
/** The id of a dougu emblem (`"trophy:cup"`, `"sport:nhl"`), drawn small in the middle. Resolved by `renderEmblem`, `emblemFrame` and `ballFrame`. */
|
|
36
41
|
emblem?: string;
|
|
37
42
|
/** The words under the picture (`"CANADA"`), one line. */
|
|
@@ -48,7 +53,7 @@ export interface PuckFace {
|
|
|
48
53
|
colors?: FaceColors | readonly (string | undefined)[];
|
|
49
54
|
}
|
|
50
55
|
/** The face of a design, in the face's units (a disc of radius 1, up is up): its definitions and its drawing. `prefix` makes every id unique to this puck. */
|
|
51
|
-
export declare function faceMarkup(face: PuckFace | undefined, design: PuckDesign, own: PuckFace | undefined, prefix: string): {
|
|
56
|
+
export declare function faceMarkup(face: PuckFace | undefined, design: PuckDesign, own: PuckFace | undefined, prefix: string, flags?: FlagRenderer, theme?: FlagRequest["theme"]): {
|
|
52
57
|
defs: string;
|
|
53
58
|
body: string;
|
|
54
59
|
};
|
|
@@ -38,7 +38,7 @@ const colourOf = (value) => {
|
|
|
38
38
|
};
|
|
39
39
|
const DESIGNS = Object.keys(LOOKS);
|
|
40
40
|
/** The face, ready to draw: the design's words and colours under the caller's. `base` is the design a puck's own id starts from. */
|
|
41
|
-
function resolve(face, base, own) {
|
|
41
|
+
function resolve(face, base, own, flags, theme) {
|
|
42
42
|
const f = typeof face === "object" && face !== null ? face : {};
|
|
43
43
|
const design = (typeof f.design === "string" && DESIGNS.includes(f.design) ? f.design : own?.design ?? base);
|
|
44
44
|
const words = { ...WORDS[design], ...own, ...definedOnly(f) };
|
|
@@ -60,7 +60,8 @@ function resolve(face, base, own) {
|
|
|
60
60
|
look,
|
|
61
61
|
image: typeof words.image === "string" ? words.image : undefined,
|
|
62
62
|
flag: typeof words.flag === "string" ? words.flag.trim().toLowerCase().slice(0, 12) : undefined,
|
|
63
|
-
flags
|
|
63
|
+
flags,
|
|
64
|
+
theme,
|
|
64
65
|
text: cleanText(words.text),
|
|
65
66
|
ring,
|
|
66
67
|
number: number === "" ? undefined : number,
|
|
@@ -112,7 +113,7 @@ function picture(f, prefix, cx, cy, w, h) {
|
|
|
112
113
|
if (f.flags !== undefined) {
|
|
113
114
|
let svg;
|
|
114
115
|
try {
|
|
115
|
-
svg = f.flags(code, { shape: "
|
|
116
|
+
svg = f.flags(code, { shape: "rect", size: 120, theme: f.theme });
|
|
116
117
|
}
|
|
117
118
|
catch {
|
|
118
119
|
svg = undefined;
|
|
@@ -182,8 +183,8 @@ function leaf(cx, cy, w, fill) {
|
|
|
182
183
|
return `<path d="${LEAF_PATH}" transform="translate(${num(cx, 3)} ${num(cy, 3)}) scale(${num(w / 2, 4)})" fill="${fill}"/>`;
|
|
183
184
|
}
|
|
184
185
|
/** The face of a design, in the face's units (a disc of radius 1, up is up): its definitions and its drawing. `prefix` makes every id unique to this puck. */
|
|
185
|
-
export function faceMarkup(face, design, own, prefix) {
|
|
186
|
-
const f = resolve(face, design, own);
|
|
186
|
+
export function faceMarkup(face, design, own, prefix, flags, theme = "inherit") {
|
|
187
|
+
const f = resolve(face, design, own, typeof flags === "function" ? flags : undefined, theme);
|
|
187
188
|
const look = f.look;
|
|
188
189
|
const clip = `${prefix}clip`;
|
|
189
190
|
let defs = `<clipPath id="${clip}"><circle r=".965"/></clipPath>`;
|
|
@@ -24,7 +24,7 @@ function definePuck(def) {
|
|
|
24
24
|
// The top face's plane in the box: its centre, and where a step of 1 along the puck's x and z axes goes (the face's right, and its down).
|
|
25
25
|
const o = cx.at([0, PUCK_H, 0]), ex = cx.at([1, PUCK_H, 0]), ez = cx.at([0, PUCK_H, 1]);
|
|
26
26
|
const m = [ex[0] - o[0], ex[1] - o[1], ez[0] - o[0], ez[1] - o[1], o[0], o[1]].map((v) => num(v, 4)).join(" ");
|
|
27
|
-
const face = faceMarkup(cx.opts.face, def.design, def.own, `${cx.id}p
|
|
27
|
+
const face = faceMarkup(cx.opts.face, def.design, def.own, `${cx.id}p`, cx.opts.flags, cx.opts.theme === "light" || cx.opts.theme === "dark" ? cx.opts.theme : "inherit");
|
|
28
28
|
// A light from the upper left and a falling-off at the far edge, over the print, in the box's own space so the light stays put while the puck turns.
|
|
29
29
|
const gid = `${cx.id}fl`;
|
|
30
30
|
const defs = `${face.defs}<radialGradient id="${gid}" cx=".36" cy=".3" r=".85"><stop offset="0" stop-color="#fff" stop-opacity=".34"/><stop offset=".4" stop-color="#fff" stop-opacity="0"/><stop offset="1" stop-color="#000" stop-opacity=".42"/></radialGradient>`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PuckFace } from "./ball/ball.face.ts";
|
|
1
|
+
import type { FlagRenderer, PuckFace } from "./ball/ball.face.ts";
|
|
2
2
|
/** `metal`: full colour with a gradient. `line`: one outline in `currentColor`. `color`: flat fills of the main colour, with no gradient. */
|
|
3
3
|
export type EmblemStyle = "metal" | "line" | "color";
|
|
4
4
|
export declare const EMBLEM_STYLES: readonly ["metal", "line", "color"];
|
|
@@ -53,9 +53,11 @@ export interface EmblemOptions {
|
|
|
53
53
|
turnBox?: boolean;
|
|
54
54
|
/**
|
|
55
55
|
* The print on the top face of a puck: the printed pucks (`puck:*`) start from a face of their own and this replaces any part of it, and `ball:puck` given a face is drawn as `puck:souvenir` with it. `image` takes any SVG
|
|
56
|
-
* (made safe first), `emblem` a dougu id, `flag` a country code (`ca` and `us` are drawn here; another needs `flags
|
|
56
|
+
* (made safe first), `emblem` a dougu id, `flag` a country code (`ca` and `us` are drawn here; another needs the `flags` option, a renderer like hata's). See `PuckFace`. Anything that is not a puck ignores it.
|
|
57
57
|
*/
|
|
58
58
|
face?: PuckFace;
|
|
59
|
+
/** A puck: a renderer for the flag codes this package does not draw (`face.flag`): `(code, { shape: "round" | "square" | "rect", size, theme }) => svg`, synchronous, the same as taisen-brackets takes (hata's `flag()` is asynchronous, so load the flags first). */
|
|
60
|
+
flags?: FlagRenderer;
|
|
59
61
|
}
|
|
60
62
|
/** A turn, in degrees from the resting view (0 and 0 is the still drawing): `yaw` about the vertical axis, `pitch` the tilt toward the eye. */
|
|
61
63
|
export interface FrameOptions extends EmblemOptions {
|
package/dist/emblems-entry.d.ts
CHANGED
|
@@ -19,4 +19,4 @@ export { sportEquipment } from "./emblems/emblem.equipment.ts";
|
|
|
19
19
|
export type { SportEquipment } from "./emblems/emblem.equipment.ts";
|
|
20
20
|
export { awardCase, podium } from "./emblems/emblem.display.ts";
|
|
21
21
|
export type { AwardCaseOptions, AwardItem, DisplayOptions, PodiumOptions, PodiumPlace } from "./emblems/emblem.display.ts";
|
|
22
|
-
export type { FaceColors, FlagRenderer, PuckDesign, PuckFace } from "./emblems/ball/ball.face.ts";
|
|
22
|
+
export type { FaceColors, FlagRenderer, FlagRequest, FlagShape, PuckDesign, PuckFace } from "./emblems/ball/ball.face.ts";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.4.
|
|
1
|
+
export declare const VERSION = "0.4.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.4.
|
|
1
|
+
export const VERSION = "0.4.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/dougu-sports",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Dougu Sports 道具, sports emblems as SVG strings: trophies, medals, crests, sport icons, and the ball and gear of every sport, in metal, line or flat colour, with optional 3D turning. Light and dark, accessible, tree-shakeable. Zero dependencies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sports",
|