Add ContextMenu and ContextMenuItem
This commit is contained in:
parent
ad72bcdcf9
commit
ed0c821227
4 changed files with 79 additions and 0 deletions
6
components/ContextMenu/index.scss
Normal file
6
components/ContextMenu/index.scss
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
.ContextMenu {
|
||||||
|
background: var(--menu-bg);
|
||||||
|
border-radius: $input-corner;
|
||||||
|
padding: $unit 0;
|
||||||
|
margin-top: $unit-fourth;
|
||||||
|
}
|
||||||
36
components/ContextMenu/index.tsx
Normal file
36
components/ContextMenu/index.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import React from 'react'
|
||||||
|
import classNames from 'classnames'
|
||||||
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
||||||
|
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
|
interface Props
|
||||||
|
extends React.DetailedHTMLProps<
|
||||||
|
React.DialogHTMLAttributes<HTMLDivElement>,
|
||||||
|
HTMLDivElement
|
||||||
|
> {
|
||||||
|
align?: 'start' | 'center' | 'end'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ContextMenuContent = React.forwardRef<HTMLDivElement, Props>(
|
||||||
|
function ContextMenu({ children, ...props }, forwardedRef) {
|
||||||
|
const classes = classNames(
|
||||||
|
{
|
||||||
|
ContextMenu: true,
|
||||||
|
},
|
||||||
|
props.className
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownMenu.Portal>
|
||||||
|
<DropdownMenu.Content className={classes} {...props} ref={forwardedRef}>
|
||||||
|
{children}
|
||||||
|
</DropdownMenu.Content>
|
||||||
|
</DropdownMenu.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export const ContextMenu = DropdownMenu.Root
|
||||||
|
export const ContextMenuGroup = DropdownMenu.Group
|
||||||
|
export const ContextMenuTrigger = DropdownMenu.Trigger
|
||||||
11
components/ContextMenuItem/index.scss
Normal file
11
components/ContextMenuItem/index.scss
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
.ContextItem {
|
||||||
|
color: var(--menu-text);
|
||||||
|
font-size: $font-regular;
|
||||||
|
padding: ($unit * 1.5) $unit-2x;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--menu-bg-item-hover);
|
||||||
|
color: var(--text-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
components/ContextMenuItem/index.tsx
Normal file
26
components/ContextMenuItem/index.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import React from 'react'
|
||||||
|
import classNames from 'classnames'
|
||||||
|
import { DropdownMenuItem } from '@radix-ui/react-dropdown-menu'
|
||||||
|
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
|
interface Props
|
||||||
|
extends React.DetailedHTMLProps<
|
||||||
|
React.DialogHTMLAttributes<HTMLDivElement>,
|
||||||
|
HTMLDivElement
|
||||||
|
> {}
|
||||||
|
|
||||||
|
const ContextMenuItem = React.forwardRef<HTMLDivElement, Props>(
|
||||||
|
function ContextMenu({ children, ...props }, forwardedRef) {
|
||||||
|
const classes = classNames(
|
||||||
|
{
|
||||||
|
ContextItem: true,
|
||||||
|
},
|
||||||
|
props.className
|
||||||
|
)
|
||||||
|
|
||||||
|
return <DropdownMenuItem className={classes}>{children}</DropdownMenuItem>
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export default ContextMenuItem
|
||||||
Loading…
Reference in a new issue