@kolkrabbi/kol-component 0.382.0 → 0.384.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.
@@ -1,61 +0,0 @@
1
- import { useEffect, useState } from 'react'
2
- import { KeylineGuide } from '../atoms/IconPlate.jsx'
3
-
4
- /* What LogoSystem and LogoTuner share (from apps/tuner, W27.4 2026-11-19): the board, the keylines on it, the labels,
5
- * the ground the keylines are drawn on. The board is the Line Swell canvas's 1200 x 800 frame with its origin at the
6
- * centre; it scales to its box and keeps its ratio. Its inks are `.kol-logo-*` rules in kol-components-organisms.css. */
7
-
8
- /* which ground the keylines sit on: the page's data-theme, followed on a flip */
9
- export function useLight() {
10
- const read = () => document.documentElement.dataset.theme === 'light'
11
- const [light, setLight] = useState(read)
12
- useEffect(() => {
13
- const o = new MutationObserver(() => setLight(read()))
14
- o.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })
15
- return () => o.disconnect()
16
- }, [])
17
- return light
18
- }
19
-
20
- /* the 24-unit keylines from KeylineGuide, laid on the board at `box` around (ox, oy) */
21
- export function Keylines({ box, ox = 0, oy = 0, light }) {
22
- return (
23
- <foreignObject x={ox - box / 2} y={oy - box / 2} width={box} height={box} pointerEvents="none">
24
- <div style={{ position: 'relative', width: '100%', height: '100%' }}><KeylineGuide light={light} /></div>
25
- </foreignObject>
26
- )
27
- }
28
-
29
- /* the canvas's palettes (line-swell.js PALETTES), ink then ground; `custom` takes the settings' own ink and ground */
30
- const PALETTES = {
31
- 'ink on paper': ['#111111', '#f4f4f4'], 'paper on ink': ['#ffffff', '#000000'], 'white on blue': ['#ffffff', '#0a1fff'],
32
- 'blue on paper': ['#0a1fff', '#f1f1f1'], 'red on ink': ['#e5303f', '#111111'], 'light on grey': ['#fafafa', '#35363a'],
33
- }
34
- /* the board's own inks when the settings carry a palette (as the canvas boards draw), else null: the theme's inks.
35
- `light` says which keylines suit the ground (the engine's keylines rule: luminance over 128) */
36
- export function inksOf(p) {
37
- if (!p?.palette) return null
38
- const pal = PALETTES[p.palette] ?? PALETTES['ink on paper'], custom = p.palette === 'custom'
39
- const ink = custom ? (p.ink || pal[0]) : pal[0], ground = custom ? (p.ground || pal[1]) : pal[1]
40
- const g = String(ground).replace('#', ''), lum = g.length === 6 ? parseInt(g.slice(0, 2), 16) * 0.299 + parseInt(g.slice(2, 4), 16) * 0.587 + parseInt(g.slice(4, 6), 16) * 0.114 : 255
41
- return { ink, ground, light: lum > 128 }
42
- }
43
-
44
- /* the board: the 1200 x 800 frame, centred and scaled to fit; `svgRef` reads pointer positions in board units.
45
- `inks` (inksOf): the ground behind the board and the ink of its form, lines and labels; the grey form is the
46
- canvas's #b3b3b3 there */
47
- export function Board({ svgRef, label, inks = null, children }) {
48
- return (
49
- <svg ref={svgRef} viewBox="0 0 1200 800" preserveAspectRatio="xMidYMid meet" role="img" aria-label={label}
50
- style={inks ? { '--kol-logo-ink': inks.ink, '--kol-logo-ground': inks.ground } : undefined}
51
- className={`kol-logo-board block h-full w-full touch-none select-none${inks ? ' is-inked' : ''}`}>
52
- <g transform="translate(600 400)">{children}</g>
53
- </svg>
54
- )
55
- }
56
-
57
- /* labels the engine places on the board, as text in board units so they scale with it; the canvas laid them as 15/16
58
- * HTML with its top 13 above the point, so the baseline lands 1 above it */
59
- export function Labels({ list }) {
60
- return list.map((l, i) => <text key={i} x={l.x} y={l.y - 1} className="kol-logo-label" pointerEvents="none" xmlSpace="preserve">{l.t}</text>)
61
- }