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

enhance: add shadcn components and stories #120

Closed
wants to merge 2 commits into from
Closed

enhance: add shadcn components and stories #120

wants to merge 2 commits into from

Conversation

rschlaefli
Copy link
Member

@rschlaefli rschlaefli commented Aug 8, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a customizable Button component, Accordion stories, Calendar component, Checkbox component, Input component, Label component, Navigation Menu component, and Popover component to enhance the design system.
    • Added new stories for visualization and testing of the Button, Calendar, Checkbox, Input, Label, Navigation Menu, and Popover components.
  • Updates

    • Updated dependencies for improved functionality and compatibility.
    • Enhanced the existing Accordion component with better documentation and clearer content.
  • Documentation

    • Improved story documentation for various components to facilitate better understanding and usability.

Copy link

coderabbitai bot commented Aug 8, 2024

Walkthrough

Walkthrough

This update enhances the design system by introducing new components and updating existing ones, improving modularity and usability. Key changes include the addition of aliases for easier imports, version upgrades for several dependencies, and the introduction of various UI components like Button, Calendar, and Popover. These changes aim to streamline development and improve the overall user experience across the design system.

Changes

Files Change Summary
packages/design-system/components.json, packages/design-system/package.json Added a new alias "ui": "@/ui" for improved module resolution. Updated dependencies, including version upgrades and new additions for better functionality and compatibility.
packages/design-system/src/ui/*.stories.tsx Introduced new story files for multiple components (Button, Calendar, Checkbox, Input, Label, NavigationMenu, Popover). Updated story structures to enhance organization and clarity.
packages/design-system/src/ui/*.tsx Created new components (Button, Calendar, Checkbox, Input, Label, NavigationMenu, Popover) with customizable properties, leveraging Radix UI for improved accessibility and styling.

Poem

In the garden where I play,
Components bloom in bright array.
Buttons leap and calendars cheer,
With popovers whispering near.
A design so fresh, oh what a sight,
Hopping joyfully into the night! 🐰✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

@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 (3)
packages/design-system/src/ui/input.tsx (1)

1-3: Consider adding a description for utility imports.

The cn utility function is imported from @/lib/utils. Ensure that this function is well-documented, as it plays a crucial role in managing class names.

packages/design-system/src/ui/checkbox.tsx (1)

1-3: Ensure Radix UI components are documented.

The Checkbox component relies on Radix UI's CheckboxPrimitive. Ensure that the usage and customization of Radix UI components are well-documented for future reference.

packages/design-system/src/ui/button.tsx (1)

56-56: Consider separating constants or functions to a new file.

Fast refresh only works when a file only exports components. Consider moving buttonVariants to a separate file to adhere to this best practice.

Tools
GitHub Check: Lint

[warning] 56-56:
Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1d7cbc1 and e922e00.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (17)
  • packages/design-system/components.json (1 hunks)
  • packages/design-system/package.json (1 hunks)
  • packages/design-system/src/ui/accordion.stories.tsx (1 hunks)
  • packages/design-system/src/ui/button.stories.tsx (1 hunks)
  • packages/design-system/src/ui/button.tsx (1 hunks)
  • packages/design-system/src/ui/calendar.stories.tsx (1 hunks)
  • packages/design-system/src/ui/calendar.tsx (1 hunks)
  • packages/design-system/src/ui/checkbox.stories.tsx (1 hunks)
  • packages/design-system/src/ui/checkbox.tsx (1 hunks)
  • packages/design-system/src/ui/input.stories.tsx (1 hunks)
  • packages/design-system/src/ui/input.tsx (1 hunks)
  • packages/design-system/src/ui/label.stories.tsx (1 hunks)
  • packages/design-system/src/ui/label.tsx (1 hunks)
  • packages/design-system/src/ui/navigation-menu.stories.tsx (1 hunks)
  • packages/design-system/src/ui/navigation-menu.tsx (1 hunks)
  • packages/design-system/src/ui/popover.stories.tsx (1 hunks)
  • packages/design-system/src/ui/popover.tsx (1 hunks)
Files skipped from review due to trivial changes (4)
  • packages/design-system/components.json
  • packages/design-system/src/ui/checkbox.stories.tsx
  • packages/design-system/src/ui/input.stories.tsx
  • packages/design-system/src/ui/label.stories.tsx
Additional context used
GitHub Check: Lint
packages/design-system/src/ui/button.tsx

[warning] 56-56:
Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components

packages/design-system/src/ui/navigation-menu.tsx

[warning] 119-119:
Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components

Additional comments not posted (26)
packages/design-system/src/ui/button.stories.tsx (1)

1-9: LGTM!

The setup for the Button story is clear and follows best practices for storybook components.

packages/design-system/src/ui/calendar.stories.tsx (1)

1-20: LGTM!

The Calendar story is well-implemented, demonstrating state management with React hooks effectively.

packages/design-system/src/ui/label.tsx (1)

1-24: LGTM!

The Label component is well-structured and uses forwardRef effectively. The styling approach with cva and cn is clean and maintainable.

packages/design-system/src/ui/input.tsx (1)

8-22: LGTM! Ensure consistent usage of forwardRef.

The Input component uses React.forwardRef, which is a good practice for allowing parent components to access the input's DOM node. Ensure this pattern is consistently applied across similar components for uniformity.

packages/design-system/src/ui/accordion.stories.tsx (2)

8-12: Ensure type compatibility with Storybook.

The use of satisfies StoryDefault ensures type compatibility with Storybook's expectations. This is a good practice to prevent type-related issues.


14-32: Enhance clarity with updated labels and content.

The updated labels and content for the accordion items improve the clarity of the story. These changes align the component's presentation with its visual design and user experience.

packages/design-system/src/ui/checkbox.tsx (1)

7-25: LGTM! Consistent use of forwardRef and utility functions.

The Checkbox component uses React.forwardRef and utility functions for class names, which is consistent with best practices for reusable components.

packages/design-system/src/ui/popover.tsx (3)

6-6: Export of Popover is straightforward and correct.

The component is correctly exported as a direct alias for PopoverPrimitive.Root, maintaining simplicity and consistency.


8-8: Export of PopoverTrigger is straightforward and correct.

The component is correctly exported as a direct alias for PopoverPrimitive.Trigger, ensuring consistency with Radix UI's design.


10-27: PopoverContent component is well-implemented.

The component uses forwardRef correctly, and the styling is handled through a utility function, ensuring flexibility and maintainability.

packages/design-system/src/ui/button.tsx (2)

7-34: buttonVariants utility is well-structured.

The utility provides a flexible and maintainable approach to styling buttons with different variants and sizes.


42-54: Button component is well-implemented.

The component uses forwardRef and buttonVariants effectively, and the asChild prop adds flexibility.

packages/design-system/src/ui/popover.stories.tsx (1)

12-53: Default story for Popover is well-constructed.

The story provides a clear and comprehensive example of the Popover component's usage, demonstrating its integration with other design system components.

packages/design-system/src/ui/calendar.tsx (2)

10-60: LGTM! Ensure accessibility compliance.

The Calendar component implementation looks good. Ensure that the component is accessible, focusing on keyboard navigation and screen reader compatibility.


5-6: Verify utility functions.

Ensure that the utility functions cn and buttonVariants are robust and handle edge cases gracefully.

Verification successful

Utility Functions Verified

The utility functions cn and buttonVariants are implemented robustly. The cn function effectively merges class names using twMerge and clsx, while buttonVariants is a well-structured constant using cva for styling variants.

  • cn is located in packages/design-system/src/lib/utils.ts.
  • buttonVariants is defined in packages/design-system/src/ui/button.tsx.

These implementations ensure flexibility and maintainability in styling components.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the robustness of utility functions `cn` and `buttonVariants`.

# Test: Search for the utility function implementations. Expect: Proper handling of edge cases.
rg --type javascript --type typescript --pattern $'function cn' -A 5
rg --type javascript --type typescript --pattern $'function buttonVariants' -A 5

Length of output: 975


Script:

#!/bin/bash
# Description: Verify the robustness of utility functions `cn` and `buttonVariants`.

# Test: Search for the utility function implementations. Expect: Proper handling of edge cases.
rg 'function cn' --type javascript --type typescript -A 5
rg 'function buttonVariants' --type javascript --type typescript -A 5

Length of output: 201


Script:

#!/bin/bash
# Description: Verify the robustness of utility functions `cn` and `buttonVariants`.

# Test: Search for the utility function implementations. Expect: Proper handling of edge cases.
rg 'function cn' --type js --type ts -A 5
rg 'function buttonVariants' --type js --type ts -A 5

Length of output: 298


Script:

#!/bin/bash
# Description: Search for `buttonVariants` as a variable or import.

# Test: Search for `buttonVariants` declaration or import. Expect: Find its definition or source.
rg 'buttonVariants' --type js --type ts -A 5

Length of output: 3143

packages/design-system/package.json (1)

11-29: Verify compatibility of updated dependencies.

Ensure that the updated and newly added dependencies are compatible with the existing codebase and do not introduce any breaking changes.

packages/design-system/src/ui/navigation-menu.stories.tsx (1)

1-140: LGTM! Verify story configuration.

The story for NavigationMenu is well-structured. Ensure that the configuration accurately reflects the intended use cases and that all components are correctly set up.

packages/design-system/src/ui/navigation-menu.tsx (9)

26-39: LGTM!

The NavigationMenuList component is straightforward and uses Radix UI primitives effectively.


41-41: LGTM!

The NavigationMenuItem component is a simple re-export of the Radix UI primitive, which is appropriate.


43-45: LGTM!

The navigationMenuTriggerStyle definition is comprehensive and uses Tailwind CSS classes effectively.


65-78: LGTM!

The NavigationMenuContent component effectively uses animations and Radix UI primitives.


80-80: LGTM!

The NavigationMenuLink component is a simple re-export of the Radix UI primitive, which is appropriate.


47-63: LGTM! Verify ChevronDown icon behavior.

The NavigationMenuTrigger component is well-implemented and uses Radix UI primitives effectively.

However, ensure that the ChevronDown icon rotates correctly on state changes.

Verification successful

ChevronDown Icon Behavior Verified

The ChevronDown icon in the NavigationMenuTrigger component rotates correctly on state changes, as indicated by the group-data-[state=open]:rotate-180 class. No further issues were found.

  • Location: packages/design-system/src/ui/navigation-menu.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the behavior of the `ChevronDown` icon in `NavigationMenuTrigger`.

# Test: Search for the `ChevronDown` icon usage. Expect: Correct rotation on state changes.
rg --type javascript --type typescript -A 5 $'ChevronDown'

Length of output: 92


Script:

#!/bin/bash
# Description: Verify the behavior of the `ChevronDown` icon in `NavigationMenuTrigger`.

# Corrected Test: Search for the `ChevronDown` icon usage. Expect: Correct rotation on state changes.
rg --type js --type ts -A 5 'ChevronDown'

Length of output: 4178


100-116: LGTM! Verify indicator animations and positioning.

The NavigationMenuIndicator component is well-implemented and uses Radix UI primitives effectively.

However, ensure that the indicator's animations and positioning are correct.


82-98: LGTM! Verify viewport positioning.

The NavigationMenuViewport component is well-structured and uses Radix UI primitives effectively.

However, ensure that the viewport is positioned correctly within the navigation menu.


8-23: LGTM! Verify cn utility function usage.

The NavigationMenu component is well-structured and uses Radix UI primitives effectively.

However, ensure that the cn utility function is correctly implemented to handle class name concatenation.

Verification successful

The cn utility function is correctly implemented.

The cn function uses twMerge and clsx to handle class name concatenation effectively. This ensures that Tailwind CSS classes are merged correctly and conditional class names are handled properly. No issues found with the implementation.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the `cn` utility function.

# Test: Search for the `cn` function implementation. Expect: Correct handling of class name concatenation.
rg --type javascript --type typescript -A 5 $'function cn'

Length of output: 94


Script:

#!/bin/bash
# Description: Verify the implementation of the `cn` utility function.

# Test: Search for the `cn` function implementation. Expect: Correct handling of class name concatenation.
rg --type typescript --type typescriptreact -A 5 $'function cn'

Length of output: 99


Script:

#!/bin/bash
# Description: Locate and verify the implementation of the `cn` utility function.

# Find all TypeScript and TSX files and search for the `cn` function.
fd --extension ts --extension tsx --exec rg -A 5 $'function cn' {}

Length of output: 148

Comment on lines +118 to +128
export {
navigationMenuTriggerStyle,
NavigationMenu,
NavigationMenuList,
NavigationMenuItem,
NavigationMenuContent,
NavigationMenuTrigger,
NavigationMenuLink,
NavigationMenuIndicator,
NavigationMenuViewport,
}
Copy link

Choose a reason for hiding this comment

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

Consider separating navigationMenuTriggerStyle into a different file.

Fast refresh only works when a file only exports components. Consider moving navigationMenuTriggerStyle to a separate file to adhere to best practices.

Tools
GitHub Check: Lint

[warning] 119-119:
Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components

@rschlaefli rschlaefli closed this Aug 8, 2024
@rschlaefli rschlaefli deleted the shadcn branch August 9, 2024 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant