mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-29 19:52:54 +01:00
Every action in an ActionsBar is now held to the height and radius of an sm icon button and centred on the row; the Pretty/Raw switch is sized to match instead of sitting shorter than the filter toggle. A CSV part in the multipart viewer loses leftover debug classes that drew it as a small primary-coloured block, and takes the pb-2 the other part viewers use. The harness's multipart fixture gains a CSV part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.5 KiB
TypeScript
40 lines
1.5 KiB
TypeScript
import classNames from "classnames";
|
|
import type { ReactNode } from "react";
|
|
|
|
/** For the positioned element an `ActionsBar` sits in: hovering it brings the bar's actions in */
|
|
export const ACTIONS_BAR_CONTAINER = "relative group/actions";
|
|
|
|
/** Set on an action's outermost element to keep it in view, as a control that shows state does */
|
|
export const PINNED_ACTION = { "data-pinned": true } as const;
|
|
|
|
interface Props {
|
|
children: ReactNode;
|
|
className?: string;
|
|
}
|
|
|
|
/**
|
|
* A row of actions over the bottom-right corner of the content in an `ACTIONS_BAR_CONTAINER`:
|
|
* small bordered buttons on the surface colour, so they read over text, each held to the height
|
|
* and radius of an `sm` icon button and centred on the row. Each fades in while the
|
|
* container is hovered or the action has focus, unless it carries `PINNED_ACTION`. The row lets
|
|
* clicks through to the content between its actions.
|
|
*/
|
|
export function ActionsBar({ children, className }: Props) {
|
|
return (
|
|
<div
|
|
className={classNames(
|
|
className,
|
|
"absolute bottom-2 left-0 right-0 z-10 flex items-center justify-end gap-1",
|
|
"pointer-events-none",
|
|
"*:pointer-events-auto *:bg-surface *:shadow *:transition-opacity *:transform-gpu",
|
|
// Every action as tall and as round as a small icon button, so they line up
|
|
"*:h-sm *:rounded-md",
|
|
"[&>:not([data-pinned])]:opacity-0",
|
|
"group-hover/actions:*:opacity-100! *:focus-within:opacity-100! *:hover:opacity-100!",
|
|
)}
|
|
>
|
|
{children}
|
|
</div>
|
|
);
|
|
}
|