Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New components #1007

Merged
merged 11 commits into from
Sep 20, 2024
Merged

New components #1007

merged 11 commits into from
Sep 20, 2024

Conversation

John-Paul-Larkin
Copy link
Member

✨ Codu Pull Request 💻

  • Disable husky pre commit linting. husky has not been removed, the command has been commented out.

  • Remove Catalyst components from Alpha

  • Add all Catalyst components to components>catalyst

@John-Paul-Larkin John-Paul-Larkin requested a review from a team as a code owner September 9, 2024 16:51
Copy link

vercel bot commented Sep 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
codu ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2024 9:43am

Copy link
Contributor

coderabbitai bot commented Sep 9, 2024

Walkthrough

This pull request introduces a variety of new React components and modifies existing ones to enhance the UI component library. Key changes include restructuring import paths, creating customizable components for alerts, avatars, badges, checkboxes, and more, while also implementing responsive layouts such as sidebars and navigation bars. Additionally, modifications to the Husky pre-commit hook script disable linting checks during commits, potentially impacting code quality assurance.

Changes

File(s) Change Summary
.husky/pre-commit Commented out lines to disable linting checks during the pre-commit phase.
app/(app)/alpha/additional-details/_client.tsx Updated import paths from relative to absolute, reflecting new directory structure.
components/ui-components/alert.tsx Added customizable alert dialog components using Headless UI.
components/ui-components/avatar.tsx Introduced Avatar and AvatarButton components for user images.
components/ui-components/badge.tsx Implemented Badge and BadgeButton components with customizable colors.
components/ui-components/checkbox.tsx Created CheckboxGroup, CheckboxField, and Checkbox components for checkboxes.
components/ui-components/description-list.tsx Added DescriptionList, DescriptionTerm, and DescriptionDetails components for semantic HTML.
components/ui-components/dialog.tsx Introduced Dialog components for customizable dialog interfaces.
components/ui-components/dropdown.tsx Implemented a comprehensive dropdown component with various subcomponents.
components/ui-components/listbox.tsx Created Listbox component for selecting options from a dropdown list.
components/ui-components/navbar.tsx Added responsive Navbar component with subcomponents for navigation.
components/ui-components/pagination.tsx Introduced Pagination components for navigation through pages.
components/ui-components/radio.tsx Implemented RadioGroup, RadioField, and Radio components for radio button interfaces.
components/ui-components/sidebar-layout.tsx Created SidebarLayout component for responsive sidebar navigation.
components/ui-components/sidebar.tsx Added Sidebar component with various subcomponents for layout and navigation.
components/ui-components/stacked-layout.tsx Introduced StackedLayout component for mobile-friendly sidebar and navbar.
components/ui-components/switch.tsx Implemented SwitchGroup, SwitchField, and Switch components for toggle functionality.
components/ui-components/table.tsx Added Table components with context-aware properties for flexible table structures.
components/ui-components/textarea.tsx Created customizable Textarea component with resizable options.

Possibly related PRs

  • Refactor/onboarding form #992: The changes in this PR involve modifications to the app/(app)/alpha/additional-details/_client.tsx file, which includes updates to the structure and usage of components, similar to the changes made in the main PR regarding import paths and component organization.

Poem

🐇 In the garden of code, changes bloom bright,
New components sprout, a delightful sight.
Alerts and avatars, badges in tow,
With checkboxes and dropdowns, watch the UI grow!
A sidebar to guide, a navbar to cheer,
In this world of React, let’s hop without fear! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 13

Outside diff range, codebase verification and nitpick comments (2)
components/Catalyst/sidebar-layout.tsx (1)

51-92: Missing CSS Class Definitions in SidebarLayout Component

The following CSS classes used in the SidebarLayout component are not found in the codebase: isolate, min-h-svh, max-lg:flex-col, lg:bg-zinc-100, and dark:lg:bg-zinc-950. Please verify their definitions or add them to ensure the component is styled correctly.

  • Missing Classes: isolate, min-h-svh, max-lg:flex-col, lg:bg-zinc-100, dark:lg:bg-zinc-950
Analysis chain

Component Structure and State Management are Correct

The SidebarLayout component is well-structured with appropriate use of React state for managing sidebar visibility. Verify the CSS classes for correctness and ensure they are defined properly in the project's stylesheets.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify CSS classes in SidebarLayout component.

# Test: Search for CSS classes related to layout. Expect: Proper usage and definitions in CSS files.
rg --type css "relative|isolate|flex|min-h-svh|bg-white|dark:bg-zinc-900|max-lg:flex-col|lg:bg-zinc-100|dark:lg:bg-zinc-950"

Length of output: 2230


Script:

#!/bin/bash
# Description: Search for missing CSS classes in the entire codebase.

# Test: Search for missing CSS classes. Expect: Definitions in CSS or JS files.
rg --type css --type js "relative|isolate|min-h-svh|max-lg:flex-col|lg:bg-zinc-100|dark:lg:bg-zinc-950"

Length of output: 190

components/Catalyst/sidebar.tsx (1)

112-198: Ensure ARIA roles and attributes for accessibility in Sidebar components

The SidebarLabel and related components in components/Catalyst/sidebar.tsx currently lack comprehensive ARIA roles and attributes, which are essential for accessibility. Consider reviewing these components to ensure that appropriate ARIA roles and attributes are applied, especially for interactive elements. This will enhance accessibility for users relying on assistive technologies.

  • Ensure ARIA roles and attributes are consistently applied in SidebarLabel and related components.
Analysis chain

Ensure accessibility and consistency in SidebarLabel and related components.

While the SidebarLabel and related components are implemented effectively, ensure that accessibility considerations such as ARIA roles and attributes are consistently applied, especially in components that involve interactive elements or complex layouts.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent accessibility attributes in Sidebar components.

# Test: Search for ARIA roles and attributes in Sidebar components.
rg --type typescript -A 5 $'aria-|role'

Length of output: 75


Script:

#!/bin/bash
# Description: Check for consistent accessibility attributes in Sidebar components.

# Test: Search for ARIA roles and attributes in .tsx files.
rg --glob '*.tsx' -A 5 'aria-|role'

Length of output: 48191

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c04dcd7 and 27776b2.

Files selected for processing (19)
  • .husky/pre-commit (1 hunks)
  • app/(app)/alpha/additional-details/_client.tsx (1 hunks)
  • components/Catalyst/alert.tsx (1 hunks)
  • components/Catalyst/avatar.tsx (1 hunks)
  • components/Catalyst/badge.tsx (1 hunks)
  • components/Catalyst/checkbox.tsx (1 hunks)
  • components/Catalyst/description-list.tsx (1 hunks)
  • components/Catalyst/dialog.tsx (1 hunks)
  • components/Catalyst/dropdown.tsx (1 hunks)
  • components/Catalyst/listbox.tsx (1 hunks)
  • components/Catalyst/navbar.tsx (1 hunks)
  • components/Catalyst/pagination.tsx (1 hunks)
  • components/Catalyst/radio.tsx (1 hunks)
  • components/Catalyst/sidebar-layout.tsx (1 hunks)
  • components/Catalyst/sidebar.tsx (1 hunks)
  • components/Catalyst/stacked-layout.tsx (1 hunks)
  • components/Catalyst/switch.tsx (1 hunks)
  • components/Catalyst/table.tsx (1 hunks)
  • components/Catalyst/textarea.tsx (1 hunks)
