Skip to content

Commit f891aa7

Browse files
committed
Merge branch 'main' of github.com:ariflogs/retroui
2 parents 5c98859 + bc68f37 commit f891aa7

File tree

13 files changed

+327
-8
lines changed

13 files changed

+327
-8
lines changed

app/(sink)/demo/components/page.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Avatar,
77
Badge,
88
Button,
9+
Menu,
910
Tabs,
1011
TabsContent,
1112
TabsPanels,
@@ -99,6 +100,21 @@ export default function page() {
99100
</div>
100101
</Alert>
101102
</div>
103+
104+
<div>
105+
<Menu>
106+
<Menu.Trigger asChild>
107+
<Button>Menu</Button>
108+
</Menu.Trigger>
109+
<Menu.Content className="min-w-36">
110+
<Menu.Item>Menu Item 1</Menu.Item>
111+
<Menu.Item>Menu Item 2</Menu.Item>
112+
<Menu.Item>Menu Item 3</Menu.Item>
113+
</Menu.Content>
114+
</Menu>
115+
</div>
116+
117+
<div className="h-36"></div>
102118
</div>
103119
);
104120
}

config/components.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ export const componentConfig = {
2626
name: "card",
2727
filePath: "packages/ui/Cards/Card.tsx",
2828
},
29-
text: {
30-
name: "text",
31-
filePath: "packages/ui/Text/Text.tsx",
32-
},
29+
3330
dialog: {
3431
name: "dialog",
3532
filePath: "packages/ui/Dialog/Dialog.tsx",
3633
},
34+
menu: {
35+
name: "menu",
36+
filePath: "packages/ui/Menu/Menu.tsx",
37+
},
38+
text: {
39+
name: "text",
40+
filePath: "packages/ui/Text/Text.tsx",
41+
},
3742
},
3843
examples: {
3944
"accordion-style-default": {
@@ -134,6 +139,11 @@ export const componentConfig = {
134139
filePath: "preview/components/input-style-default.tsx",
135140
preview: lazy(() => import("@/preview/components/input-style-default")),
136141
},
142+
"menu-style-default": {
143+
name: "menu-style-default",
144+
filePath: "preview/components/menu-style-default.tsx",
145+
preview: lazy(() => import("@/preview/components/menu-style-default")),
146+
},
137147
"textarea-style-default": {
138148
name: "textarea-style-default",
139149
filePath: "preview/components/textarea-style-default.tsx",

config/navigation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ export const navConfig: INavigationConfig = {
2222
{ title: "Badge", href: `${componentsRoute}/badge` },
2323
{ title: "Button", href: `${componentsRoute}/button` },
2424
{ title: "Card", href: `${componentsRoute}/card` },
25+
{ title: "Dialog", href: `${componentsRoute}/dialog` },
2526
{ title: "Input", href: `${componentsRoute}/input` },
27+
{ title: "Menu", href: `${componentsRoute}/menu` },
2628
{ title: "Tab", href: `${componentsRoute}/tab` },
2729
{ title: "Textarea", href: `${componentsRoute}/textarea` },
2830
{ title: "Text", href: `${componentsRoute}/text` },
29-
{ title: "Dialog", href: `${componentsRoute}/dialog` },
3031
],
3132
},
3233
{

content/docs/components/menu.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: Menu
3+
description: Show your users a list of actions they can take. 📋
4+
lastUpdated: 19 Oct, 2024
5+
links:
6+
api_reference: https://www.radix-ui.com/primitives/docs/components/dropdown-menu#api-reference
7+
source: https://github.com/Logging-Stuff/RetroUI/blob/main/packages/ui/Menu/Menu.tsx
8+
---
9+
10+
<ComponentShowcase name="menu-style-default" />
11+
<br />
12+
<br />
13+
14+
## Installation
15+
16+
#### 1. Install dependencies:
17+
18+
```sh
19+
npm install @radix-ui/react-dropdown-menu
20+
```
21+
22+
<br />
23+
24+
#### 2. Copy the code 👇 into your project:
25+
26+
<ComponentSource name="menu" />
27+
28+
<br />
29+
<br />
30+
31+
## Examples
32+
33+
### Default
34+
35+
<ComponentShowcase name="menu-style-default" />

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@radix-ui/react-accordion": "^1.2.1",
1414
"@radix-ui/react-avatar": "^1.1.1",
1515
"@radix-ui/react-dialog": "^1.1.2",
16+
"@radix-ui/react-dropdown-menu": "^2.1.2",
1617
"@radix-ui/react-visually-hidden": "^1.1.0",
1718
"class-variance-authority": "^0.7.0",
1819
"clsx": "^2.1.1",

packages/ui/Buttons/Button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { cn } from "@/lib/utils";
22
import { cva, VariantProps } from "class-variance-authority";
33
import React, { ButtonHTMLAttributes } from "react";
44

5-
const buttonVariants = cva("font-head transition-all", {
5+
const buttonVariants = cva("font-head transition-all outline-none", {
66
variants: {
77
variant: {
88
default:
@@ -39,6 +39,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProps>(
3939
forwardedRef
4040
) => (
4141
<button
42+
ref={forwardedRef}
4243
className={cn(buttonVariants({ variant, size }), className)}
4344
{...props}
4445
>

packages/ui/Cards/Card.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { cn } from "@/lib/utils";
22
import { HTMLAttributes } from "react";
33
import { Text } from "../Text";
4-
import { Content } from "next/font/google";
54

65
interface ICardProps extends HTMLAttributes<HTMLDivElement> {
76
className?: string;

packages/ui/Menu/Menu.tsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"use client";
2+
3+
import { cn } from "@/lib/utils";
4+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
5+
import React, { ComponentPropsWithoutRef, HTMLAttributes } from "react";
6+
7+
const Menu = DropdownMenu.Root;
8+
const Trigger = DropdownMenu.Trigger;
9+
10+
interface IMenuContent
11+
extends ComponentPropsWithoutRef<typeof DropdownMenu.Content> {}
12+
13+
const Content = ({ className, ...props }: IMenuContent) => (
14+
<DropdownMenu.Portal>
15+
<DropdownMenu.Content
16+
side="bottom"
17+
align="start"
18+
className={cn(
19+
"bg-white border-2 border-black shadow-md absolute top-2 min-w-20",
20+
className
21+
)}
22+
{...props}
23+
/>
24+
</DropdownMenu.Portal>
25+
);
26+
27+
const MenuItem = React.forwardRef<
28+
HTMLDivElement,
29+
ComponentPropsWithoutRef<typeof DropdownMenu.Item>
30+
>(({ className, ...props }, ref) => (
31+
<DropdownMenu.Item
32+
ref={ref}
33+
className={cn(
34+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-primary-400 hover:text-white focus:bg-primary-400 focus:text-white data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
35+
className
36+
)}
37+
{...props}
38+
/>
39+
));
40+
MenuItem.displayName = "MenuItem";
41+
42+
const MenuComponent = Object.assign(Menu, {
43+
Trigger,
44+
Content,
45+
Item: MenuItem,
46+
});
47+
48+
export { MenuComponent as Menu };

packages/ui/Menu/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./Menu";

packages/ui/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export * from "./Avatars";
88
export * from "./Badges";
99
export * from "./Tabs";
1010
export * from "./Dialog";
11+
export * from "./Menu";

0 commit comments

Comments
 (0)