From f30b459dfbc2b820f451108065a7414ee6df94cf Mon Sep 17 00:00:00 2001 From: Dani Moreno Date: Thu, 16 Jan 2025 16:06:59 +0100 Subject: [PATCH] drawer --- .../Information/Headers/BaseHeader/index.tsx | 4 +- .../Information/Headers/Metadata/index.tsx | 28 ++++++++++-- .../Navigation/Dropdown/index.tsx | 44 +++++++++++++------ lib/ui/drawer.tsx | 4 +- lib/ui/dropdown-menu.tsx | 2 +- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/lib/experimental/Information/Headers/BaseHeader/index.tsx b/lib/experimental/Information/Headers/BaseHeader/index.tsx index 0131d7094..4a7e50b58 100644 --- a/lib/experimental/Information/Headers/BaseHeader/index.tsx +++ b/lib/experimental/Information/Headers/BaseHeader/index.tsx @@ -84,7 +84,7 @@ export function BaseHeader({
{metadata && }
-
+
{primaryAction && ( <>
@@ -107,7 +107,7 @@ export function BaseHeader({ )} {primaryAction && (secondaryActions || otherActions) && ( -
+
)} {secondaryActions && secondaryActions.map((action) => ( diff --git a/lib/experimental/Information/Headers/Metadata/index.tsx b/lib/experimental/Information/Headers/Metadata/index.tsx index 49292bac8..425ef1ecd 100644 --- a/lib/experimental/Information/Headers/Metadata/index.tsx +++ b/lib/experimental/Information/Headers/Metadata/index.tsx @@ -8,6 +8,7 @@ import { StatusTag, StatusVariant, } from "@/experimental/Information/Tags/StatusTag" +import { MobileDropdown } from "@/experimental/Navigation/Dropdown" import { Tooltip } from "@/experimental/Overlays/Tooltip" import { cn } from "@/lib/utils" import { AnimatePresence, motion } from "framer-motion" @@ -53,6 +54,7 @@ function renderMetadataValue(item: MetadataItem) { function MetadataItem({ item }: { item: MetadataItem }) { const [isActive, setIsActive] = useState(false) const isAction = item.actions?.length + const metadataValue = renderMetadataValue(item) return (
@@ -68,9 +70,29 @@ function MetadataItem({ item }: { item: MetadataItem }) { onBlur={() => isAction && setIsActive(false)} className="relative flex h-5 w-fit items-center hover:cursor-default" > -
- {renderMetadataValue(item)} +
+ {metadataValue}
+ {isAction && ( +
+ ({ + label: action.label, + icon: action.icon, + onClick: action.onClick, + })) ?? [] + } + > + {metadataValue} + +
+ )} {isActive && isAction && (
- {renderMetadataValue(item)} + {metadataValue}
{isAction && ( { export function Dropdown({ items, - icon = Ellipsis, + icon = EllipsisHorizontal, size, children, }: DropdownProps) { @@ -89,7 +88,7 @@ export function Dropdown({ /> )} - + {items.map((item, index) => item === "separator" ? ( @@ -121,10 +120,13 @@ export const MobileDropdown = ({ items, children }: DropdownProps) => { -
+
{items.map((item, index) => item === "separator" ? ( - +
) : item.href ? ( { ) : ( - ) )}
diff --git a/lib/ui/drawer.tsx b/lib/ui/drawer.tsx index 81af574e8..d496195c9 100644 --- a/lib/ui/drawer.tsx +++ b/lib/ui/drawer.tsx @@ -41,12 +41,12 @@ const DrawerContent = React.forwardRef< -
+
{children} diff --git a/lib/ui/dropdown-menu.tsx b/lib/ui/dropdown-menu.tsx index d07aaa89f..b9b7685ca 100644 --- a/lib/ui/dropdown-menu.tsx +++ b/lib/ui/dropdown-menu.tsx @@ -82,7 +82,7 @@ const DropdownMenuItem = React.forwardRef<