runloopable / web /src /shell /icons.tsx
fsanyoto's picture
Deploy AIOS web (React glide grid + FastAPI slice)
816fa8a verified
Raw History Blame Contribute Delete
7.6 kB
// ---------------------------------------------------------------------------
// shell/icons.tsx β€” THE SHELL'S GLYPH VOCABULARY, in one file.
//
// WHY THIS FILE EXISTS (wave 53, contract C4). The rail's marks were defined
// inline in `Shell.tsx`, and one of them β€” the database cylinder β€” was ALSO
// hand-copied into `ViewSidebar.tsx` and into the Home page. Three hands drawing
// one mark is how two rows that mean the same thing stop looking alike; the copy
// nobody edits is the one a reader sees. So the shell's glyphs live here, are
// imported by every shell surface, and are edited in exactly one place.
//
// S72-T05 (R111): sidebar rows draw from `@phosphor-icons/react` (outline
// `regular`, active `fill`), imported per icon in `Shell.tsx`. A glyph here is
// either one the library does not ship (`ArtifactsGlyph`, composed from its
// shapes) or a hand-drawn mark another surface still mounts (`AgentIcon`, Home).
//
// THE RULES for a hand-drawn glyph, and they are not style preferences:
// Β· ONE EXPORT PER GLYPH. No shared sub-components, no shared state, no
// parameterised "icon factory" β€” a second glyph must be addable by appending
// a function, without reading the one above it.
// Β· EACH EXPORT CARRIES THE WAVE AND TICKET THAT DREW IT in its own comment,
// so the next person changing a mark can find the instruction it answers
// before they overrule it.
// Β· 16x16 viewBox, stroke-only, round caps, vector paths β€” NEVER emoji
// (owner constant).
// Β· NO LOCAL PAINT. `.shell-nav-icon` in `index.css` owns `fill: none`,
// `stroke: currentColor` and the shared `stroke-width: 1.2`. A glyph that
// hardcodes any of those leaves the column the next time the rail's weight
// is retuned, and nothing goes red β€” it just drifts.
// β›” THAT LAST RULE HAS A TRAP THE FIRST GLYPH HERE ALREADY HIT. A CSS class
// rule BEATS an SVG presentation attribute, so `fill="currentColor"` on a
// shape inside `.shell-nav-icon` renders INVISIBLE: the class says
// `fill: none` and wins. A "solid" dot is therefore drawn as a SMALL STROKED
// CIRCLE whose own 1.2 stroke closes the hole, never as a filled one.
// A library glyph wears `shell-nav-icon is-glyph`, which paints fill.
//
// Guarded by `verify_icons.py` (gate `icons`), which reads the glyphs from THIS
// file and the mounts from `Shell.tsx`.
// ---------------------------------------------------------------------------
import { useId } from "react";
import type { IconWeight } from "@phosphor-icons/react";
import { Circle } from "@phosphor-icons/react/dist/csr/Circle";
import { Square } from "@phosphor-icons/react/dist/csr/Square";
import { Triangle } from "@phosphor-icons/react/dist/csr/Triangle";
/** ⭐⭐ WAVE 53 Β· T34 (owner instruction 4) β€” THE AGENTS ROW'S MARK: A SQUARE
* WITH TWO EYES. Owner, verbatim: *"Agent module icon is still ugly. How about
* just make it square and have two dots in side that looks like an eye."*
* S72-T05: the rail row now draws the library's `Robot`; Home's Agents cards
* still mount this mark.
*
* β›” IT REPLACES `FlowIcon`, THE TWO-NODE FLOW GLYPH WAVE 51 SHIPPED HERE β€” and
* `FlowIcon` had itself replaced a robot, which R15 deleted. NEITHER COMES
* BACK. The flow mark was the better ARGUMENT (an agent is a step, an edge, the
* next step) and it lost anyway, because at 16px three loose outlined shapes
* read as a diagram of nothing rather than as one thing. A face reads as one
* thing at any size, which is the whole of what a 16px rail mark has to do.
*
* ⚠ THE DOTS ARE STROKED CIRCLES, NOT FILLED ONES, AND THAT IS THE POINT OF
* FAILURE IF ANYONE "TIDIES" IT. `.shell-nav-icon` declares `fill: none`, and a
* class rule outranks a presentation attribute, so `fill="currentColor"` here
* paints NOTHING and the square renders empty. At r=0.95 under the class's own
* 1.2 stroke the remaining hole is 0.7 units wide, which closes into a solid dot
* at 16px while keeping the glyph's paint entirely delegated the way every
* sibling mark's is. An inline style would also work and is the wrong trade: it
* would be the one mark in the rail that does not follow the class.
* ⚠ THE RADIUS AND THE SPACING ARE A PAIR, MEASURED ON THE SHOT, not tuned
* independently. Under a 1.2 stroke r=0.95 draws a 3.1-wide dot, so the centres
* are 4.6 apart to leave 1.5 of clear ground between them: closer and the two
* dots blur into one bar at 16px, which is a squint, not a pair of eyes.
*
* Geometry: the square sits on the 2.4 to 13.6 box the old Sheet mark used, with
* a wider corner radius so it reads as a head rather than as another sheet. The
* eyes sit a touch above the box centre, which is where a face carries them;
* dead-centre reads as a colon. */
export function AgentIcon() {
return (
<svg className="shell-nav-icon" viewBox="0 0 16 16" aria-hidden="true">
<rect x="2.4" y="2.4" width="11.2" height="11.2" rx="2.7" />
<circle cx="5.7" cy="7.8" r="0.95" />
<circle cx="10.3" cy="7.8" r="0.95" />
</svg>
);
}
/* β›” `DatabaseIcon` (W53-T35) LIVED HERE AND IS DELETED: the Data row draws the library's
`Database` since S72-T05 and nothing else mounted it. Home and the View rail keep
`iconShapes.ts::DATABASE_SHAPE_PATHS`. */
/** Where each library shape sits inside the 256-unit box, at 184 units (0.72 scale). Measured on
* 1x and 2x shots: circle back left, triangle back right, square in front below. */
const SHAPE_BOX = 184;
const CIRCLE_AT = { x: -16, y: -14 };
const TRIANGLE_AT = { x: 84, y: -16 };
const SQUARE_AT = { x: 44, y: 84 };
/** Mask stroke around a front shape, in glyph units: the gap that keeps two filled shapes apart. */
const HALO = 32;
/** S72-T05 (instruction 21, R111) β€” the Artifacts row: a triangle, a square and a circle that
* overlap, composed from the library's own `Triangle`, `Square` and `Circle`.
* Phosphor's `Shapes` draws the three apart, which is why this is composed.
* ⚠ The outline state draws the `bold` weight: at 0.72 scale it lands on `regular`'s 1px line.
* ⚠ Masks cut each back shape around the ones in front, so the filled state stays three shapes. */
export function ArtifactsGlyph({ weight, className }: { weight: IconWeight; className?: string }) {
const id = useId().replace(/[^A-Za-z0-9_-]/g, "");
const drawn: IconWeight = weight === "fill" ? "fill" : "bold";
const cut = { weight: "fill" as const, color: "black", stroke: "black", strokeWidth: HALO,
strokeLinejoin: "round" as const, size: SHAPE_BOX };
return (
<svg className={className} width={16} height={16} viewBox="0 0 256 256" fill="currentColor"
aria-hidden="true">
<defs>
<mask id={`${id}-circle`} maskUnits="userSpaceOnUse" x="0" y="0" width="256" height="256">
<rect width="256" height="256" fill="white" />
<Triangle {...cut} {...TRIANGLE_AT} />
<Square {...cut} {...SQUARE_AT} />
</mask>
<mask id={`${id}-triangle`} maskUnits="userSpaceOnUse" x="0" y="0" width="256" height="256">
<rect width="256" height="256" fill="white" />
<Square {...cut} {...SQUARE_AT} />
</mask>
</defs>
<g mask={`url(#${id}-circle)`}>
<Circle weight={drawn} size={SHAPE_BOX} {...CIRCLE_AT} />
</g>
<g mask={`url(#${id}-triangle)`}>
<Triangle weight={drawn} size={SHAPE_BOX} {...TRIANGLE_AT} />
</g>
<Square weight={drawn} size={SHAPE_BOX} {...SQUARE_AT} />
</svg>
);
}