The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { ProjectIconColor } from "@t3tools/contracts"; |
| 2 | import { projectIconColorClassName } from "../projectIconColors"; |
| 3 | import { cn } from "~/lib/utils"; |
| 4 | |
| 5 | const monogramSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" }); |
| 6 | |
| 7 | export function ProjectMonogram({ |
| 8 | text, |
| 9 | color, |
| 10 | className, |
| 11 | }: { |
| 12 | readonly text: string; |
| 13 | readonly color: ProjectIconColor; |
| 14 | readonly className?: string | undefined; |
| 15 | }) { |
| 16 | // Wrap the tile to avoid menu/button SVG margin trimming. |
| 17 | return ( |
| 18 | <span |
| 19 | aria-hidden="true" |
| 20 | data-slot="project-monogram" |
| 21 | className={cn("inline-flex size-4 shrink-0 items-center justify-center", className)} |
| 22 | > |
| 23 | <svg |
| 24 | viewBox="0 0 16 16" |
| 25 | className={cn( |
| 26 | "size-full overflow-hidden rounded-[25%] font-mono select-none", |
| 27 | projectIconColorClassName(color), |
| 28 | )} |
| 29 | style={{ |
| 30 | backgroundColor: "color-mix(in srgb, currentColor 14%, transparent)", |
| 31 | }} |
| 32 | > |
| 33 | <text |
| 34 | x="8" |
| 35 | y="10.8" |
| 36 | textAnchor="middle" |
| 37 | fill="currentColor" |
| 38 | className="font-mono" |
| 39 | fontSize="8.25" |
| 40 | fontWeight="700" |
| 41 | textLength={Array.from(monogramSegmenter.segment(text)).length === 1 ? 6 : 12} |
| 42 | lengthAdjust="spacingAndGlyphs" |
| 43 | textRendering="geometricPrecision" |
| 44 | > |
| 45 | {text} |
| 46 | </text> |
| 47 | </svg> |
| 48 | </span> |
| 49 | ); |
| 50 | } |