-
Notifications
You must be signed in to change notification settings - Fork 119
/
Copy pathMenu.tsx
42 lines (36 loc) · 1.13 KB
/
Menu.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { BoxElementProps } from "@twilio-paste/box";
import { Box, safelySpreadBoxProps } from "@twilio-paste/box";
import { MenuPrimitive } from "@twilio-paste/menu-primitive";
import * as React from "react";
import type { MenuProps } from "./types";
const StyledMenu = React.forwardRef<HTMLDivElement, BoxElementProps>(({ style, ...props }, ref) => {
return (
<Box
{...safelySpreadBoxProps(props)}
backgroundColor="colorBackgroundWeaker"
borderRadius="borderRadius30"
boxShadow="shadowElevation10"
maxWidth="size30"
minWidth="size20"
zIndex="zIndex20"
paddingY="space30"
_focus={{ outline: "none" }}
style={style}
ref={ref}
>
<Box
// scroll at roughly 10 items
maxHeight="size50"
overflowY="auto"
>
{props.children}
</Box>
</Box>
);
});
StyledMenu.displayName = "StyledMenu";
const Menu = React.forwardRef<HTMLDivElement, MenuProps>(({ element = "MENU", ...props }, ref) => {
return <MenuPrimitive {...props} element={element} as={StyledMenu} ref={ref} />;
});
Menu.displayName = "Menu";
export { Menu };