Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:

- name: Build and push to DockerHub
run: |
docker build -t devarifhossain/retroui:1.0.7 ./
docker push devarifhossain/retroui:1.0.7
docker build -t devarifhossain/retroui:1.0.8 ./
docker push devarifhossain/retroui:1.0.8
Comment on lines +27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider automating version management.

Instead of hardcoding the version, consider deriving it from the GitHub release tag to prevent version mismatches and reduce manual updates.

-          docker build -t devarifhossain/retroui:1.0.8 ./
-          docker push devarifhossain/retroui:1.0.8
+          VERSION=${GITHUB_REF#refs/tags/v}
+          docker build -t devarifhossain/retroui:$VERSION ./
+          docker push devarifhossain/retroui:$VERSION
+          docker tag devarifhossain/retroui:$VERSION devarifhossain/retroui:latest
+          docker push devarifhossain/retroui:latest
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker build -t devarifhossain/retroui:1.0.8 ./
docker push devarifhossain/retroui:1.0.8
VERSION=${GITHUB_REF#refs/tags/v}
docker build -t devarifhossain/retroui:$VERSION ./
docker push devarifhossain/retroui:$VERSION
docker tag devarifhossain/retroui:$VERSION devarifhossain/retroui:latest
docker push devarifhossain/retroui:latest


- name: Set up SSH
uses: webfactory/ssh-agent@v0.9.0
Expand Down
20 changes: 11 additions & 9 deletions app/(marketing)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
Textarea,
} from "@/packages/ui";
import AccordionStyleDefault from "@/preview/components/accordion-style-default";
import AvatarStyleCircleSizes from "@/preview/components/avatar-style-circle-sizes";
import BadgeStyleVariants from "@/preview/components/badge-style-variants";
import { GithubIcon, MessageCircle } from "lucide-react";
import Image from "next/image";
Expand Down Expand Up @@ -64,10 +65,13 @@ export default function Home() {
Our components look both old school and modern! ✨
</Text>

<div className="grid gap-4 grid-cols-2 lg:grid-cols-4 mb-8">
<div className="grid gap-8 grid-cols-1 lg:grid-cols-2 mb-8">
<div className="space-y-4">
<Text as="h4">Button</Text>
<Button>Click Me</Button>
<div className="flex space-x-4">
<Button>Click Me</Button>
<Button variant="outline">Click Me</Button>
</div>
</div>
<div className="space-y-4">
<Text as="h4">Badge</Text>
Expand All @@ -77,22 +81,20 @@ export default function Home() {
</div>
<div className="space-y-4">
<Text as="h4">Avatar</Text>
<Avatar />
<AvatarStyleCircleSizes />
</div>
<div className="space-y-4">
<Text as="h4">Basic Card</Text>
<BasicCard />
</div>
<div className="space-y-4">
<Text as="h4">Input</Text>
<Input />
</div>
</div>
<div className="grid gap-8 grid-cols-1 lg:grid-cols-3">
<div className="space-y-4">
<Text as="h4">Textarea</Text>
<Textarea />
</div>
<div className="space-y-4">
<Text as="h4">Basic Card</Text>
<BasicCard />
</div>
<div className="space-y-4">
<Text as="h4">Accordion</Text>
<AccordionStyleDefault />
Expand Down
16 changes: 16 additions & 0 deletions app/(sink)/demo/components/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Avatar,
Badge,
Button,
Menu,
Tabs,
TabsContent,
TabsPanels,
Expand Down Expand Up @@ -99,6 +100,21 @@ export default function page() {
</div>
</Alert>
</div>

<div>
<Menu>
<Menu.Trigger asChild>
<Button>Menu</Button>
</Menu.Trigger>
<Menu.Content className="min-w-36">
<Menu.Item>Menu Item 1</Menu.Item>
<Menu.Item>Menu Item 2</Menu.Item>
<Menu.Item>Menu Item 3</Menu.Item>
</Menu.Content>
</Menu>
</div>
Comment on lines +104 to +115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance Menu accessibility and user experience

While the basic implementation works, consider these improvements:

  1. Add an aria-label to the Menu button
  2. Include visual indicators for keyboard navigation
  3. Add descriptions to menu items for better context
  4. Consider adding error boundaries

Here's a suggested implementation:

 <Menu>
   <Menu.Trigger asChild>
-    <Button>Menu</Button>
+    <Button aria-label="Open menu options">Menu</Button>
   </Menu.Trigger>
-  <Menu.Content className="min-w-36">
+  <Menu.Content className="min-w-36" aria-label="Menu options">
-    <Menu.Item>Menu Item 1</Menu.Item>
-    <Menu.Item>Menu Item 2</Menu.Item>
-    <Menu.Item>Menu Item 3</Menu.Item>
+    <Menu.Item>
+      <span className="font-medium">Menu Item 1</span>
+      <span className="text-sm text-gray-500 ml-2">Description</span>
+    </Menu.Item>
+    <Menu.Item>
+      <span className="font-medium">Menu Item 2</span>
+      <span className="text-sm text-gray-500 ml-2">Description</span>
+    </Menu.Item>
+    <Menu.Item>
+      <span className="font-medium">Menu Item 3</span>
+      <span className="text-sm text-gray-500 ml-2">Description</span>
+    </Menu.Item>
   </Menu.Content>
 </Menu>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div>
<Menu>
<Menu.Trigger asChild>
<Button>Menu</Button>
</Menu.Trigger>
<Menu.Content className="min-w-36">
<Menu.Item>Menu Item 1</Menu.Item>
<Menu.Item>Menu Item 2</Menu.Item>
<Menu.Item>Menu Item 3</Menu.Item>
</Menu.Content>
</Menu>
</div>
<div>
<Menu>
<Menu.Trigger asChild>
<Button aria-label="Open menu options">Menu</Button>
</Menu.Trigger>
<Menu.Content className="min-w-36" aria-label="Menu options">
<Menu.Item>
<span className="font-medium">Menu Item 1</span>
<span className="text-sm text-gray-500 ml-2">Description</span>
</Menu.Item>
<Menu.Item>
<span className="font-medium">Menu Item 2</span>
<span className="text-sm text-gray-500 ml-2">Description</span>
</Menu.Item>
<Menu.Item>
<span className="font-medium">Menu Item 3</span>
<span className="text-sm text-gray-500 ml-2">Description</span>
</Menu.Item>
</Menu.Content>
</Menu>
</div>


<div className="h-36"></div>
</div>
);
}
18 changes: 14 additions & 4 deletions config/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ export const componentConfig = {
name: "card",
filePath: "packages/ui/Cards/Card.tsx",
},
text: {
name: "text",
filePath: "packages/ui/Text/Text.tsx",
},

dialog: {
name: "dialog",
filePath: "packages/ui/Dialog/Dialog.tsx",
},
menu: {
name: "menu",
filePath: "packages/ui/Menu/Menu.tsx",
},
text: {
name: "text",
filePath: "packages/ui/Text/Text.tsx",
},
},
examples: {
"accordion-style-default": {
Expand Down Expand Up @@ -134,6 +139,11 @@ export const componentConfig = {
filePath: "preview/components/input-style-default.tsx",
preview: lazy(() => import("@/preview/components/input-style-default")),
},
"menu-style-default": {
name: "menu-style-default",
filePath: "preview/components/menu-style-default.tsx",
preview: lazy(() => import("@/preview/components/menu-style-default")),
},
Comment on lines +142 to +146
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Found several name-path mismatches in component examples

Several components have inconsistent name properties that don't match their file paths:

  • avatar-style-fallbacks points to avatar-style-circle-fallbacks.tsx
  • badge-style-default is duplicated and points to badge-style-rounded.tsx
  • button-style-default is duplicated and points to button-style-outline.tsx
  • typography-p points to tab-style-default.tsx

These mismatches could cause confusion and should be corrected to maintain consistency throughout the codebase.

🔗 Analysis chain

LGTM! New menu example follows the established pattern.

The configuration is correctly structured with proper lazy loading implementation.

I noticed some examples might have incorrect name properties. Let's verify:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for mismatches between example names and their file paths

# Extract examples with potential name mismatches
rg -A 2 'name: ".+?".*\n.*filePath: "preview/components/(.+?)\.tsx"' | \
grep -E 'name:|filePath:' | \
awk '{
    if($1=="name:") name=substr($2,2,length($2)-3);
    if($1=="filePath:") {
        split($2,path,"/");
        file=substr(path[3],1,length(path[3])-5);
        if(name!=file) printf "Mismatch - Name: %s, File: %s\n",name,file;
    }
}'

Length of output: 539


Script:

#!/bin/bash
# Let's try a different approach using ripgrep's multiline mode
rg -U --multiline '^.*"name": "([^"]+)".*\n.*"filePath": "preview/components/([^"]+)\.tsx"' config/components.ts | \
while IFS= read -r line; do
    name=$(echo "$line" | grep -o '"name": "[^"]*"' | cut -d'"' -f4)
    file=$(echo "$line" | grep -o '"filePath": "[^"]*"' | cut -d'"' -f4 | awk -F'/' '{print $NF}' | sed 's/\.tsx$//')
    if [ "$name" != "$file" ]; then
        echo "Mismatch - Name: $name, File: $file"
    fi
done

Length of output: 136


Script:

#!/bin/bash
# Let's simplify and try a different approach
rg -A1 'name:' config/components.ts | \
grep -E '(name:|filePath:)' | \
sed 's/[",]//g' | \
sed 's/^ *//'

Length of output: 2736

"textarea-style-default": {
name: "textarea-style-default",
filePath: "preview/components/textarea-style-default.tsx",
Expand Down
3 changes: 2 additions & 1 deletion config/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ export const navConfig: INavigationConfig = {
{ title: "Badge", href: `${componentsRoute}/badge` },
{ title: "Button", href: `${componentsRoute}/button` },
{ title: "Card", href: `${componentsRoute}/card` },
{ title: "Dialog", href: `${componentsRoute}/dialog` },
{ title: "Input", href: `${componentsRoute}/input` },
{ title: "Menu", href: `${componentsRoute}/menu` },
{ title: "Tab", href: `${componentsRoute}/tab` },
{ title: "Textarea", href: `${componentsRoute}/textarea` },
{ title: "Text", href: `${componentsRoute}/text` },
{ title: "Dialog", href: `${componentsRoute}/dialog` },
],
},
{
Expand Down
35 changes: 35 additions & 0 deletions content/docs/components/menu.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Menu
description: Show your users a list of actions they can take. 📋
lastUpdated: 19 Oct, 2024
links:
api_reference: https://www.radix-ui.com/primitives/docs/components/dropdown-menu#api-reference
source: https://github.com/Logging-Stuff/RetroUI/blob/main/packages/ui/Menu/Menu.tsx
---

<ComponentShowcase name="menu-style-default" />
<br />
<br />

## Installation

#### 1. Install dependencies:

```sh
npm install @radix-ui/react-dropdown-menu
```

<br />

#### 2. Copy the code 👇 into your project:

<ComponentSource name="menu" />

<br />
<br />

## Examples

### Default

<ComponentShowcase name="menu-style-default" />
Comment on lines +31 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the examples section.

Consider adding:

  1. Description of what the default example demonstrates
  2. More examples showing different use cases (e.g., nested menus, custom triggers, keyboard navigation)
  3. Code snippets showing how to implement each example

Would you like me to help generate additional example code and documentation for common use cases?

2 changes: 1 addition & 1 deletion infra/docker-compose.prod.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
web:
image: devarifhossain/retroui:1.0.7
image: devarifhossain/retroui:1.0.8
container_name: retroui
expose:
- "3000"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@radix-ui/react-accordion": "^1.2.1",
"@radix-ui/react-avatar": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-visually-hidden": "^1.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/Buttons/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cn } from "@/lib/utils";
import { cva, VariantProps } from "class-variance-authority";
import React, { ButtonHTMLAttributes } from "react";

const buttonVariants = cva("font-head transition-all", {
const buttonVariants = cva("font-head transition-all outline-none", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure focus visibility for accessibility.

While removing the default outline, make sure to maintain a visible focus indicator for keyboard navigation. Consider adding a custom focus style using :focus-visible for better accessibility.

-const buttonVariants = cva("font-head transition-all outline-none", {
+const buttonVariants = cva("font-head transition-all outline-none focus-visible:ring-2 focus-visible:ring-primary-400 focus-visible:ring-offset-2", {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const buttonVariants = cva("font-head transition-all outline-none", {
const buttonVariants = cva("font-head transition-all outline-none focus-visible:ring-2 focus-visible:ring-primary-400 focus-visible:ring-offset-2", {

variants: {
variant: {
default:
Expand Down Expand Up @@ -39,6 +39,7 @@ export const Button = React.forwardRef<HTMLButtonElement, IButtonProps>(
forwardedRef
) => (
<button
ref={forwardedRef}
className={cn(buttonVariants({ variant, size }), className)}
{...props}
>
Expand Down
1 change: 0 additions & 1 deletion packages/ui/Cards/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { cn } from "@/lib/utils";
import { HTMLAttributes } from "react";
import { Text } from "../Text";
import { Content } from "next/font/google";

interface ICardProps extends HTMLAttributes<HTMLDivElement> {
className?: string;
Expand Down
48 changes: 48 additions & 0 deletions packages/ui/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use client";

import { cn } from "@/lib/utils";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
import React, { ComponentPropsWithoutRef, HTMLAttributes } from "react";

const Menu = DropdownMenu.Root;
const Trigger = DropdownMenu.Trigger;

interface IMenuContent
extends ComponentPropsWithoutRef<typeof DropdownMenu.Content> {}

const Content = ({ className, ...props }: IMenuContent) => (
<DropdownMenu.Portal>
<DropdownMenu.Content
side="bottom"
align="start"
className={cn(
"bg-white border-2 border-black shadow-md absolute top-2 min-w-20",
className
)}
{...props}
/>
</DropdownMenu.Portal>
);

const MenuItem = React.forwardRef<
HTMLDivElement,
ComponentPropsWithoutRef<typeof DropdownMenu.Item>
>(({ className, ...props }, ref) => (
<DropdownMenu.Item
ref={ref}
className={cn(
"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",
className
)}
{...props}
/>
));
MenuItem.displayName = "MenuItem";

const MenuComponent = Object.assign(Menu, {
Trigger,
Content,
Item: MenuItem,
});

export { MenuComponent as Menu };
1 change: 1 addition & 0 deletions packages/ui/Menu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Menu";
1 change: 1 addition & 0 deletions packages/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./Avatars";
export * from "./Badges";
export * from "./Tabs";
export * from "./Dialog";
export * from "./Menu";
Loading