| 1 | import { ArrowUp, AtSign, Plus, Sparkles } from "lucide-react"; |
| 2 | import type { ReactNode } from "react"; |
| 3 | import { Link } from "react-router"; |
| 4 | |
| 5 | import { MarkGlyph } from "./logo"; |
| 6 | import { Badge } from "./ui/badge"; |
| 7 | import { Button } from "./ui/button"; |
| 8 | import { Card } from "./ui/card"; |
| 9 | import { Hint } from "./ui/hint"; |
| 10 | import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover"; |
| 11 | |
| 12 | /** |
| 13 | * The place to ask AI for something and hand the work to one of the |
| 14 | * workspace's AI providers (Workspace settings → Integrations → Your AI |
| 15 | * providers). Shown so it is clear where this will be, and not usable yet: |
| 16 | * nothing here sends, and every control says so. |
| 17 | */ |
| 18 | export function AskComposer({ slug, children }: { slug: string; children?: ReactNode }) { |
| 19 | return ( |
| 20 | <section aria-label="Ask AI" className="space-y-3"> |
| 21 | <Card aria-disabled="true" className="opacity-80"> |
| 22 | <p className="flex items-center gap-2 px-4 pt-3 text-sm font-medium text-fg"> |
| 23 | <Sparkles size={14} className="text-accent" aria-hidden="true" /> |
| 24 | Ask AI |
| 25 | <Badge className="px-1.5 py-0 font-normal">Coming soon</Badge> |
| 26 | </p> |
| 27 | <label htmlFor="ask-ai" className="sr-only"> |
| 28 | Ask AI (coming soon) |
| 29 | </label> |
| 30 | <textarea |
| 31 | id="ask-ai" |
| 32 | disabled |
| 33 | rows={2} |
| 34 | placeholder="Ask anything, or describe work to hand to your AI provider." |
| 35 | className="block w-full cursor-not-allowed resize-none bg-transparent px-4 pt-3.5 pb-2 text-sm text-fg placeholder:text-muted focus:outline-none" |
| 36 | /> |
| 37 | <div className="flex flex-wrap items-center gap-2 px-3 pb-3"> |
| 38 | <Soon label="Add context"> |
| 39 | <Plus size={15} /> |
| 40 | </Soon> |
| 41 | <Soon label="Mention"> |
| 42 | <AtSign size={14} /> |
| 43 | </Soon> |
| 44 | <span className="ml-auto" /> |
| 45 | <Soon label="Send"> |
| 46 | <ArrowUp size={15} /> |
| 47 | </Soon> |
| 48 | </div> |
| 49 | </Card> |
| 50 | <p className="text-xs text-muted"> |
| 51 | It will hand off to{" "} |
| 52 | <Link to={`/${slug}/-/integrations/models`} className="text-accent hover:underline"> |
| 53 | your AI providers |
| 54 | </Link> |
| 55 | . |
| 56 | </p> |
| 57 | {children} |
| 58 | </section> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | /** One of the composer's controls: there, disabled, with a hint saying why. */ |
| 63 | function Soon({ label, children }: { label: string; children: ReactNode }) { |
| 64 | return ( |
| 65 | <Hint label="Coming soon" disabled> |
| 66 | <Button type="button" variant="outline" size="icon-sm" disabled aria-label={`${label} (coming soon)`}> |
| 67 | {children} |
| 68 | </Button> |
| 69 | </Hint> |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * The top bar's Ask AI: the lavender pixel 1 beside its words, on a wash of |
| 75 | * the accent. Not on yet: it opens the composer, which says so. |
| 76 | */ |
| 77 | export function AskButton({ slug }: { slug: string }) { |
| 78 | return ( |
| 79 | <Popover> |
| 80 | <Hint label="Ask AI · coming soon"> |
| 81 | <PopoverTrigger asChild> |
| 82 | <Button variant="soft" size="bar" aria-label="Ask AI (coming soon)" className="gap-2 max-md:ring-0 lg:px-3"> |
| 83 | <MarkGlyph className="h-3.5" /> |
| 84 | <span className="max-lg:hidden">Ask AI</span> |
| 85 | </Button> |
| 86 | </PopoverTrigger> |
| 87 | </Hint> |
| 88 | <PopoverContent align="end" className="w-[26rem] p-3"> |
| 89 | <AskComposer slug={slug} /> |
| 90 | </PopoverContent> |
| 91 | </Popover> |
| 92 | ); |
| 93 | } |