mirror of
https://github.com/khairul169/vaulterm.git
synced 2025-04-28 16:49:39 +07:00
51 lines
1.0 KiB
TypeScript
51 lines
1.0 KiB
TypeScript
import React from "react";
|
|
import {
|
|
GetProps,
|
|
ListItem,
|
|
Popover,
|
|
styled,
|
|
withStaticProperties,
|
|
} from "tamagui";
|
|
|
|
type MenuButtonProps = GetProps<typeof Popover> & {
|
|
asChild?: boolean;
|
|
trigger?: React.ReactNode;
|
|
width?: string | number | null;
|
|
};
|
|
|
|
const MenuButtonFrame = ({
|
|
asChild,
|
|
trigger,
|
|
children,
|
|
width,
|
|
...props
|
|
}: MenuButtonProps) => {
|
|
return (
|
|
<Popover size="$1" {...props}>
|
|
<Popover.Trigger asChild={asChild}>{trigger}</Popover.Trigger>
|
|
|
|
<Popover.Content
|
|
bordered
|
|
enterStyle={{ y: -10, opacity: 0 }}
|
|
exitStyle={{ y: -10, opacity: 0 }}
|
|
animation={["quick", { opacity: { overshootClamping: true } }]}
|
|
width={width}
|
|
>
|
|
{children}
|
|
</Popover.Content>
|
|
</Popover>
|
|
);
|
|
};
|
|
|
|
const MenuButtonItem = (props: GetProps<typeof ListItem>) => (
|
|
<Popover.Close asChild>
|
|
<ListItem hoverTheme pressTheme {...props} />
|
|
</Popover.Close>
|
|
);
|
|
|
|
const MenuButton = withStaticProperties(MenuButtonFrame, {
|
|
Item: MenuButtonItem,
|
|
});
|
|
|
|
export default MenuButton;
|