Files skipped from review due to trivial changes (2)
  • .husky/pre-commit
  • app/(app)/alpha/additional-details/_client.tsx
Additional comments not posted (51)
components/Catalyst/description-list.tsx (3)

3-12: Approved: Well-implemented DescriptionList component.

The DescriptionList component is correctly implemented with appropriate use of clsx for class name binding and props spreading on the <dl> element.


15-25: Approved: Consistent and correct implementation of DescriptionTerm.

The DescriptionTerm component follows the same pattern as DescriptionList, correctly applying clsx for dynamic class name management and props spreading on the <dt> element.


27-37: Approved: Correct implementation of DescriptionDetails.

The DescriptionDetails component is implemented consistently with the other components in this file, using clsx effectively for class name management and props spreading on the <dd> element.

components/Catalyst/textarea.tsx (1)

5-54: Approved: Advanced and flexible Textarea component implementation.

The Textarea component is well-implemented, utilizing forwardRef for ref forwarding and clsx for extensive conditional styling. The integration with Headless UI's Textarea and the handling of various UI states are commendable.

components/Catalyst/avatar.tsx (2)

15-51: Approved: Well-implemented Avatar component with good accessibility practices.

The Avatar component is flexible, supporting both text and image representations. It uses conditional styling effectively and includes accessibility features like aria-hidden for decorative elements. The implementation is robust and follows best practices.


53-84: Approved: Flexible AvatarButton component implementation.

The AvatarButton component is well-designed, capable of rendering as either a Link or a Button based on the props. This flexibility, combined with the correct use of forwardRef and conditional styling, makes it a robust component suitable for various use cases.

components/Catalyst/alert.tsx (2)

81-95: Enhance the AlertActions for better mobile responsiveness.

The AlertActions component uses flex properties that might not render well on all mobile devices. Consider testing this component on various devices to ensure that the layout remains consistent and functional.

Verification successful

Recommendation to Test AlertActions Component on Various Devices

The AlertActions component uses responsive design techniques, such as changing flex direction and element widths based on screen size. It is advisable to test this component on various devices to ensure that the layout remains consistent and functional across different screen sizes. This will help verify the effectiveness of the responsive design.

  • File: components/Catalyst/alert.tsx
  • Lines: 81-95
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the mobile responsiveness of the AlertActions component.

# Test: Search for flex properties and test on mobile devices.
rg --type typescript -A 5 $'AlertActions'

Length of output: 75


Script:

#!/bin/bash
# Use ast-grep to find the AlertActions function definition and inspect its implementation.
ast-grep --lang typescript --pattern $'export function AlertActions({ className, ...props }: React.ComponentPropsWithoutRef<\'div\'>) {
  $$$
}' --json

Length of output: 159


Script:

#!/bin/bash
# Use rg to search for the AlertActions function by name across the codebase.
rg 'function AlertActions' -A 5

Length of output: 387


Script:

#!/bin/bash
# Use rg to search for the complete implementation of the AlertActions function to inspect all applied classes.
rg 'export function AlertActions' -A 10 components/Catalyst/alert.tsx

Length of output: 376


18-51: Ensure accessibility and responsiveness in the Alert component.

The Alert component is well-structured with appropriate use of Headless UI components for accessibility. However, ensure that the responsive and accessibility features are tested across different devices and screen readers to maintain a high level of usability.

components/Catalyst/dialog.tsx (3)

18-51: Review the Dialog component for modularity and reusability.

The Dialog component is modular and uses Headless UI effectively. Ensure that it is reusable in various parts of the application without modifications.


88-107: Ensure DialogActions are flexible and responsive.

The DialogActions should be tested for responsiveness, especially in flex layouts that might behave differently on various screen sizes.

Verification successful

DialogActions Component Appears Responsive

The DialogActions component uses responsive utility classes, such as sm:flex-row and sm:*:w-auto, which suggest it is designed to adapt to different screen sizes. These classes indicate a default column layout that switches to a row layout on small screens, addressing the review comment's concern about responsiveness.

  • components/Catalyst/dialog.tsx: Lines 88-107
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the responsiveness of the DialogActions component.

# Test: Search for flex properties and test on various devices.
rg --type typescript -A 5 $'DialogActions'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the responsiveness of the DialogActions component.

# Corrected Test: Search for the DialogActions component in .tsx files and include additional context.
rg --type-add 'tsx:*.tsx' --type tsx -A 10 'DialogActions'

Length of output: 689


6-16: Consistency check: Ensure size definitions match across components.

The size definitions in the Dialog component should be consistent with those in the Alert component to maintain uniformity across the UI library.

components/Catalyst/stacked-layout.tsx (2)

51-89: Review the StackedLayout for overall responsiveness and modularity.

The StackedLayout is designed to be modular and responsive. Ensure that it functions correctly in different layouts and screen sizes.


23-49: Ensure MobileSidebar is accessible and responsive.

The MobileSidebar uses Headless UI components for accessibility, but ensure that it is fully accessible and responsive by testing on various devices and with screen readers.

Verification successful

MobileSidebar is accessible and responsive.

The MobileSidebar component includes ARIA attributes for accessibility and uses responsive design techniques such as the lg:hidden class to adapt to different screen sizes. These elements ensure that the component is both accessible and responsive.

  • ARIA attributes: aria-hidden, aria-label
  • Responsive design: lg:hidden class
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the accessibility and responsiveness of the MobileSidebar component.

# Test: Search for accessibility attributes and test on various devices.
rg --type typescript -A 5 $'MobileSidebar'

Length of output: 76


Script:

#!/bin/bash
# Corrected command to search for the MobileSidebar component in TypeScript files.
rg --type ts -A 10 'MobileSidebar' components/Catalyst/stacked-layout.tsx

Length of output: 926


Script:

#!/bin/bash
# Search for ARIA attributes and responsive design elements in the MobileSidebar component.
rg --type ts 'aria-' components/Catalyst/stacked-layout.tsx

# Check for media queries or responsive CSS classes in the MobileSidebar component.
rg --type ts 'className=".*lg:hidden.*"' components/Catalyst/stacked-layout.tsx

Length of output: 510

components/Catalyst/sidebar-layout.tsx (3)

7-13: SVG Icon Implementation is Correct

The OpenMenuIcon component is implemented correctly with appropriate accessibility attributes.


15-21: SVG Icon Implementation is Correct

The CloseMenuIcon component is implemented correctly with appropriate accessibility attributes.


23-49: Verify Mobile Sidebar Functionality

The MobileSidebar component uses Headless.Dialog appropriately for modal behavior. Ensure that the responsiveness and transitions are tested across different devices and screen sizes.

Verification successful

Verified Use of Tailwind CSS Utility Classes

The MobileSidebar component utilizes Tailwind CSS utility classes for responsiveness and transitions. The presence of tailwind.config.js confirms the use of Tailwind CSS in the project, which explains the utility classes applied directly in the JSX. No further action is required regarding the CSS classes in this component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify responsiveness and transitions in MobileSidebar component.

# Test: Search for CSS classes related to responsiveness and transitions. Expect: Proper usage and definitions in CSS files.
rg --type css "fixed|inset-0|bg-black/30|transition|duration-300|ease-in-out"

Length of output: 644


Script:

#!/bin/bash
# Check for Tailwind CSS configuration or imports in the project.

# Look for Tailwind CSS configuration file.
fd tailwind.config.js

# Search for Tailwind CSS imports in JavaScript/TypeScript files.
rg "import 'tailwindcss/tailwind.css'" --type js --type ts

Length of output: 109

components/Catalyst/pagination.tsx (5)

5-17: Proper Use of clsx and Accessibility Features

The Pagination component correctly uses clsx for dynamic class application and includes accessibility features such as aria-label.


19-49: Conditional Rendering and Accessibility are Handled Well

The PaginationPrevious component handles conditional rendering based on the href prop effectively, ensuring that the component is accessible and functional.


51-81: Consistent Implementation with Previous Components

The PaginationNext component is implemented consistently with PaginationPrevious, effectively handling conditional rendering and accessibility.


83-93: Simple and Effective Implementation

The PaginationList component uses clsx effectively for conditional display based on screen size, which is a good practice for responsive design.


95-120: Accessibility and Dynamic Styling are Well-Handled

The PaginationPage component effectively uses aria-current to indicate the current page and clsx for dynamic styling, aligning with accessibility best practices.

components/Catalyst/navbar.tsx (6)

10-20: Simple and Effective Navbar Implementation

The Navbar component uses clsx effectively for dynamic class application, ensuring a flexible and maintainable codebase.


22-33: Proper Use of Accessibility Attributes

The NavbarDivider component is implemented correctly with the aria-hidden attribute, ensuring it is not read by screen readers, which is appropriate for purely decorative elements.


35-46: Effective Use of Animation and Layout Management

The NavbarSection component uses LayoutGroup effectively to manage animations and layout changes, enhancing the user experience with smooth transitions.


48-59: Simple and Accessible Spacer Implementation

The NavbarSpacer component is implemented correctly with the aria-hidden attribute, ensuring it is not read by screen readers, which is appropriate for spacers.


61-121: Complex Conditional Rendering Handled Well

The NavbarItem component handles conditional rendering and ref forwarding effectively, making it versatile for different use cases. The detailed accessibility features and dynamic class application are implemented correctly.


123-128: Simple and Effective Label Implementation

The NavbarLabel component uses clsx effectively for dynamic class application, ensuring a flexible and maintainable codebase.

components/Catalyst/badge.tsx (4)

1-6: Imports and dependencies are well-organized.

The imports are clear and well-organized, which is good for maintainability. The use of forwardRef is appropriate for components that might need ref forwarding, especially when dealing with UI libraries like @headlessui/react.


7-35: Color mapping object is comprehensive and well-defined.

The colors object is extensive and covers a wide range of colors with specific styles for both light and dark themes. This approach ensures that the Badge component can be easily customized while maintaining consistency across different themes.


37-50: Badge component implementation is clean and efficient.

The Badge component is implemented efficiently using functional component syntax and destructuring for props. The use of clsx for conditional class application is appropriate and enhances the readability and maintainability of the component.


52-82: Ensure accessibility in conditional rendering within BadgeButton.

The BadgeButton component handles conditional rendering well, but ensure that accessibility considerations, such as keyboard focus and ARIA attributes, are maintained when switching between Link and Headless.Button. It might be beneficial to verify that the accessibility features are consistent in both rendered elements.

components/Catalyst/table.tsx (5)

1-18: Context setup for table properties is well-implemented.

The TableContext is set up effectively to manage table properties such as bleed, dense, grid, and striped. This approach allows for flexible configuration of the table's appearance and behavior, which can be easily adjusted through context providers.


20-63: Table component structure is modular and well-organized.

The Table component and its context provider are well-structured, providing a clear and modular approach to building table UIs. The use of clsx for conditional class application based on context values is a good practice, enhancing the component's flexibility and maintainability.


66-80: TableBody component is succinct and functional.

The TableBody component is implemented succinctly, serving as a straightforward container for table rows. This minimalistic approach is appropriate for components that primarily act as structural placeholders.


82-126: TableRow component handles complex conditional styling effectively.

The TableRow component demonstrates an effective use of context to apply conditional styling based on the striped property and the presence of an href. This implementation ensures that the row's appearance can dynamically respond to its context and properties, which is crucial for interactive table elements.


128-184: TableCell component's dynamic styling and accessibility features are commendable.

The TableCell component's implementation includes dynamic styling based on multiple context values and conditional rendering of a link for navigable cells. The use of useState for managing a reference to the cell element is a thoughtful addition for managing focus, especially in accessibility contexts.

components/Catalyst/sidebar.tsx (3)

1-20: Sidebar component setup is clean and effective.

The Sidebar component is implemented effectively using functional component syntax and props destructuring. The use of clsx for conditional class application based on the className prop enhances the component's flexibility and maintainability.


22-50: Sidebar sub-components are well-defined and modular.

The SidebarHeader, SidebarBody, and SidebarFooter components are well-defined and modular, each handling specific sections of the sidebar layout. This separation enhances the readability and maintainability of the sidebar component structure.


52-110: SidebarItem and related components demonstrate good use of advanced React patterns.

The SidebarItem component, along with SidebarDivider and SidebarSpacer, demonstrates good use of advanced React patterns such as forwardRef and conditional rendering. The use of clsx for dynamic class application and the useId hook for managing unique identifiers are particularly commendable.

components/Catalyst/dropdown.tsx (5)

9-11: Approved: Simple and effective implementation of the Dropdown component.

The function correctly utilizes the Headless UI library components and TypeScript props, ensuring type safety and simplicity.


13-18: Approved: Well-implemented DropdownButton with flexible component type.

The use of TypeScript generics here allows for flexible component customization while maintaining type safety. This is a good practice in React component design.


53-90: Approved: Effective use of conditional rendering in DropdownItem.

The function smartly handles the rendering of different elements based on props, which is a good practice for reusable UI components. The complex class management is well-handled, though it could benefit from further comments for clarity.


92-102: Approved: Simple and clean implementation of DropdownHeader.

The function is straightforward and effectively uses clsx for class management, adhering to best practices for simplicity and maintainability.


104-121: Approved: Well-structured DropdownSection for layout management.

The function effectively manages layout with conditional classes and maintains consistency with the rest of the components in terms of styling and structure.

components/Catalyst/checkbox.tsx (3)

5-18: Well-implemented CheckboxGroup component.

The use of clsx for conditional styling and the spread of props are handled well. Ensure that props are validated appropriately to avoid passing invalid HTML attributes to the div element.


21-44: CheckboxField component is correctly implemented.

