import * as React from "react";
import { cn } from "../lib/cn";
/** The three icons the widget's button can show on a customer's site. */
export type LauncherName = "universal" | "wheelchair" | "eye";
/**
* The launcher artwork, faithful to the real widget's trigger button
* (`apps/widget/src/components/WidgetTrigger`): a filled circle in `color`
* (the button's colour) with the glyph's paths in `fill` (the colour inside
* it). The icon picker and the preview draw from here, so both show what
* ships.
*/
type LauncherIconProps = {
color: string;
fill: string;
className?: string;
};
const DEFAULT_ICON_CLASS = "size-10 rounded-full";
export function WheelchairIcon({
color,
fill,
className = DEFAULT_ICON_CLASS,
}: LauncherIconProps) {
return (
);
}
export function UniversalIcon({
color,
fill,
className = DEFAULT_ICON_CLASS,
}: LauncherIconProps) {
return (
);
}
export function VisionIcon({
color,
fill,
className = DEFAULT_ICON_CLASS,
}: LauncherIconProps) {
return (
);
}
const ICON_BY_NAME: Record<
LauncherName,
React.ComponentType
> = {
universal: UniversalIcon,
wheelchair: WheelchairIcon,
eye: VisionIcon,
};
/** The order the picker offers them in. */
export const LAUNCHER_NAMES: readonly LauncherName[] = [
"universal",
"wheelchair",
"eye",
];
export interface LauncherGlyphProps {
name?: LauncherName;
/** The button's colour and the glyph's, as CSS colours. */
color?: string;
glyph?: string;
/** Its side, in pixels. */
size?: number;
className?: string;
}
// The design system's LauncherGlyph: one launcher on its round button, for a
// picker's tile or the preview of the button. Decorative: whatever holds it
// carries the name.
function LauncherGlyph({
name = "universal",
color = "var(--color-primary)",
glyph = "var(--color-primary-white)",
size = 40,
className,
}: LauncherGlyphProps) {
const Icon = ICON_BY_NAME[name] ?? UniversalIcon;
return (
);
}
export { LauncherGlyph };