The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useGT } from "gt-react"; |
| 2 | import { BookmarkIcon } from "lucide-react"; |
| 3 | import { memo } from "react"; |
| 4 | |
| 5 | import { cn } from "~/lib/utils"; |
| 6 | import { ComposerBanner } from "./ComposerBanner"; |
| 7 | |
| 8 | export const ComposerStashBadge = memo(function ComposerStashBadge(props: { |
| 9 | count: number; |
| 10 | menuOpen: boolean; |
| 11 | /** Bumped per stash; each new key replays the pulse. 0 means never pulsed. */ |
| 12 | pulseKey: number; |
| 13 | onToggleMenu: () => void; |
| 14 | }) { |
| 15 | const gt = useGT(); |
| 16 | if (props.count === 0) return null; |
| 17 | const pulsed = props.pulseKey > 0; |
| 18 | const count = ( |
| 19 | <ComposerBanner.Count |
| 20 | // Remounting the count per stash restarts its CSS pulse; no timer has to end it. |
| 21 | key={props.pulseKey} |
| 22 | className={cn( |
| 23 | "text-muted-foreground", |
| 24 | pulsed && |
| 25 | "animate-stash-pulse-count transition-[opacity,translate] duration-180 ease-out starting:translate-y-0.5 starting:opacity-0 motion-reduce:transition-none", |
| 26 | )} |
| 27 | > |
| 28 | {props.count} |
| 29 | </ComposerBanner.Count> |
| 30 | ); |
| 31 | |
| 32 | return ( |
| 33 | <ComposerBanner.Root |
| 34 | density="comfortable" |
| 35 | width="content" |
| 36 | data-composer-shoulder-tab |
| 37 | className="ml-auto" |
| 38 | > |
| 39 | <ComposerBanner.Row |
| 40 | render={<button type="button" />} |
| 41 | data-prompt-stash-badge="true" |
| 42 | aria-label={gt("Stashed prompts: {count}. Open stash.", { count: props.count })} |
| 43 | aria-expanded={props.menuOpen} |
| 44 | className={cn( |
| 45 | "transition-colors duration-200", |
| 46 | props.menuOpen && "pointer-events-none", |
| 47 | props.menuOpen ? "text-foreground" : "text-muted-foreground hover:text-foreground", |
| 48 | // The button keeps its identity (focus, hover) across stashes. Swapping between two |
| 49 | // identical keyframes restarts the row's animation instead. |
| 50 | pulsed && |
| 51 | (props.pulseKey % 2 === 0 ? "animate-stash-pulse-row-alt" : "animate-stash-pulse-row"), |
| 52 | )} |
| 53 | onPointerDown={(event) => event.preventDefault()} |
| 54 | onClick={props.onToggleMenu} |
| 55 | > |
| 56 | <ComposerBanner.Icon> |
| 57 | <BookmarkIcon /> |
| 58 | </ComposerBanner.Icon> |
| 59 | <ComposerBanner.Content> |
| 60 | {gt("Stash", { $context: "noun, saved prompts set aside for later" })} |
| 61 | </ComposerBanner.Content> |
| 62 | <ComposerBanner.Actions>{count}</ComposerBanner.Actions> |
| 63 | </ComposerBanner.Row> |
| 64 | </ComposerBanner.Root> |
| 65 | ); |
| 66 | }); |