* A floating action bar that pins itself to the bottom of the nearest * positioned ancestor (usually a scroll container with `position: relative`). * * Rendered as a `CardStack` so it picks up the card visual — wrap action * buttons as children; they'll be right-aligned inside the card. * * To
({ className, children }: { className?: string; children: React.ReactNode })
| 19 | * on top of a loading state. |
| 20 | */ |
| 21 | function FloatActions({ className, children }: { className?: string; children: React.ReactNode }) { |
| 22 | const isLoading = useRouterState({ select: (s) => s.isLoading }); |
| 23 | |
| 24 | if (isLoading) { |
| 25 | return null; |
| 26 | } |
| 27 | |
| 28 | return ( |
| 29 | // `transform-gpu` promotes the bar to its own compositing layer. Without it, |
| 30 | // when an action button changes width (e.g. "Add integration" -> "Adding...") |
| 31 | // the right-aligned row reflows and Chromium can leave a stale paint of the |
| 32 | // sticky bar, rendering it doubled/ghosted. A dedicated layer repaints |
| 33 | // atomically and avoids the artifact. Transforming the sticky element itself |
| 34 | // does not affect its stickiness. |
| 35 | <CardStack |
| 36 | className={cn( |
| 37 | "sticky shadow-lg bottom-4 left-0 right-0 mt-auto w-full transform-gpu", |
| 38 | className, |
| 39 | )} |
| 40 | > |
| 41 | <div className="flex items-center justify-end gap-3 px-4 py-3">{children}</div> |
| 42 | </CardStack> |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | export { FloatActions }; |