import { type Background } from "./background.ts"; import type { MarkShape } from "./layers.types.ts"; import type { Language, ScoreOptions, SurfaceOptions } from "./types.ts"; /** The sizes a grid is made for: a social card, a square post and a phone's width. */ export type GridPreset = "card" | "square" | "phone"; /** What a preset fixes: the size in pixels (a height of `undefined` is whatever the drawings need), the columns, and whether the page has a ground of its own. */ export interface GridPresetInfo { readonly width: number; readonly height: number | undefined; readonly columns: number | undefined; /** The ground behind the grid when `background` says nothing: a solid one for a picture that will be posted, none for a phone's page. */ readonly ground: boolean; readonly about: string; } /** * The presets of `drawGrid`: `card` is 1200 by 675 (the 16:9 card that social sites show for a link), `square` is 1080 by 1080, and `phone` is 390 wide in one column with * the height the drawings need. A `width`, a `height` or `columns` in the options wins over the preset's. */ export declare const GRID_PRESETS: Readonly>; /** One mark of the key: what it means, in what colour and shape. */ export interface GridLegendItem { /** What the mark means. */ label: string; /** The mark's colour (`safeColour`); the layers' own when missing. */ color?: string; /** The mark's shape. A circle by default. */ shape?: MarkShape; /** Drawn open, as a miss or a save is. */ hollow?: boolean; } /** What a cell holds: the options of `drawKyogijo`, a drawing's SVG, or a chart (anything with a `draw()` that returns an SVG). */ export type GridDrawing = string | SurfaceOptions | ScoreOptions | { draw(): string; }; /** A drawing and the caption written over it. A cell may also be the drawing alone. */ export interface GridCell { drawing: GridDrawing; /** A caption over the drawing (one line, made smaller to fit). The drawing keeps its own title and description for a screen reader. */ label?: string; } /** What `drawGrid` takes. */ export interface GridOptions { /** A size to fit: `card`, `square` or `phone` (see `GRID_PRESETS`). */ preset?: GridPreset; /** The drawings in a row. By default the number that makes the drawings largest in a fixed size, else as many as fit with a cell at least 280 wide. */ columns?: number; /** The space between cells, in the grid's units. About a sixtieth of the width by default. */ gap?: number; /** The width of the picture. The preset's, else 960. */ width?: number; /** The height of the picture. The preset's; without one, the drawings decide. */ height?: number; /** The title, set at the top. It is also the group's accessible title. */ title?: string; /** The line under the title. */ subtitle?: string; /** The line at the foot: a credit, a source, a date. */ endnote?: string; /** The key the drawings share, set under the title. */ legend?: readonly GridLegendItem[]; /** The ground behind everything: a pattern, a colour, a photograph. See `BackgroundOptions`. `card` and `square` have a plain one unless it is `"none"`. */ background?: Background; /** The language of the grid's own words: its accessible title and description. Drawings given as options take it too, unless they have their own. */ language?: Language; /** Force light or dark on the grid and on every drawing in it. Without it the grid follows the device and the page, like a drawing does. */ theme?: "light" | "dark"; /** A prefix for the ids in the picture. Made from the grid when missing. */ id?: string; /** The group's accessible title in place of `title`, for a grid whose visible title says too little. */ label?: string; /** The group's description, in place of the one made from the drawings' titles. */ description?: string; /** A class for the root, as in `drawKyogijo`. */ className?: string; /** `none` leaves the stylesheet to the page (`KYOGIJO_STYLE` has every rule). */ style?: "embed" | "none"; } /** The most drawings a grid takes. */ export declare const GRID_MAX_CELLS = 200; /** * Many drawings in one SVG, as small multiples: one per park, per period or per player, in columns, under a title and a subtitle and over a credit line, with a key they share. * A cell is the options of `drawKyogijo`, a drawing's SVG, a chart, or `{ drawing, label }`. Every drawing keeps its own title and description for a screen reader, with ids * of its own, so that the same drawing may appear twice; the group has a title and a description made from them. Each is drawn at the largest size its cell allows, the * last row centred. `preset` fits a social card (`card`, 1200 by 675; `square`, 1080 by 1080) or a phone (`phone`, 390 wide in one column); without a size the grid is 960 * wide and as tall as the drawings need. The scene and every renderer read it like any other drawing. The same cells and options always give the same string. * @example * ```ts * import { drawGrid } from "@johnmorrisdotca/kyogijo-stadiums/layouts"; * const svg = drawGrid( * [{ drawing: { sport: "nhl" }, label: "Rink" }, { drawing: { sport: "nba" }, label: "Court" }], * { columns: 2, title: "Two surfaces", endnote: "Drawn by Kyogijo" }, * ); * console.log(svg.startsWith("