* Remove backfill-flag-configs script One-time migration has been run; script is no longer needed. https://claude.ai/code/session_014RUwPfm1qc539xLxW4m9Uy * Clean up flag config code - FlagSvg: remove redundant getDisplayFlagConfig call; config is already a valid FlagConfig by type, so the validation/fallback was dead code. Also replace the unreachable `?? "#adf661"` fallback with a non-null assertion. - team/user models: pre-generate ID before insert so flagConfig is persisted immediately on creation rather than relying on display-time generation. - auth.server.ts: add create.after hook so BetterAuth-created users also get a flagConfig written to the DB on signup. https://claude.ai/code/session_014RUwPfm1qc539xLxW4m9Uy * Fix lint: replace non-null assertion in FlagSvg with destructure defaults oxlint forbids the ! operator; destructuring with empty-string defaults is equivalent since FlagConfig always has 3 colors. https://claude.ai/code/session_014RUwPfm1qc539xLxW4m9Uy --------- Co-authored-by: Claude <noreply@anthropic.com>
118 lines
3.9 KiB
TypeScript
118 lines
3.9 KiB
TypeScript
import { cn } from "~/lib/utils";
|
|
import type { FlagConfig } from "~/lib/flag-types";
|
|
|
|
interface FlagSvgProps {
|
|
config: FlagConfig;
|
|
size?: number;
|
|
className?: string;
|
|
title?: string;
|
|
}
|
|
|
|
export function FlagSvg({ config, size = 48, className, title }: FlagSvgProps) {
|
|
const [c0 = "", c1 = "", c2 = ""] = config.colors;
|
|
|
|
return (
|
|
<svg
|
|
viewBox="0 0 100 100"
|
|
width={size}
|
|
height={size}
|
|
role="img"
|
|
aria-label={title}
|
|
className={cn("block shrink-0 overflow-hidden", className)}
|
|
>
|
|
{title ? <title>{title}</title> : null}
|
|
{config.pattern === "triband-h" && (
|
|
<>
|
|
<rect width="100" height="34" fill={c0} />
|
|
<rect y="33" width="100" height="34" fill={c1} />
|
|
<rect y="66" width="100" height="34" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "triband-v" && (
|
|
<>
|
|
<rect width="34" height="100" fill={c0} />
|
|
<rect x="33" width="34" height="100" fill={c1} />
|
|
<rect x="66" width="34" height="100" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "diagonal" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<polygon points="0,0 100,0 0,100" fill={c1} />
|
|
<polygon points="100,100 100,28 28,100" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "nordic-cross" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<rect x="30" width="18" height="100" fill={c1} />
|
|
<rect y="40" width="100" height="18" fill={c1} />
|
|
<rect x="36" width="6" height="100" fill={c2} />
|
|
<rect y="46" width="100" height="6" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "cross" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<rect x="40" width="20" height="100" fill={c1} />
|
|
<rect y="40" width="100" height="20" fill={c1} />
|
|
<rect x="46" width="8" height="100" fill={c2} />
|
|
<rect y="46" width="100" height="8" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "canton" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<rect width="50" height="50" fill={c1} />
|
|
<rect x="12" y="12" width="26" height="26" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "triangle" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<polygon points="0,0 64,50 0,100" fill={c1} />
|
|
<polygon points="0,22 36,50 0,78" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "chevron" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<polygon points="0,0 56,50 0,100 28,100 84,50 28,0" fill={c1} />
|
|
<polygon points="0,22 32,50 0,78 0,62 14,50 0,38" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "quartered" && (
|
|
<>
|
|
<rect width="50" height="50" fill={c0} />
|
|
<rect x="50" width="50" height="50" fill={c1} />
|
|
<rect y="50" width="50" height="50" fill={c1} />
|
|
<rect x="50" y="50" width="50" height="50" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "bordered" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<rect x="12" y="12" width="76" height="76" fill={c1} />
|
|
<rect x="24" y="24" width="52" height="52" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "circle" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<circle cx="50" cy="50" r="30" fill={c1} />
|
|
<circle cx="50" cy="50" r="15" fill={c2} />
|
|
</>
|
|
)}
|
|
{config.pattern === "star" && (
|
|
<>
|
|
<rect width="100" height="100" fill={c0} />
|
|
<polygon
|
|
points="50,14 60,39 87,39 65,56 73,84 50,67 27,84 35,56 13,39 40,39"
|
|
fill={c1}
|
|
/>
|
|
<circle cx="50" cy="50" r="10" fill={c2} />
|
|
</>
|
|
)}
|
|
</svg>
|
|
);
|
|
}
|