Skip to content

Commit aeba466

Browse files
committed
feat: add component PopoverAnchor
1 parent 5f147a2 commit aeba466

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Anchor } from '@radix-ui/react-popover';
2+
3+
import { cn } from '@/lib/utils';
4+
5+
import { popoverVariants } from './popover-varianst';
6+
import type { PopoverAnchorProps } from './types';
7+
8+
const PopoverAnchor = (props: PopoverAnchorProps) => {
9+
const { className, ...rest } = props;
10+
11+
const { anchor } = popoverVariants();
12+
13+
const mergedCls = cn(anchor(), className);
14+
15+
return (
16+
<Anchor
17+
className={mergedCls}
18+
data-slot="combobox-anchor"
19+
{...rest}
20+
/>
21+
);
22+
};
23+
24+
export default PopoverAnchor;

packages/ui/src/components/popover/popover-varianst.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const popoverVariants = tv({
55
size: 'md'
66
},
77
slots: {
8+
anchor: 'w-full',
89
arrow: 'w-1em h-0.5em fill-popover stroke-border',
910
content: [
1011
`w-auto rounded-md border bg-popover text-popover-foreground shadow-md outline-none z-50 will-change-transform`,

packages/ui/src/components/popover/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {
22
// eslint-disable-next-line sort/import-members
33
PopoverPortalProps,
4+
PopoverAnchorProps as _PopoverAnchorProps,
45
PopoverArrowProps as _PopoverArrowProps,
56
PopoverContentProps as _PopoverContentProps,
67
PopoverProps as _PopoverProps
@@ -28,3 +29,5 @@ export type PopoverProps = _PopoverProps &
2829
showArrow?: boolean;
2930
trigger?: React.ReactNode;
3031
};
32+
33+
export type PopoverAnchorProps = BaseNodeProps<_PopoverAnchorProps>;

0 commit comments

Comments
 (0)