mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
fix(studio): menu row highlight follows the menu's corner (#7791)
* fix(studio): menu row highlight follows the menu's corner * fix(studio): keep the menu row's comment share flat * fix(studio): export the menu row class so hosts reuse it
This commit is contained in:
@@ -443,12 +443,14 @@ describe("open motion", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("rounds a row's highlight more than the panel that holds it", async () => {
|
||||
it("rounds a row's highlight to the panel's corner less the panel's inset", async () => {
|
||||
await openActionMenu();
|
||||
|
||||
const rowRadius = [...items()[0]!.classList].find((c) => c.startsWith("rounded-"))!;
|
||||
expect([...popup()!.classList]).toContain("rounded-lg");
|
||||
expect(compileStudioCss([rowRadius])).toMatch(/calc\(var\(--radius-lg\) \+ 6px\)/);
|
||||
expect([...popup()!.classList]).toEqual(expect.arrayContaining(["rounded-lg", "p-1"]));
|
||||
expect(compileStudioCss([rowRadius])).toMatch(
|
||||
/border-radius: calc\(var\(--radius-lg\) - 4px\)/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ export const POPUP_LAYER = "z-200";
|
||||
const menuPopup = cn(popupSurface, "min-w-36 p-1 shadow-menu");
|
||||
|
||||
/** One row. `data-highlighted` is set by keyboard and pointer alike, so the seen row is the Enter row. */
|
||||
const itemBase = cn(
|
||||
"flex cursor-default select-none items-center justify-between gap-6 rounded-[calc(var(--radius-lg)+6px)] px-2 py-1.5",
|
||||
export const menuItemBase = cn(
|
||||
"flex cursor-default select-none items-center justify-between gap-6 rounded-[calc(var(--radius-lg)-4px)] px-2 py-1.5",
|
||||
"text-step-11 whitespace-nowrap text-text-1",
|
||||
"outline-hidden transition-colors ease-out-quint duration-hover",
|
||||
"data-[highlighted]:bg-hover data-[highlighted]:text-text-0",
|
||||
@@ -210,7 +210,10 @@ interface MenuItemProps extends StyledProps<typeof BaseMenu.Item> {
|
||||
/** One action. `disabled` items are skipped by the arrow keys, not just dimmed. */
|
||||
export function MenuItem({ shortcut, tone, className, children, ...props }: MenuItemProps) {
|
||||
return (
|
||||
<BaseMenu.Item className={cn(itemBase, tone === "danger" && itemDanger, className)} {...props}>
|
||||
<BaseMenu.Item
|
||||
className={cn(menuItemBase, tone === "danger" && itemDanger, className)}
|
||||
{...props}
|
||||
>
|
||||
<span className="truncate">{children}</span>
|
||||
{shortcut ? <MenuShortcut>{shortcut}</MenuShortcut> : null}
|
||||
</BaseMenu.Item>
|
||||
@@ -229,7 +232,7 @@ interface MenuRadioItemProps extends StyledProps<typeof BaseMenu.RadioItem> {
|
||||
/** One choice in a `MenuRadioGroup`. The dot renders only while it is checked. */
|
||||
export function MenuRadioItem({ className, children, ...props }: MenuRadioItemProps) {
|
||||
return (
|
||||
<BaseMenu.RadioItem className={cn(itemBase, className)} {...props}>
|
||||
<BaseMenu.RadioItem className={cn(menuItemBase, className)} {...props}>
|
||||
<span className="truncate">{children}</span>
|
||||
{/* Fixed box so a checked and an unchecked row keep the same width. */}
|
||||
<span className="flex size-3 shrink-0 items-center justify-center">
|
||||
@@ -246,7 +249,7 @@ export function MenuCheckboxItem({
|
||||
...props
|
||||
}: StyledProps<typeof BaseMenu.CheckboxItem>) {
|
||||
return (
|
||||
<BaseMenu.CheckboxItem className={cn(itemBase, className)} {...props}>
|
||||
<BaseMenu.CheckboxItem className={cn(menuItemBase, className)} {...props}>
|
||||
<span className="truncate">{children}</span>
|
||||
<span className="flex size-3 shrink-0 items-center justify-center text-accent-ink">
|
||||
<BaseMenu.CheckboxItemIndicator>✓</BaseMenu.CheckboxItemIndicator>
|
||||
|
||||
@@ -17,6 +17,7 @@ export {
|
||||
MenuRadioItem,
|
||||
MenuSeparator,
|
||||
MenuShortcut,
|
||||
menuItemBase,
|
||||
popupSurface,
|
||||
} from "./Menu";
|
||||
export type { MenuItemTone, PopupPreviewState } from "./Menu";
|
||||
|
||||
@@ -15,6 +15,7 @@ export {
|
||||
MenuRadioItem,
|
||||
MenuSeparator,
|
||||
MenuShortcut,
|
||||
menuItemBase,
|
||||
popupSurface,
|
||||
} from "./components/ui/Menu";
|
||||
export type { MenuItemTone, PopupPreviewState } from "./components/ui/Menu";
|
||||
|
||||
Reference in New Issue
Block a user