mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
refactor: export with component definition
This commit is contained in:
parent
94ef1679a9
commit
9d1c04d07a
2 changed files with 51 additions and 49 deletions
|
@ -1,4 +1,4 @@
|
|||
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
||||
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
||||
import "./dropdown-menu.scss";
|
||||
|
||||
export interface DropdownMenuItem {
|
||||
|
@ -20,7 +20,7 @@ interface DropdownMenuProps {
|
|||
alignOffset?: number;
|
||||
}
|
||||
|
||||
export default ({
|
||||
export function DropdownMenu({
|
||||
children,
|
||||
title,
|
||||
items,
|
||||
|
@ -29,49 +29,53 @@ export default ({
|
|||
loop = true,
|
||||
align = "center",
|
||||
alignOffset = 0,
|
||||
}: DropdownMenuProps) => (
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger asChild>
|
||||
<button aria-label={title}>{children}</button>
|
||||
</DropdownMenu.Trigger>
|
||||
}: DropdownMenuProps) {
|
||||
return (
|
||||
<DropdownMenuPrimitive.Root>
|
||||
<DropdownMenuPrimitive.Trigger asChild>
|
||||
<button aria-label={title}>{children}</button>
|
||||
</DropdownMenuPrimitive.Trigger>
|
||||
|
||||
<DropdownMenu.Portal>
|
||||
<DropdownMenu.Content
|
||||
sideOffset={sideOffset}
|
||||
side={side}
|
||||
loop={loop}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
className="dropdown-menu__content"
|
||||
>
|
||||
{title && (
|
||||
<DropdownMenu.Group className="dropdown-menu__group">
|
||||
<div className="dropdown-menu__title-bar">{title}</div>
|
||||
</DropdownMenu.Group>
|
||||
)}
|
||||
|
||||
<DropdownMenu.Separator className="dropdown-menu__separator" />
|
||||
|
||||
<DropdownMenu.Group className="dropdown-menu__group">
|
||||
{items.map(
|
||||
(item) =>
|
||||
item.show !== false && (
|
||||
<DropdownMenu.Item
|
||||
key={item.label}
|
||||
aria-label={item.label}
|
||||
onSelect={item.onClick}
|
||||
className={`dropdown-menu__item ${item.disabled ? "dropdown-menu__item--disabled" : ""}`}
|
||||
disabled={item.disabled}
|
||||
>
|
||||
{item.icon && (
|
||||
<div className="dropdown-menu__item-icon">{item.icon}</div>
|
||||
)}
|
||||
{item.label}
|
||||
</DropdownMenu.Item>
|
||||
)
|
||||
<DropdownMenuPrimitive.Portal>
|
||||
<DropdownMenuPrimitive.Content
|
||||
sideOffset={sideOffset}
|
||||
side={side}
|
||||
loop={loop}
|
||||
align={align}
|
||||
alignOffset={alignOffset}
|
||||
className="dropdown-menu__content"
|
||||
>
|
||||
{title && (
|
||||
<DropdownMenuPrimitive.Group className="dropdown-menu__group">
|
||||
<div className="dropdown-menu__title-bar">{title}</div>
|
||||
</DropdownMenuPrimitive.Group>
|
||||
)}
|
||||
</DropdownMenu.Group>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Portal>
|
||||
</DropdownMenu.Root>
|
||||
);
|
||||
|
||||
<DropdownMenuPrimitive.Separator className="dropdown-menu__separator" />
|
||||
|
||||
<DropdownMenuPrimitive.Group className="dropdown-menu__group">
|
||||
{items.map(
|
||||
(item) =>
|
||||
item.show !== false && (
|
||||
<DropdownMenuPrimitive.Item
|
||||
key={item.label}
|
||||
aria-label={item.label}
|
||||
onSelect={item.onClick}
|
||||
className={`dropdown-menu__item ${item.disabled ? "dropdown-menu__item--disabled" : ""}`}
|
||||
disabled={item.disabled}
|
||||
>
|
||||
{item.icon && (
|
||||
<div className="dropdown-menu__item-icon">
|
||||
{item.icon}
|
||||
</div>
|
||||
)}
|
||||
{item.label}
|
||||
</DropdownMenuPrimitive.Item>
|
||||
)
|
||||
)}
|
||||
</DropdownMenuPrimitive.Group>
|
||||
</DropdownMenuPrimitive.Content>
|
||||
</DropdownMenuPrimitive.Portal>
|
||||
</DropdownMenuPrimitive.Root>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,7 @@ import * as styles from "./download-group.css";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { SPACING_UNIT, vars } from "@renderer/theme.css";
|
||||
import { useMemo } from "react";
|
||||
import DropdownMenu, {
|
||||
DropdownMenuItem,
|
||||
} from "@renderer/components/dropdown-menu/dropdown-menu";
|
||||
import { DropdownMenu, DropdownMenuItem } from "@renderer/components/dropdown-menu/dropdown-menu";
|
||||
import { ThreeBarsIcon } from "@primer/octicons-react";
|
||||
|
||||
export interface DownloadGroupProps {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue