Skip to content

Commit

Permalink
chore(DropdownMenu): use Portal component from @headlessui/react
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaakher committed May 21, 2024
1 parent aa4f81f commit 77b3ff2
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 9 deletions.
7 changes: 7 additions & 0 deletions apps/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# hawa-docs

## 0.0.68

### Patch Changes

- Updated dependencies
- @sikka/hawa@0.35.4

## 0.0.67

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawa-docs",
"version": "0.0.67",
"version": "0.0.68",
"private": true,
"scripts": {
"dev": "next dev -p 3001",
Expand Down
6 changes: 6 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sikka/hawa

## 0.35.4

### Patch Changes

- Use the `Portal` component from `@headlessui/react` in `DropdownMenu`

## 0.35.3

### Patch Changes
Expand Down
15 changes: 9 additions & 6 deletions packages/components/elements/dropdownMenu/DropdownMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as React from "react";

import { Portal } from "@headlessui/react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import { cn } from "@util/index";

import { DirectionType, RadioOptionType } from "../../types/commonTypes";

// New import

const DropdownMenuRoot = DropdownMenuPrimitive.Root;
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
Expand Down Expand Up @@ -70,7 +73,7 @@ const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<DropdownMenuPrimitive.Portal>
<Portal>
<DropdownMenuPrimitive.Content
ref={ref}
sideOffset={sideOffset}
Expand All @@ -80,7 +83,7 @@ const DropdownMenuContent = React.forwardRef<
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
</Portal>
));
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;

Expand Down Expand Up @@ -355,7 +358,7 @@ const DropdownMenu: React.FC<DropdownMenuProps> = ({
>
{trigger}
</DropdownMenuTrigger>
<DropdownMenuPortal>
<Portal>
<DropdownMenuContent
side={side}
sideOffset={sideOffset}
Expand Down Expand Up @@ -427,7 +430,7 @@ const DropdownMenu: React.FC<DropdownMenuProps> = ({
{item.icon && item.icon}
{item.label && item.label}
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<Portal>
<DropdownMenuSubContent>
{item.subitems.map((subitem, subIndex) => {
const SubitemLinkComponent = subitem.slug
Expand Down Expand Up @@ -469,7 +472,7 @@ const DropdownMenu: React.FC<DropdownMenuProps> = ({
);
})}
</DropdownMenuSubContent>
</DropdownMenuPortal>
</Portal>
</DropdownMenuSub>
) : (
<DropdownMenuItem
Expand Down Expand Up @@ -526,7 +529,7 @@ const DropdownMenu: React.FC<DropdownMenuProps> = ({
}
})}
</DropdownMenuContent>
</DropdownMenuPortal>
</Portal>
</DropdownMenuRoot>
);
};
Expand Down
3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sikka/hawa",
"version": "0.35.3",
"version": "0.35.4",
"description": "Modern UI Kit made with Tailwind",
"author": {
"name": "Sikka Software",
Expand Down Expand Up @@ -57,6 +57,7 @@
"react-dom": "18.3.1"
},
"dependencies": {
"@headlessui/react": "^2.0.3",
"@hookform/resolvers": "^3.4.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-checkbox": "^1.0.4",
Expand Down
7 changes: 7 additions & 0 deletions packages/storybook/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# hawa-storybook

## 0.26.89

### Patch Changes

- Updated dependencies
- @sikka/hawa@0.35.4

## 0.26.88

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawa-storybook",
"version": "0.26.88",
"version": "0.26.89",
"description": "Modern UI Kit made with Tailwind",
"author": {
"name": "Sikka Software",
Expand Down
138 changes: 138 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 77b3ff2

Please sign in to comment.