Download web/src/sheet/refColors.ts from fsanyoto/loopable: direct link, hf CLI and curl.
- Browser
- Download file 2.03 kB
-
https://huggingface.co/spaces/fsanyoto/loopable/resolve/9291c0100f4e7b8da2efcbbf1ebdea72ee1663e7/web/src/sheet/refColors.ts
- Command line
-
hf download hf://spaces/fsanyoto/loopable@9291c0100f4e7b8da2efcbbf1ebdea72ee1663e7/web/src/sheet/refColors.ts
-
curl -L -o refColors.ts https://huggingface.co/spaces/fsanyoto/loopable/resolve/9291c0100f4e7b8da2efcbbf1ebdea72ee1663e7/web/src/sheet/refColors.ts
2.03 kB
| // The fixed six colour reference rotation, wave 52 (W52-T05, contract C3, instruction 7, rule CR-4). | |
| // | |
| // `AutoWiki/waves/wave52/proto/excel-behaviour-spec.md` CR-4: Excel's own reference-colouring | |
| // palette is NOT documented anywhere sourceable. Rather than guess at it, the spec FIXES this | |
| // app's own six colour rotation and a lane must use exactly these, in exactly this order, cycling | |
| // after the sixth. `formulaAssist.ts::refsIn` assigns SLOT INDEXES (0-5); this file is the only | |
| // place that turns a slot index into a hex colour, so the formula text and the grid outline always | |
| // agree (CR-1, "so a reference and its cell always agree" per the ticket brief). | |
| // | |
| // PURE data and pure functions only. No React, no DOM. | |
| export interface RefColorSlot { | |
| name: string; | |
| light: string; | |
| dark: string; | |
| } | |
| /** CR-4's table, verbatim, in rotation order. Never reorder; never add or remove a slot. */ | |
| export const REF_COLORS: readonly RefColorSlot[] = [ | |
| { name: "Blue", light: "#1B6AC9", dark: "#5CA8F0" }, | |
| { name: "Red", light: "#C0392B", dark: "#F07167" }, | |
| { name: "Purple", light: "#7A4DBF", dark: "#B18CE6" }, | |
| { name: "Green", light: "#1E8449", dark: "#4FBF7F" }, | |
| { name: "Orange", light: "#C87A00", dark: "#E8A33D" }, | |
| { name: "Teal", light: "#0F7B7B", dark: "#3FB8B8" }, | |
| ]; | |
| export const REF_COLOR_COUNT = REF_COLORS.length; | |
| /** Any slot index (including >= 6, including negative) wraps into the six slot rotation. */ | |
| function slotIndex(slot: number): number { | |
| const n = REF_COLOR_COUNT; | |
| return ((slot % n) + n) % n; | |
| } | |
| /** The hex for one slot, in the given theme. Wraps after the sixth slot (CR-4's "cycling"). */ | |
| export function colorForSlot(slot: number, theme: "light" | "dark" = "light"): string { | |
| const entry = REF_COLORS[slotIndex(slot)]; | |
| return theme === "dark" ? entry.dark : entry.light; | |
| } | |
| /** The slot's display name (for an aria label or a legend), independent of theme. CR-7. */ | |
| export function nameForSlot(slot: number): string { | |
| return REF_COLORS[slotIndex(slot)].name; | |
| } | |