The component correctly omits conflicting props and uses clsx effectively for dynamic class binding. This is a good practice to ensure that the component remains flexible and reusable.


117-157: Checkbox component is well-designed with effective theming.

The use of CSS variables for theming enhances the flexibility and reusability of the component. The structure of the component adheres to best practices, making it maintainable and scalable.

components/Catalyst/switch.tsx (3)

5-20: SwitchGroup component is consistently implemented.

The component follows similar patterns as seen in the checkbox components, using clsx for dynamic class binding and spreading props. Ensure that props are validated to prevent invalid HTML attributes.


24-45: SwitchField component is correctly implemented.

This component effectively uses clsx for dynamic class binding and omits potentially conflicting props, which is a good practice for maintaining component isolation and reusability.


142-198: Switch component is well-designed with effective theming.

The use of CSS variables for theming enhances the flexibility and reusability of the component. The structure of the component adheres to best practices, making it maintainable and scalable.

components/Catalyst/listbox.tsx (1)

161-177: Approve implementation of utility components.

The ListboxLabel and ListboxDescription components are implemented appropriately, providing essential functionality to the listbox with a clear and concise code style. The use of clsx for dynamic class names is consistent with the rest of the components.

Comment on lines 6 to 16
const sizes = {
xs: 'sm:max-w-xs',
sm: 'sm:max-w-sm',
md: 'sm:max-w-md',
lg: 'sm:max-w-lg',
xl: 'sm:max-w-xl',
'2xl': 'sm:max-w-2xl',
'3xl': 'sm:max-w-3xl',
'4xl': 'sm:max-w-4xl',
'5xl': 'sm:max-w-5xl',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using TypeScript enums for size definitions.

The current implementation uses a plain object for size mappings. Using TypeScript enums or a const enum could provide better autocompletion and error checking during development.

Consider refactoring the size definitions:

enum Size {
  Xs = 'sm:max-w-xs',
  Sm = 'sm:max-w-sm',
  Md = 'sm:max-w-md',
  Lg = 'sm:max-w-lg',
  Xl = 'sm:max-w-xl',
  '2Xl' = 'sm:max-w-2xl',
  '3Xl' = 'sm:max-w-3xl',
  '4Xl' = 'sm:max-w-4xl',
  '5Xl' = 'sm:max-w-5xl',
}

Comment on lines 53 to 66
export function AlertTitle({
className,
...props
}: { className?: string } & Omit<Headless.DialogTitleProps, 'as' | 'className'>) {
return (
<Headless.DialogTitle
{...props}
className={clsx(
className,
'text-balance text-center text-base/6 font-semibold text-zinc-950 sm:text-wrap sm:text-left sm:text-sm/6 dark:text-white'
)}
/>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Review the AlertTitle component for text scaling.

The AlertTitle uses fixed text sizes which might not scale well on all devices. Consider using responsive units like rem or percentages for text sizes to enhance readability across devices.

Propose a change to use responsive text sizes:

className={clsx(
  className,
  'text-balance text-center text-base font-semibold text-zinc-950 sm:text-wrap sm:text-left sm:text-base dark:text-white'
)}

Comment on lines 68 to 79
export function AlertDescription({
className,
...props
}: { className?: string } & Omit<Headless.DescriptionProps<typeof Text>, 'as' | 'className'>) {
return (
<Headless.Description
as={Text}
{...props}
className={clsx(className, 'mt-2 text-pretty text-center sm:text-left')}
/>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize AlertDescription for better text alignment and readability.

The AlertDescription component could benefit from better text alignment properties, especially in smaller screens where center alignment might not be ideal.

Suggest a change for better text alignment:

className={clsx(className, 'mt-2 text-pretty text-left sm:text-left')}

Comment on lines 54 to 70
export function DialogTitle({
className,
...props
}: { className?: string } & Omit<
Headless.DialogTitleProps,
"as" | "className"
>) {
return (
<Headless.DialogTitle
{...props}
className={clsx(
className,
"text-balance text-lg/6 font-semibold text-zinc-950 dark:text-white sm:text-base/6",
)}
/>
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the DialogTitle for appropriate text scaling and accessibility.

Similar to the AlertTitle, ensure that the DialogTitle uses responsive text sizes and is accessible.

Suggest using responsive text sizes for better accessibility:

className={clsx(
  className,
  'text-balance text-lg font-semibold text-zinc-950 dark:text-white sm:text-base'
)}

Comment on lines 72 to 85
export function DialogDescription({
className,
...props
}: { className?: string } & Omit<
Headless.DescriptionProps<typeof Text>,
"as" | "className"
>) {
return (
<Headless.Description
as={Text}
{...props}
className={clsx(className, "mt-2 text-pretty")}
/>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize DialogDescription for better text readability.

The DialogDescription should use more flexible text alignment properties to improve readability on various devices.

Suggest changes for better text alignment:

className={clsx(className, 'mt-2 text-pretty text-left')}

Comment on lines 7 to 102
export function Listbox<T>({
className,
placeholder,
autoFocus,
'aria-label': ariaLabel,
children: options,
...props
}: {
className?: string
placeholder?: React.ReactNode
autoFocus?: boolean
'aria-label'?: string
children?: React.ReactNode
} & Omit<Headless.ListboxProps<typeof Fragment, T>, 'as' | 'multiple'>) {
return (
<Headless.Listbox {...props} multiple={false}>
<Headless.ListboxButton
autoFocus={autoFocus}
data-slot="control"
aria-label={ariaLabel}
className={clsx([
className,
// Basic layout
'group relative block w-full',
// Background color + shadow applied to inset pseudo element, so shadow blends with border in light mode
'before:absolute before:inset-px before:rounded-[calc(theme(borderRadius.lg)-1px)] before:bg-white before:shadow',
// Background color is moved to control and shadow is removed in dark mode so hide `before` pseudo
'dark:before:hidden',
// Hide default focus styles
'focus:outline-none',
// Focus ring
'after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:ring-inset after:ring-transparent after:data-[focus]:ring-2 after:data-[focus]:ring-blue-500',
// Disabled state
'data-[disabled]:opacity-50 before:data-[disabled]:bg-zinc-950/5 before:data-[disabled]:shadow-none',
])}
>
<Headless.ListboxSelectedOption
as="span"
options={options}
placeholder={placeholder && <span className="block truncate text-zinc-500">{placeholder}</span>}
className={clsx([
// Basic layout
'relative block w-full appearance-none rounded-lg py-[calc(theme(spacing[2.5])-1px)] sm:py-[calc(theme(spacing[1.5])-1px)]',
// Set minimum height for when no value is selected
'min-h-11 sm:min-h-9',
// Horizontal padding
'pl-[calc(theme(spacing[3.5])-1px)] pr-[calc(theme(spacing.7)-1px)] sm:pl-[calc(theme(spacing.3)-1px)]',
// Typography
'text-left text-base/6 text-zinc-950 placeholder:text-zinc-500 sm:text-sm/6 dark:text-white forced-colors:text-[CanvasText]',
// Border
'border border-zinc-950/10 group-data-[active]:border-zinc-950/20 group-data-[hover]:border-zinc-950/20 dark:border-white/10 dark:group-data-[active]:border-white/20 dark:group-data-[hover]:border-white/20',
// Background color
'bg-transparent dark:bg-white/5',
// Invalid state
'group-data-[invalid]:border-red-500 group-data-[invalid]:group-data-[hover]:border-red-500 group-data-[invalid]:dark:border-red-600 group-data-[invalid]:data-[hover]:dark:border-red-600',
// Disabled state
'group-data-[disabled]:border-zinc-950/20 group-data-[disabled]:opacity-100 group-data-[disabled]:dark:border-white/15 group-data-[disabled]:dark:bg-white/[2.5%] dark:data-[hover]:group-data-[disabled]:border-white/15',
])}
/>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<svg
className="size-5 stroke-zinc-500 group-data-[disabled]:stroke-zinc-600 sm:size-4 dark:stroke-zinc-400 forced-colors:stroke-[CanvasText]"
viewBox="0 0 16 16"
aria-hidden="true"
fill="none"
>
<path d="M5.75 10.75L8 13L10.25 10.75" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" />
<path d="M10.25 5.25L8 3L5.75 5.25" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" />
</svg>
</span>
</Headless.ListboxButton>
<Headless.ListboxOptions
transition
anchor="selection start"
className={clsx(
// Anchor positioning
'[--anchor-offset:-1.625rem] [--anchor-padding:theme(spacing.4)] sm:[--anchor-offset:-1.375rem]',
// Base styles
'isolate w-max min-w-[calc(var(--button-width)+1.75rem)] select-none scroll-py-1 rounded-xl p-1',
// Invisible border that is only visible in `forced-colors` mode for accessibility purposes
'outline outline-1 outline-transparent focus:outline-none',
// Handle scrolling when menu won't fit in viewport
'overflow-y-scroll overscroll-contain',
// Popover background
'bg-white/75 backdrop-blur-xl dark:bg-zinc-800/75',
// Shadows
'shadow-lg ring-1 ring-zinc-950/10 dark:ring-inset dark:ring-white/10',
// Transitions
'transition-opacity duration-100 ease-in data-[transition]:pointer-events-none data-[closed]:data-[leave]:opacity-0'
)}
>
{options}
</Headless.ListboxOptions>
</Headless.Listbox>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve use of generics and dynamic class names; suggest CSS simplification.

The use of TypeScript generics enhances the component's reusability, and the dynamic class names are well-handled using the clsx library. However, the complex CSS might be hard to maintain. Consider simplifying the CSS or documenting the styling choices more thoroughly to aid future development.

Comment on lines 104 to 159
export function ListboxOption<T>({
children,
className,
...props
}: { className?: string; children?: React.ReactNode } & Omit<
Headless.ListboxOptionProps<'div', T>,
'as' | 'className'
>) {
let sharedClasses = clsx(
// Base
'flex min-w-0 items-center',
// Icons
'[&>[data-slot=icon]]:size-5 [&>[data-slot=icon]]:shrink-0 sm:[&>[data-slot=icon]]:size-4',
'[&>[data-slot=icon]]:text-zinc-500 [&>[data-slot=icon]]:group-data-[focus]/option:text-white [&>[data-slot=icon]]:dark:text-zinc-400',
'forced-colors:[&>[data-slot=icon]]:text-[CanvasText] forced-colors:[&>[data-slot=icon]]:group-data-[focus]/option:text-[Canvas]',
// Avatars
'[&>[data-slot=avatar]]:-mx-0.5 [&>[data-slot=avatar]]:size-6 sm:[&>[data-slot=avatar]]:size-5'
)

return (
<Headless.ListboxOption as={Fragment} {...props}>
{({ selectedOption }) => {
if (selectedOption) {
return <div className={clsx(className, sharedClasses)}>{children}</div>
}

return (
<div
className={clsx(
// Basic layout
'group/option grid cursor-default grid-cols-[theme(spacing.5),1fr] items-baseline gap-x-2 rounded-lg py-2.5 pl-2 pr-3.5 sm:grid-cols-[theme(spacing.4),1fr] sm:py-1.5 sm:pl-1.5 sm:pr-3',
// Typography
'text-base/6 text-zinc-950 sm:text-sm/6 dark:text-white forced-colors:text-[CanvasText]',
// Focus
'outline-none data-[focus]:bg-blue-500 data-[focus]:text-white',
// Forced colors mode
'forced-color-adjust-none forced-colors:data-[focus]:bg-[Highlight] forced-colors:data-[focus]:text-[HighlightText]',
// Disabled
'data-[disabled]:opacity-50'
)}
>
<svg
className="relative hidden size-5 self-center stroke-current group-data-[selected]/option:inline sm:size-4"
viewBox="0 0 16 16"
fill="none"
aria-hidden="true"
>
<path d="M4 8.5l3 3L12 4" strokeWidth={1.5} strokeLinecap="round" strokeLinejoin="round" />
</svg>
<span className={clsx(className, sharedClasses, 'col-start-2')}>{children}</span>
</div>
)
}}
</Headless.ListboxOption>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve implementation; suggest adding unit tests for conditional rendering.

The implementation of ListboxOption is consistent with the main component and uses TypeScript generics effectively. The conditional rendering logic is clear. Consider adding unit tests to verify that the rendering behaves as expected under different conditions.

Would you like help setting up the unit tests for this component?

Comment on lines 4 to 20
export function RadioGroup({
className,
...props
}: { className?: string } & Omit<Headless.RadioGroupProps, 'as' | 'className'>) {
return (
<Headless.RadioGroup
data-slot="control"
{...props}
className={clsx(
className,
// Basic groups
'space-y-3 [&_[data-slot=label]]:font-normal',
// With descriptions
'has-[[data-slot=description]]:space-y-6 [&_[data-slot=label]]:has-[[data-slot=description]]:font-medium'
)}
/>
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve implementation; suggest CSS simplification.

The RadioGroup component is implemented well, using modern React practices and effective use of clsx for dynamic class names. Consider simplifying the CSS to improve maintainability and ensure that it is easier for other developers to understand and modify.

Comment on lines 23 to 46
export function RadioField({
className,
...props
}: { className?: string } & Omit<Headless.FieldProps, 'as' | 'className'>) {
return (
<Headless.Field
data-slot="field"
{...props}
className={clsx(
className,
// Base layout
'grid grid-cols-[1.125rem_1fr] items-center gap-x-4 gap-y-1 sm:grid-cols-[1rem_1fr]',
// Control layout
'[&>[data-slot=control]]:col-start-1 [&>[data-slot=control]]:row-start-1 [&>[data-slot=control]]:justify-self-center',
// Label layout
'[&>[data-slot=label]]:col-start-2 [&>[data-slot=label]]:row-start-1 [&>[data-slot=label]]:justify-self-start',
// Description layout
'[&>[data-slot=description]]:col-start-2 [&>[data-slot=description]]:row-start-2',
// With description
'[&_[data-slot=label]]:has-[[data-slot=description]]:font-medium'
)}
/>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve implementation; suggest CSS simplification.

The RadioField component is implemented appropriately, using a grid layout for responsive design. The use of clsx for dynamic class names is consistent with the rest of the components. Consider simplifying the CSS to enhance maintainability.

Comment on lines 120 to 138
export function Radio({
color = 'dark/zinc',
className,
...props
}: { color?: Color; className?: string } & Omit<Headless.RadioProps, 'as' | 'className' | 'children'>) {
return (
<Headless.Radio data-slot="control" {...props} className={clsx(className, 'group inline-flex focus:outline-none')}>
<span className={clsx([base, colors[color]])}>
<span
className={clsx(
'size-full rounded-full border-[4.5px] border-transparent bg-[--radio-indicator] bg-clip-padding',
// Forced colors mode
'forced-colors:border-[Canvas] forced-colors:group-data-[checked]:border-[Highlight]'
)}
/>
</span>
</Headless.Radio>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Approve implementation; suggest documenting CSS custom properties.

The Radio component is implemented well, using custom CSS properties for theming, which enhances the flexibility and reusability of the component. Consider documenting the use of these custom properties to ensure that they are easy to understand and maintain across the application.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 27776b2 and c1e43f7.

Files selected for processing (17)
  • components/Catalyst/alert.tsx (1 hunks)
  • components/Catalyst/avatar.tsx (1 hunks)
  • components/Catalyst/badge.tsx (1 hunks)
  • components/Catalyst/checkbox.tsx (1 hunks)
  • components/Catalyst/description-list.tsx (1 hunks)
  • components/Catalyst/dialog.tsx (1 hunks)
  • components/Catalyst/dropdown.tsx (1 hunks)
  • components/Catalyst/listbox.tsx (1 hunks)
  • components/Catalyst/navbar.tsx (1 hunks)
  • components/Catalyst/pagination.tsx (1 hunks)
  • components/Catalyst/radio.tsx (1 hunks)
  • components/Catalyst/sidebar-layout.tsx (1 hunks)
  • components/Catalyst/sidebar.tsx (1 hunks)
  • components/Catalyst/stacked-layout.tsx (1 hunks)
  • components/Catalyst/switch.tsx (1 hunks)
  • components/Catalyst/table.tsx (1 hunks)
  • components/Catalyst/textarea.tsx (1 hunks)
Files skipped from review due to trivial changes (4)
  • components/Catalyst/description-list.tsx
  • components/Catalyst/listbox.tsx
  • components/Catalyst/pagination.tsx
  • components/Catalyst/textarea.tsx
Files skipped from review as they are similar to previous changes (13)
  • components/Catalyst/alert.tsx
  • components/Catalyst/avatar.tsx
  • components/Catalyst/badge.tsx
  • components/Catalyst/checkbox.tsx
  • components/Catalyst/dialog.tsx
  • components/Catalyst/dropdown.tsx
  • components/Catalyst/navbar.tsx
  • components/Catalyst/radio.tsx
  • components/Catalyst/sidebar-layout.tsx
  • components/Catalyst/sidebar.tsx
  • components/Catalyst/stacked-layout.tsx
  • components/Catalyst/switch.tsx
  • components/Catalyst/table.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (4)
components/ui-components/dropdown.tsx (2)

20-51: LGTM, but consider extracting the inline styles.

The code changes are approved.

However, the component has a lot of inline styles which can be extracted to a separate CSS file to improve readability and maintainability.

Consider extracting the inline styles to a separate CSS file and importing it in the component. For example:

import "./DropdownMenu.css";

export function DropdownMenu({ ... }) {
  return (
    <Headless.MenuItems
      {...props} 
      className={clsx(className, "dropdown-menu")}
    />
  );
}

And in DropdownMenu.css:

.dropdown-menu {
  /* Anchor positioning */
  --anchor-gap: theme(spacing.2);
  --anchor-padding: theme(spacing.1);
  ...
}

53-90: LGTM, but consider extracting the inline styles.

The code changes are approved.

However, the component has a lot of inline styles which can be extracted to a separate CSS file to improve readability and maintainability.

Consider extracting the inline styles to a separate CSS file and importing it in the component. For example:

import "./DropdownItem.css";

export function DropdownItem({ ... }) {
  return (
    <Headless.MenuItem>
      {"href" in props ? (
        <Link {...props} className={clsx(className, "dropdown-item")} />
      ) : (
        <button type="button" {...props} className={clsx(className, "dropdown-item")} />
      )}
    </Headless.MenuItem>
  );
}

And in DropdownItem.css:

.dropdown-item {
  /* Base styles */
  @apply group cursor-default rounded-lg px-3.5 py-2.5 focus:outline-none sm:px-3 sm:py-1.5;
  ...  
}
components/ui-components/radio.tsx (1)

123-148: LGTM, but consider extracting the inline styles.

The code changes are approved.

However, the component has a lot of inline styles which can be extracted to a separate CSS file to improve readability and maintainability.

Consider extracting the inline styles to a separate CSS file and importing it in the component. For example:

import "./Radio.css";

export function Radio({ color = "dark/zinc", ... }) {
  return (
    <Headless.Radio      
      className={clsx(className, "radio", `radio-${color}`)}
    >
      <span className="radio__inner">
        <span className="radio__indicator" />
      </span>
    </Headless.Radio>
  );
}

And in Radio.css:

.radio {
  @apply group inline-flex focus:outline-none;
}

.radio__inner {
  /* Base styles */
  @apply relative isolate flex size-[1.1875rem] shrink-0 rounded-full sm:size-[1.0625rem];
  ...
}

.radio__indicator {
  @apply size-full rounded-full border-[4.5px] border-transparent bg-[--radio-indicator] bg-clip-padding;
  ...
}

/* Color variants */
.radio-dark\/zinc {
  --radio-checked-bg: theme(colors.zinc.900);
  --radio-checked-border: theme(colors.zinc.950/90%);
  --radio-checked-indicator: theme(colors.white);
  ...
}
...
components/ui-components/checkbox.tsx (1)

120-160: LGTM, but consider extracting the inline styles.

The code changes are approved.

However, the component has a lot of inline styles which can be extracted to a separate CSS file to improve readability and maintainability.

Consider extracting the inline styles to a separate CSS file and importing it in the component. For example:

import "./Checkbox

</blockquote></details>

</blockquote></details>

<details>
<summary>Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**

<details>
<summary>Commits</summary>

Files that changed from the base of the PR and between c1e43f750b35b5e6d4a60ae29eaa7229d5c6592d and 66ac481aa8cc34c1b3c4db11681065308bc4354a.

</details>


<details>
<summary>Files selected for processing (18)</summary>

* app/(app)/alpha/additional-details/_client.tsx (1 hunks)
* components/ui-components/alert.tsx (1 hunks)
* components/ui-components/avatar.tsx (1 hunks)
* components/ui-components/badge.tsx (1 hunks)
* components/ui-components/checkbox.tsx (1 hunks)
* components/ui-components/description-list.tsx (1 hunks)
* components/ui-components/dialog.tsx (1 hunks)
* components/ui-components/dropdown.tsx (1 hunks)
* components/ui-components/listbox.tsx (1 hunks)
* components/ui-components/navbar.tsx (1 hunks)
* components/ui-components/pagination.tsx (1 hunks)
* components/ui-components/radio.tsx (1 hunks)
* components/ui-components/sidebar-layout.tsx (1 hunks)
* components/ui-components/sidebar.tsx (1 hunks)
* components/ui-components/stacked-layout.tsx (1 hunks)
* components/ui-components/switch.tsx (1 hunks)
* components/ui-components/table.tsx (1 hunks)
* components/ui-components/textarea.tsx (1 hunks)

</details>








<details>
<summary>Files skipped from review as they are similar to previous changes (1)</summary>

* app/(app)/alpha/additional-details/_client.tsx

</details>


<details>
<summary>Additional comments not posted (57)</summary><blockquote>

<details>
<summary>components/ui-components/description-list.tsx (3)</summary><blockquote>

`3-16`: **LGTM!**

The code changes are approved.

---

`18-31`: **LGTM!**

The code changes are approved.

---

`33-46`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/textarea.tsx (1)</summary><blockquote>

`5-57`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/avatar.tsx (2)</summary><blockquote>

`15-60`: **LGTM!**

The code changes are approved.

---

`62-100`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/alert.tsx (1)</summary><blockquote>

`1-108`: **LGTM!**

The `Alert` component and its sub-components are well-structured and follow best practices:

- Modular design with separate main component and sub-components.
- Utilizes the `@headlessui/react` library for accessibility and interactivity.
- Allows for customizable alert sizes through the `sizes` object.
- Applies appropriate styling classes using `clsx` for conditional class merging.
- Provides a consistent structure for the alert title, description, body, and actions.
- Handles transitions and applies responsive styles for different screen sizes.

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/dialog.tsx (1)</summary><blockquote>

`1-108`: **LGTM!**

The `Dialog` component and its sub-components are well-structured and follow best practices:

- Modular design with separate main component and sub-components.
- Utilizes the `@headlessui/react` library for accessibility and interactivity.
- Allows for customizable dialog sizes through the `sizes` object.
- Applies appropriate styling classes using `clsx` for conditional class merging.
- Provides a consistent structure for the dialog title, description, body, and actions.
- Handles transitions and applies responsive styles for different screen sizes.

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/stacked-layout.tsx (1)</summary><blockquote>

`1-89`: **LGTM!**

The `StackedLayout` component and its sub-components are well-structured and provide a responsive layout:

- Utilizes the `@headlessui/react` library for accessibility and interactivity of the mobile sidebar.
- Defines `OpenMenuIcon` and `CloseMenuIcon` components for rendering the menu icons.
- Manages the state for showing/hiding the mobile sidebar using the `useState` hook.
- Structures the layout with a navbar, sidebar (on mobile), and main content area.
- Applies appropriate styling classes for different screen sizes and dark mode.

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/sidebar-layout.tsx (3)</summary><blockquote>

`7-13`: **LGTM!**

The code changes are approved.

---

`15-21`: **LGTM!**

The code changes are approved.

---

`51-92`: **LGTM!**

The code changes are approved.

The `SidebarLayout` component is correctly implemented and uses sub-components to render the sidebar and navbar on mobile. It also uses the `useState` hook to manage the state of the sidebar on mobile.

</blockquote></details>
<details>
<summary>components/ui-components/pagination.tsx (5)</summary><blockquote>

`5-17`: **LGTM!**

The code changes are approved.

---

`19-49`: **LGTM!**

The code changes are approved.

The `PaginationPrevious` component is correctly implemented and uses the `Button` component to render the button.

---

`51-81`: **LGTM!**

The code changes are approved.

The `PaginationNext` component is correctly implemented and uses the `Button` component to render the button.

---

`83-93`: **LGTM!**

The code changes are approved.

---

`95-120`: **LGTM!**

The code changes are approved.

The `PaginationPage` component is correctly implemented and uses the `Button` component to render the button.

</blockquote></details>
<details>
<summary>components/ui-components/navbar.tsx (6)</summary><blockquote>

`10-20`: **LGTM!**

The code changes are approved.

---

`22-33`: **LGTM!**

The code changes are approved.

---

`35-46`: **LGTM!**

The code changes are approved.

The `NavbarSection` component is correctly implemented and uses the `LayoutGroup` component from the `framer-motion` library to group the items in the section.

---

`48-59`: **LGTM!**

The code changes are approved.

---

`61-121`: **LGTM!**

The code changes are approved.

The `NavbarItem` component is correctly implemented and uses the `Link` component to render a link and the `Headless.Button` component to render a button. It also uses the `motion` component from the `framer-motion` library to animate the current indicator.

---

`123-128`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/badge.tsx (1)</summary><blockquote>

`39-54`: **LGTM!**

The `Badge` component is well-implemented and follows best practices.

</blockquote></details>
<details>
<summary>components/ui-components/table.tsx (7)</summary><blockquote>

`20-64`: **LGTM!**

The `Table` component is well-implemented and follows best practices.

---

`66-76`: **LGTM!**

The `TableHead` component is correctly implemented.

---

`78-80`: **LGTM!**

The `TableBody` component is correctly implemented.

---

`82-90`: **LGTM!**

The `TableRowContext` is correctly implemented.

---

`92-126`: **LGTM!**

The `TableRow` component is well-implemented and follows best practices.

---

`128-146`: **LGTM!**

The `TableHeader` component is well-implemented and follows best practices.

---

`148-184`: **LGTM!**

The `TableCell` component is well-implemented and follows best practices.

</blockquote></details>
<details>
<summary>components/ui-components/sidebar.tsx (8)</summary><blockquote>

`11-21`: **LGTM!**

The `Sidebar` component is correctly implemented.

---

`23-36`: **LGTM!**

The `SidebarHeader` component is correctly implemented.

---

`38-51`: **LGTM!**

The `SidebarBody` component is correctly implemented.

---

`53-66`: **LGTM!**

The `SidebarFooter` component is correctly implemented.

---

`68-83`: **LGTM!**

The `SidebarSection` component is correctly implemented.

---

`85-98`: **LGTM!**

The `SidebarDivider` component is correctly implemented.

---

`100-111`: **LGTM!**

The `SidebarSpacer` component is correctly implemented.

---

`113-126`: **LGTM!**

The `SidebarHeading` component is correctly implemented.

</blockquote></details>
<details>
<summary>components/ui-components/dropdown.tsx (6)</summary><blockquote>

`9-11`: **LGTM!**

The code changes are approved.

---

`13-18`: **LGTM!**

The code changes are approved.

---

`92-102`: **LGTM!**

The code changes are approved.

---

`104-121`: **LGTM!**

The code changes are approved.

---

`123-139`: **LGTM!**

The code changes are approved.

---

`141-157`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/radio.tsx (2)</summary><blockquote>

`4-24`: **LGTM!**

The code changes are approved.

---

`26-49`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/checkbox.tsx (2)</summary><blockquote>

`5-22`: **LGTM!**

The code changes are approved.

---

`24-47`: **LGTM!**

The code changes are approved.

</blockquote></details>
<details>
<summary>components/ui-components/listbox.tsx (4)</summary><blockquote>

`9-120`: **Listbox component looks good!**

The `Listbox` component is well-implemented and utilizes the `@headlessui/react` library effectively. The prop handling and CSS classes cover various scenarios and provide flexibility in customizing the listbox.

---

`122-186`: **ListboxOption component looks good!**

The `ListboxOption` component is well-implemented and handles the rendering of options effectively. The conditional rendering based on the selected state is a good approach, and the CSS classes cover various states and provide flexibility in styling the options.

---

`188-201`: **ListboxLabel component looks good!**

The `ListboxLabel` component is a simple and straightforward component that renders a label for the listbox. The CSS classes handle margin and truncation appropriately.

---

`203-219`: **ListboxDescription component looks good!**

The `ListboxDescription` component is a useful addition for rendering descriptions for options within the listbox. The CSS classes handle text color, spacing, and truncation appropriately.

</blockquote></details>
<details>
<summary>components/ui-components/switch.tsx (4)</summary><blockquote>

`5-22`: **SwitchGroup component looks good!**

The `SwitchGroup` component is a useful wrapper for the switch and its label. The CSS classes handle spacing and typography appropriately.

---

`24-47`: **SwitchField component looks good!**

The `SwitchField` component provides a structured way to represent a switch field with its associated label and description. The CSS classes handle the layout and spacing effectively.

---

`49-138`: **`colors` object looks good!**

The `colors` object provides a convenient way to define color-specific styles for the switch component. The color schemes cover a wide range of options, allowing for flexibility in customizing the switch appearance. The styles are well-organized and follow a consistent pattern.

---

`142-198`: **Switch component looks good!**

The `Switch` component is well-implemented and utilizes the `@headlessui/react` library effectively. The prop handling and CSS classes cover various states and scenarios, providing flexibility in customizing the switch appearance. The use of the `colors` object for color-specific styles is a good approach.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment on lines +56 to +90
export const BadgeButton = forwardRef(function BadgeButton(
{
color = "zinc",
className,
children,
...props
}: BadgeProps & { className?: string; children: React.ReactNode } & (
| Omit<Headless.ButtonProps, "as" | "className">
| Omit<React.ComponentPropsWithoutRef<typeof Link>, "className">
),
ref: React.ForwardedRef<HTMLElement>,
) {
const classes = clsx(
className,
"group relative inline-flex rounded-md focus:outline-none data-[focus]:outline data-[focus]:outline-2 data-[focus]:outline-offset-2 data-[focus]:outline-blue-500",
);

return "href" in props ? (
<Link
{...props}
className={classes}
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Link>
) : (
<Headless.Button {...props} className={classes} ref={ref}>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Headless.Button>
);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but consider a minor refactor.

The BadgeButton component is well-implemented and follows best practices.

However, consider extracting the classes variable to a separate function to improve readability and reusability.

+const getBadgeButtonClasses = (className: string) =>
+  clsx(
+    className,
+    "group relative inline-flex rounded-md focus:outline-none data-[focus]:outline data-[focus]:outline-2 data-[focus]:outline-offset-2 data-[focus]:outline-blue-500",
+  );
+
 export const BadgeButton = forwardRef(function BadgeButton(
   {
     color = "zinc",
     className,
     children,
     ...props
   }: BadgeProps & { className?: string; children: React.ReactNode } & (
       | Omit<Headless.ButtonProps, "as" | "className">
       | Omit<React.ComponentPropsWithoutRef<typeof Link>, "className">
     ),
   ref: React.ForwardedRef<HTMLElement>,
 ) {
-  const classes = clsx(
-    className,
-    "group relative inline-flex rounded-md focus:outline-none data-[focus]:outline data-[focus]:outline-2 data-[focus]:outline-offset-2 data-[focus]:outline-blue-500",
-  );
+  const classes = getBadgeButtonClasses(className);

   return "href" in props ? (
     <Link
       {...props}
       className={classes}
       ref={ref as React.ForwardedRef<HTMLAnchorElement>}
     >
       <TouchTarget>
         <Badge color={color}>{children}</Badge>
       </TouchTarget>
     </Link>
   ) : (
     <Headless.Button {...props} className={classes} ref={ref}>
       <TouchTarget>
         <Badge color={color}>{children}</Badge>
       </TouchTarget>
     </Headless.Button>
   );
 });
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
export const BadgeButton = forwardRef(function BadgeButton(
{
color = "zinc",
className,
children,
...props
}: BadgeProps & { className?: string; children: React.ReactNode } & (
| Omit<Headless.ButtonProps, "as" | "className">
| Omit<React.ComponentPropsWithoutRef<typeof Link>, "className">
),
ref: React.ForwardedRef<HTMLElement>,
) {
const classes = clsx(
className,
"group relative inline-flex rounded-md focus:outline-none data-[focus]:outline data-[focus]:outline-2 data-[focus]:outline-offset-2 data-[focus]:outline-blue-500",
);
return "href" in props ? (
<Link
{...props}
className={classes}
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Link>
) : (
<Headless.Button {...props} className={classes} ref={ref}>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Headless.Button>
);
});
const getBadgeButtonClasses = (className: string) =>
clsx(
className,
"group relative inline-flex rounded-md focus:outline-none data-[focus]:outline data-[focus]:outline-2 data-[focus]:outline-offset-2 data-[focus]:outline-blue-500",
);
export const BadgeButton = forwardRef(function BadgeButton(
{
color = "zinc",
className,
children,
...props
}: BadgeProps & { className?: string; children: React.ReactNode } & (
| Omit<Headless.ButtonProps, "as" | "className">
| Omit<React.ComponentPropsWithoutRef<typeof Link>, "className">
),
ref: React.ForwardedRef<HTMLElement>,
) {
const classes = getBadgeButtonClasses(className);
return "href" in props ? (
<Link
{...props}
className={classes}
ref={ref as React.ForwardedRef<HTMLAnchorElement>}
>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Link>
) : (
<Headless.Button {...props} className={classes} ref={ref}>
<TouchTarget>
<Badge color={color}>{children}</Badge>
</TouchTarget>
</Headless.Button>
);
});

@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete this entire file and references to Husky if it's not being used 🤖

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah.
I didn't delete it because I thought there may be other uses for it?
I actually thought we might use it to run prettier on pre commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see anywhere else we need it so get rid of it everywhere I guess.

@NiallJoeMaher NiallJoeMaher changed the title Addition/catalyst components New components Sep 16, 2024
…odu into addition/catalyst-components

 especially if it merges an updated upstream into a topic branch.
Copy link
Contributor

@NiallJoeMaher NiallJoeMaher left a comment

Choose a reason for hiding this comment

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

🌮

@NiallJoeMaher NiallJoeMaher merged commit a292b4d into develop Sep 20, 2024
4 checks passed
@NiallJoeMaher NiallJoeMaher deleted the addition/catalyst-components branch September 20, 2024 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants