mirror of
https://github.com/khairul169/vaulterm.git
synced 2025-06-18 01:29:37 +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 {...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;
|