runloopable / web /src /apps /templateMarks.tsx
fsanyoto's picture
Deploy AIOS web (React glide grid + FastAPI slice)
95fb175 verified
Raw History Blame Contribute Delete
7.06 kB
// C2: the designed mark of each templatic App, keyed by C1 `mark` (app_templates.TEMPLATES).
// Amazon glyphs use navy ink. Odoo retains its existing accent tokens.
// An unknown or missing mark draws DEFAULT_MARK, so a kind added to C1 before its art still renders.
import type { CSSProperties, ReactElement } from "react";
import { BRAND_OF_CONNECTOR, ConnectorMark } from "../connectors/brandMarks";
import "../styles/sdlc79/app-marks.css";
const INK = "app-mark-ink";
const ACCENT = "app-mark-accent";
// The legacy cg-navy token resolves to blue; Amazon glyphs use the current brand navy.
const AMAZON_INK = { "--cg-navy": "var(--lp-brand-navy)" } as CSSProperties;
/** One drawing per C1 mark, on a 24 unit grid. `verify_icons.py` holds one per C1 kind. */
export const TEMPLATE_MARKS: Readonly<Record<string, ReactElement>> = {
route: <>
<path className={INK} d="M7.2 6h3.3c2.2 0 2.2 3.3 4.4 3.3h1c2 0 2 3.6 0 3.6h-4.8c-2.1 0-2.1 3.1-4.1 3.1H5" />
<circle className={INK} cx="5" cy="6" r="2.2" />
<circle className={ACCENT} cx="19" cy="18" r="2.4" />
</>,
catalog: <>
<rect className={ACCENT} x="3" y="4" width="18" height="5" rx="1.5" />
<rect className={INK} x="3" y="4" width="18" height="16" rx="2" />
<path className={INK} d="M9 9v11M15 9v11" />
</>,
competitor_watch: <>
<path className={INK} d="M2.8 12s3.4-6 9.2-6 9.2 6 9.2 6-3.4 6-9.2 6-9.2-6-9.2-6z" />
<circle className={INK} cx="12" cy="12" r="2.8" />
</>,
ranking_diagnostic: <>
<path className={INK} d="M3 20h12M4 20v-5h3.5v5M8.5 20v-9H12v9M13 20v-3" />
<circle className={INK} cx="16.5" cy="7.5" r="3.4" />
<path className={INK} d="M19 10l2.2 2.2" />
</>,
amazon_operator: <>
<path className={INK} d="M3 13.5h5l1.5 2.5h5l1.5-2.5h5V19H3z" />
<path className={INK} d="M3 13.5l2.4-7.5h13.2l2.4 7.5V19H3z" />
<path className={INK} d="M9 9.5l2 2 4-4" />
</>,
restock_planner: <>
<path className={INK} d="M12 3l8 4.5-8 4.5-8-4.5z" />
<path className={INK} d="M12 3l8 4.5v9L12 21l-8-4.5v-9zM4 7.5l8 4.5 8-4.5M12 12v9" />
</>,
reimbursements: <>
<circle className={INK} cx="13.5" cy="13.5" r="6.5" />
<path className={INK} d="M3.5 9.5a8.5 8.5 0 0 1 12.8-5.1M16.5 2v3h-3M13.5 10.5v6M11.5 12h3a1 1 0 0 1 0 2h-2a1 1 0 0 0 0 2h3" />
</>,
aged_stock: <>
<rect className={INK} x="3" y="9" width="12" height="11" rx="1.5" />
<path className={INK} d="M3 13h12M7.5 13v2.5h3V13" />
<circle className={INK} cx="17" cy="7" r="4.5" />
<path className={INK} d="M17 4.8V7l1.5 1.2" />
</>,
opportunity_finder: <>
<path className={INK} d="M3 19l6-6 4 4 8-8M15 9h6v6" />
<path className={INK} d="M6 2.5l1.1 2.4 2.4 1.1-2.4 1.1L6 9.5 4.9 7.1 2.5 6l2.4-1.1z" />
</>,
returns_refunds: <>
<path className={INK} d="M4 12a8 8 0 0 1 13.7-5.6M18 3v4h-4M20 12a8 8 0 0 1-13.7 5.6M6 21v-4h4" />
<circle className={INK} cx="12" cy="12" r="2.6" />
</>,
repeat_buyers: <>
<circle className={INK} cx="9" cy="8" r="3" />
<path className={INK} d="M3 20v-3a6 6 0 0 1 12 0v3M16 5a6 6 0 0 1 4 10M21 11v4h-4" />
<circle className={INK} cx="18" cy="19" r="2" />
</>,
amazon_dashboard: <>
<rect className={INK} x="3" y="3" width="18" height="18" rx="2" />
<path className={INK} d="M7 17v-4M12 17V7M17 17V10" />
<path className={INK} d="M6 6h3v3H6z" />
</>,
payouts: <>
<rect className={INK} x="2.5" y="6.5" width="19" height="11" rx="1.5" />
<circle className={INK} cx="12" cy="12" r="2.8" />
<path className={INK} d="M6 10v4M18 10v4" />
</>,
account_health: <>
<path className={INK} d="M12 3l8 3v6c0 4.5-3.4 8-8 9-4.6-1-8-4.5-8-9V6z" />
<path className={INK} d="M6.5 12.5h2.8l1.5-3 2.4 6 1.5-3h2.8" />
</>,
amazon_profit: <>
<circle className={INK} cx="12" cy="12" r="8.5" />
<path className={INK} d="M12 3.5V6M12 18v2.5M3.5 12H6M18 12h2.5" />
<circle className={INK} cx="12" cy="12" r="3" />
</>,
alerts: <>
<path className={INK} d="M5 17h14l-2-3V9a5 5 0 0 0-10 0v5zM10 20h4" />
</>,
reports: <>
<path className={ACCENT} d="M14 3v5h5z" />
<path className={INK} d="M14 3H5v18h14V8zM14 3v5h5M8 12h8M8 16h8" />
</>,
};
const AMAZON_MARKS = new Set([
"competitor_watch", "ranking_diagnostic", "amazon_operator", "restock_planner",
"reimbursements", "aged_stock", "opportunity_finder", "returns_refunds", "repeat_buyers",
"amazon_dashboard", "payouts", "account_health", "amazon_profit",
]);
function hasAmazonTemplateMark(mark: unknown): mark is string {
return hasTemplateMark(mark) && AMAZON_MARKS.has(mark);
}
// The Templates mark, stacked sheets, for a kind with no designed mark.
const DEFAULT_MARK = <>
<rect className="app-mark-default" x="3.3" y="6.6" width="17.4" height="13.8" rx="2.1" />
<path className="app-mark-default" d="M6.6 6.6V3.9h14.1v13.8H18M3.3 11.4h17.4" />
</>;
/** True when `mark` names a designed mark. */
export function hasTemplateMark(mark: unknown): mark is string {
return typeof mark === "string" && Object.prototype.hasOwnProperty.call(TEMPLATE_MARKS, mark);
}
/** A templatic App's mark, or the default glyph. Decorative: the App's name sits beside it. */
export function TemplateMark({ mark, size = 24 }: { mark?: unknown; size?: number }): ReactElement {
const known = hasTemplateMark(mark);
return <svg className={known ? "app-mark" : "app-mark is-default"} viewBox="0 0 24 24"
style={hasAmazonTemplateMark(mark) ? AMAZON_INK : undefined}
width={size} height={size} aria-hidden="true" focusable="false" data-mark={known ? mark : "default"}>
{known ? TEMPLATE_MARKS[mark] : DEFAULT_MARK}
</svg>;
}
/** True when an App wears its Amazon or Odoo source brand. */
export function appWearsBrand(connector: unknown): boolean {
return typeof connector === "string" && Object.prototype.hasOwnProperty.call(BRAND_OF_CONNECTOR, connector)
&& (BRAND_OF_CONNECTOR[connector] === "amazon" || BRAND_OF_CONNECTOR[connector] === "odoo");
}
/** A known Amazon App uses its own glyph; other Apps keep their source-brand fallback. */
export function AppMark({ mark, connector, size = 24 }: { mark?: unknown; connector?: unknown; size?: number }) {
if (hasAmazonTemplateMark(mark)) return <TemplateMark mark={mark} size={size} />;
return appWearsBrand(connector)
? <ConnectorMark connector={connector} size={size} className="lp-source-mark app-mark-brand" />
: <TemplateMark mark={mark} size={size} />;
}
/** C2: an App frame's marks. The connector mark sits at 16 px on the right unless the App mark is that brand. */
export function AppFrameMarks({ mark, connector }: { mark?: unknown; connector?: unknown }): ReactElement {
const branded = appWearsBrand(connector);
return <>
<span className="cg-app-frame-mark" data-mark={hasTemplateMark(mark) ? mark : "default"}
aria-hidden={branded ? undefined : "true"}>
<AppMark mark={mark} connector={connector} size={20} />
</span>
{branded ? null : <ConnectorMark connector={connector} className="cg-app-frame-connector" size={16} />}
</>;
}