-
Notifications
You must be signed in to change notification settings - Fork 374
Expand file tree
/
Copy pathNodeAppendix.tsx
More file actions
45 lines (40 loc) · 1.07 KB
/
NodeAppendix.tsx
File metadata and controls
45 lines (40 loc) · 1.07 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
38
39
40
41
42
43
44
45
import { cva, type VariantProps } from 'class-variance-authority'
import { forwardRef, type HTMLAttributes } from 'react'
import { cn } from '@/utils'
const appendixVariants = cva(
'node-appendix absolute flex w-full flex-col items-center',
{
variants: {
position: {
top: '-translate-y-[100%] -my-1',
bottom: 'top-[100%] my-1',
left: '-left-[100%] -mx-1',
right: 'left-[100%] mx-1',
},
},
defaultVariants: {
position: 'top',
},
},
)
export interface NodeAppendixProps
extends HTMLAttributes<HTMLDivElement>,
VariantProps<typeof appendixVariants> {
className?: string
position?: 'top' | 'bottom' | 'left' | 'right'
}
export const NodeAppendix = forwardRef<HTMLDivElement, NodeAppendixProps>(
({ children, className, position, ...props }, ref) => {
return (
<div
ref={ref}
data-component="NodeAppendix"
className={cn(appendixVariants({ position }), className)}
{...props}
>
{children}
</div>
)
},
)
NodeAppendix.displayName = 'NodeAppendix'