SPB Git

Repository Public

icons.tsx 7.3 KB 76 lines tsx

1import type { ReactNode } from "react";2import type { Icon } from "@/schema";34/**5 * The fixed icon set: original glyphs on a 24×24 grid, 1.75 stroke, round caps and joins, no fill.6 * Exhaustive: adding an icon to ICONS in the schema without drawing it here is a type error.7 */8const P = ({ d }: { d: string }) => <path d={d} />;9const RING = <circle cx="12" cy="12" r="8.5" />;1011export const ICON_GLYPHS: Record<Icon, ReactNode> = {12  brain: <><P d="M12 6.5A3 3 0 0 0 6.6 5 3 3 0 0 0 4.5 9.6a3.2 3.2 0 0 0 .4 5.2A3 3 0 0 0 8 18.9a2.6 2.6 0 0 0 4-2.2V6.5Z" /><P d="M12 6.5A3 3 0 0 1 17.4 5a3 3 0 0 1 2.1 4.6 3.2 3.2 0 0 1-.4 5.2 3 3 0 0 1-3.1 4.1 2.6 2.6 0 0 1-4-2.2" /><P d="M8.2 11.5H10M15.8 13.5H14" /></>,13  layers: <><P d="M12 3 3 8l9 5 9-5-9-5Z" /><P d="m3 12 9 5 9-5" /><P d="m3 16 9 5 9-5" /></>,14  route: <><circle cx="5" cy="18" r="2" /><circle cx="19" cy="4.5" r="2" /><P d="M7 18h8.5a3.4 3.4 0 0 0 0-6.8h-7a3.35 3.35 0 0 1 0-6.7H17" /></>,15  database: <><ellipse cx="12" cy="6" rx="7" ry="3" /><P d="M5 6v12c0 1.7 3.1 3 7 3s7-1.3 7-3V6" /><P d="M5 12c0 1.7 3.1 3 7 3s7-1.3 7-3" /></>,16  server: <><rect x="4" y="4" width="16" height="7" rx="2" /><rect x="4" y="13" width="16" height="7" rx="2" /><P d="M7.8 7.5h.01M7.8 16.5h.01M12 7.5h4.5M12 16.5h4.5" /></>,17  cpu: <><rect x="7" y="7" width="10" height="10" rx="1.5" /><P d="M10 3v4M14 3v4M10 17v4M14 17v4M3 10h4M3 14h4M17 10h4M17 14h4" /><rect x="10.2" y="10.2" width="3.6" height="3.6" rx=".6" /></>,18  cloud: <P d="M7 18.5a4.2 4.2 0 0 1-.7-8.35A5.6 5.6 0 0 1 17.1 9.6a4.5 4.5 0 0 1 .4 8.9H7Z" />,19  network: <><circle cx="12" cy="5" r="2" /><circle cx="5" cy="18.5" r="2" /><circle cx="19" cy="18.5" r="2" /><P d="M12 7v4.5M12 11.5l-5.6 5.4M12 11.5l5.6 5.4" /></>,20  search: <><circle cx="11" cy="11" r="6.2" /><P d="m20 20-4.5-4.5" /></>,21  filter: <P d="M4 5h16l-6 7.5V19l-4-2v-4.5L4 5Z" />,22  document: <><P d="M6.5 3H14l4.5 4.5V20a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z" /><P d="M14 3v4.5h4.5M9 12.5h6M9 16h6" /></>,23  code: <P d="m8.5 7-5 5 5 5M15.5 7l5 5-5 5M13.5 5l-3 14" />,24  chart: <><P d="M4 4v16h16" /><P d="M8.5 16v-4M12.5 16V8M16.5 16v-6" /></>,25  trend: <><P d="m3 17 6-6 4 4 8-8" /><P d="M15 7h6v6" /></>,26  sigma: <P d="M18 6.5V4H6l7 8-7 8h12v-2.5" />,27  function: <><P d="M13.5 4.6c-2-.6-3.2.5-3.5 2.6L8.6 17c-.3 2.1-1.5 3.1-3.4 2.4" /><P d="M6.5 10.5h6.5M15.5 13.5l4.5 5.5M20 13.5 15.5 19" /></>,28  clock: <>{RING}<P d="M12 7.5V12l3 2" /></>,29  bolt: <P d="M13 3 5 13.5h6L10 21l8-10.5h-6L13 3Z" />,30  lock: <><rect x="5" y="11" width="14" height="9.5" rx="2" /><P d="M8 11V8a4 4 0 0 1 8 0v3M12 14.8v2" /></>,31  key: <><circle cx="8" cy="15.5" r="4" /><P d="m11 12.5 8.5-8.5M16.5 7l2.5 2.5M13.8 9.7l2 2" /></>,32  shield: <><P d="m12 3 7.5 3v5.5c0 4.5-3 8-7.5 9.5-4.5-1.5-7.5-5-7.5-9.5V6L12 3Z" /><P d="m9 12 2.2 2.2 4-4.2" /></>,33  users: <><circle cx="9" cy="8" r="3.2" /><P d="M3 20c0-3.3 2.7-6 6-6s6 2.7 6 6" /><P d="M16 5.1a3.2 3.2 0 0 1 0 5.9M17.5 14.4c2.1.8 3.5 2.9 3.5 5.6" /></>,34  user: <><circle cx="12" cy="8" r="3.5" /><P d="M5 20.5c0-3.9 3.1-7 7-7s7 3.1 7 7" /></>,35  globe: <>{RING}<P d="M3.5 12h17" /><P d="M12 3.5c2.5 2.4 3.8 5.2 3.8 8.5s-1.3 6.1-3.8 8.5c-2.5-2.4-3.8-5.2-3.8-8.5s1.3-6.1 3.8-8.5Z" /></>,36  flask: <><P d="M9.5 3h5M10.5 3v6.2L5.2 18a2 2 0 0 0 1.7 3h10.2a2 2 0 0 0 1.7-3l-5.3-8.8V3" /><P d="M7.8 15h8.4" /></>,37  atom: <><circle cx="12" cy="12" r="1.3" /><ellipse cx="12" cy="12" rx="9" ry="3.6" /><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(60 12 12)" /><ellipse cx="12" cy="12" rx="9" ry="3.6" transform="rotate(120 12 12)" /></>,38  book: <><P d="M5 4.5A1.5 1.5 0 0 1 6.5 3H19v15H6.5A1.5 1.5 0 0 0 5 19.5v-15Z" /><P d="M5 19.5A1.5 1.5 0 0 0 6.5 21H19M9 7.5h6" /></>,39  target: <>{RING}<circle cx="12" cy="12" r="4.8" /><circle cx="12" cy="12" r="1.2" /></>,40  check: <>{RING}<P d="m8 12.2 2.8 2.8 5.2-5.6" /></>,41  cross: <>{RING}<P d="m9 9 6 6M15 9l-6 6" /></>,42  warning: <><P d="M12 4 2.8 19.5h18.4L12 4Z" /><P d="M12 10v4.5M12 17.2h.01" /></>,43  info: <>{RING}<P d="M12 11v5.5M12 7.8h.01" /></>,44  scale: <><P d="M12 4v16M7.5 20h9M5 7h14" /><P d="m5 7-2.5 6a2.5 2.5 0 0 0 5 0L5 7ZM19 7l-2.5 6a2.5 2.5 0 0 0 5 0L19 7Z" /></>,45  coins: <><ellipse cx="9" cy="7" rx="5.5" ry="2.5" /><P d="M3.5 7v4.5c0 1.4 2.5 2.5 5.5 2.5M3.5 11.5V16c0 1.4 2.5 2.5 5.5 2.5" /><ellipse cx="15" cy="13.5" rx="5.5" ry="2.5" /><P d="M9.5 13.5V18c0 1.4 2.5 2.5 5.5 2.5s5.5-1.1 5.5-2.5v-4.5" /></>,46  bank: <><P d="M3 9.5 12 4l9 5.5H3Z" /><P d="M5.5 10v7M9.8 10v7M14.2 10v7M18.5 10v7M3.5 20h17M4.5 17h15" /></>,47  cube: <><P d="m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3Z" /><P d="m4 7.5 8 4.5 8-4.5M12 12v9" /></>,48  gear: <><circle cx="12" cy="12" r="3" /><circle cx="12" cy="12" r="6.5" /><P d="M12 2.8v2.7M12 18.5v2.7M2.8 12h2.7M18.5 12h2.7M5.5 5.5l1.9 1.9M16.6 16.6l1.9 1.9M5.5 18.5l1.9-1.9M16.6 7.4l1.9-1.9" /></>,49  arrows: <P d="M4 8h14M14 4l4 4-4 4M20 16H6M10 12l-4 4 4 4" />,50  split: <><P d="M3.5 12H9c4 0 3.5-6 7.5-6H20M9 12c4 0 3.5 6 7.5 6H20" /><P d="M17.5 3.5 20 6l-2.5 2.5M17.5 15.5 20 18l-2.5 2.5" /></>,51  merge: <><P d="M3.5 6H7c4 0 3.5 6 7.5 6H20M3.5 18H7c4 0 3.5-6 7.5-6" /><P d="M17.5 9.5 20 12l-2.5 2.5" /></>,52  token: <><P d="m12 3.5 7.4 4.25v8.5L12 20.5l-7.4-4.25v-8.5L12 3.5Z" /><P d="M9 9.8h6M12 9.8v5.2" /></>,53  memory: <><rect x="3" y="6.5" width="18" height="9.5" rx="1.5" /><P d="M7.5 10v2.5M12 10v2.5M16.5 10v2.5M6 16v3M10 16v3M14 16v3M18 16v3" /></>,54  queue: <><rect x="3" y="8" width="4" height="8" rx="1" /><rect x="9" y="8" width="4" height="8" rx="1" /><P d="M15.5 12H21M18.5 9.5 21 12l-2.5 2.5" /></>,55  table: <><rect x="3.5" y="4.5" width="17" height="15" rx="2" /><P d="M3.5 9.5h17M3.5 14.5h17M9.5 9.5v10" /></>,56  eye: <><P d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z" /><circle cx="12" cy="12" r="3" /></>,57  sparkles: <><P d="m10 4 1.6 4.4L16 10l-4.4 1.6L10 16l-1.6-4.4L4 10l4.4-1.6L10 4Z" /><P d="m18 14 .8 2.2L21 17l-2.2.8L18 20l-.8-2.2L15 17l2.2-.8L18 14Z" /></>,58  puzzle: <P d="M5 8h3.5a2 2 0 1 1 4 0H16v3.5a2 2 0 1 1 0 4V19H5V8Z" />,59  microscope: <><P d="M6 20.5h13M9.5 20.5a6.2 6.2 0 0 0 6.3-9.3" /><P d="m10 4 3.5 1.5-2.6 6L7.4 10 10 4Z" /><P d="M7.5 14.5h5" /></>,60  calculator: <><rect x="5" y="3" width="14" height="18" rx="2" /><P d="M8.5 7h7M8.5 11h.01M12 11h.01M15.5 11h.01M8.5 14.2h.01M12 14.2h.01M15.5 14.2h.01M8.5 17.4h.01M12 17.4h3.5" /></>,61  link: <><P d="M10 14a4 4 0 0 0 5.7 0l3-3A4 4 0 0 0 13 5.3l-1 1" /><P d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1" /></>,62};6364const STROKE = { fill: "none", stroke: "currentColor", strokeWidth: 1.75, strokeLinecap: "round", strokeLinejoin: "round" } as const;6566/** One glyph of the fixed icon set, drawn on a 24×24 grid with currentColor strokes. Decorative: aria-hidden. */67export function IconGlyph({ name, size = 20 }: { name: Icon; size?: number }) {68  return <svg className="sh-icon" width={size} height={size} viewBox="0 0 24 24" aria-hidden="true" focusable="false" data-icon={name} {...STROKE}>{ICON_GLYPHS[name]}</svg>;69}7071/** The same glyph as a positioned group, for use inside another SVG (diagram nodes). Colour comes from `color`. */72export function IconInSvg({ name, x, y, size, color }: { name: Icon; x: number; y: number; size: number; color: string }) {73  const k = size / 24;74  return <g transform={`translate(${x} ${y}) scale(${Math.round(k * 1000) / 1000})`} color={color} {...STROKE} strokeWidth={1.75 / Math.max(k, 0.6) * 0.8} aria-hidden="true">{ICON_GLYPHS[name]}</g>;75}76
Files main
Menu

Theme