import { platform } from "@yaakapp-internal/platform"; import { Icon } from "@yaakapp-internal/ui"; import type { ReactNode } from "react"; import { setKeyValue } from "../../lib/keyValueStore"; import { DismissibleBanner } from "./DismissibleBanner"; interface Props { /** Stable id; the dismissal is remembered under it. */ id: string; children: ReactNode; docsUrl?: string; action?: { label: string; onClick: () => void | Promise }; onDismiss?: () => void; className?: string; } /** * A one-time nudge toward a feature the user hasn't found yet. Dismissed once, gone for good. */ export function FeatureHint({ id, children, docsUrl, action, onDismiss, className }: Props) { const actions = [ ...(action ? [{ ...action, variant: "solid" as const, color: "info" as const }] : []), ...(action != null && docsUrl != null ? [ { label: "Docs", rightSlot: , onClick: () => platform.openUrl(docsUrl).catch(console.error), }, ] : []), ]; return (
{children} {action == null && docsUrl != null && ( <> {" "} ( ) )}
); } export function dismissFeatureHint(id: string) { return setKeyValue({ namespace: "global", key: ["dismiss-banner", `feature-hint:${id}`], value: true, }); }