-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPopover.tsx
More file actions
37 lines (31 loc) · 1.21 KB
/
Popover.tsx
File metadata and controls
37 lines (31 loc) · 1.21 KB
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
import React, { ReactElement } from 'react';
import { Dialog, DialogTrigger, Popover as BasePopover, PopoverProps as BasePopoverProps } from 'react-aria-components';
import styled from 'styled-components';
import { getSemanticValue } from '../../../essentials/experimental';
import { get } from '../../../utils/experimental/themeGet';
interface PopoverProps extends Omit<BasePopoverProps, 'children'> {
children: React.ReactNode;
}
const StyledPopover = styled(BasePopover)`
background: ${getSemanticValue('surface')};
padding: ${get('space.4')};
box-shadow: 0 2px 4px -1px hsla(0, 0%, 0%, 0.2), 0 1px 10px 0 hsla(0, 0%, 0%, 0.12),
0 4px 5px 0 hsla(0, 0%, 0%, 0.14);
border-radius: ${get('radii.4')};
&[data-trigger='Select'],
&[data-trigger='ComboBox'] {
box-sizing: border-box;
width: var(--trigger-width);
}
`;
const FocusTrap = styled(Dialog)`
outline: 0;
`;
function Popover({ children, placement = 'bottom', offset = 8, ...props }: PopoverProps): ReactElement {
return (
<StyledPopover placement={placement} offset={offset} {...props}>
{children}
</StyledPopover>
);
}
export { Popover, DialogTrigger as PopoverTrigger, FocusTrap };