Skip to content

Conversation

@ErfanKashef
Copy link
Contributor

@ErfanKashef ErfanKashef commented Feb 21, 2025

close

Summary by CodeRabbit

  • New Features
    • Introduced a new UI page with an interactive dropdown for selecting sort criteria (e.g., Popularity, Highest price, Lowest price) alongside an input field with descriptive labels and helper text.
    • Added Storybook stories for the Select component, showcasing standard and custom styling variations.
  • Style
    • Enhanced the consistency and appearance of input and selection elements, ensuring a polished and cohesive user experience.

@mrbadri mrbadri self-requested a review February 21, 2025 08:46
@mrbadri
Copy link
Contributor

mrbadri commented Feb 21, 2025

This pull request is related to issue #251

Closes #251

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

The pull request introduces a new React component named Page in apps/core/app/test/page.tsx, which renders a container with a Select dropdown (offering release date-related options) and an Input field with label and helper text. Additionally, modifications in the UI library improve styling consistency by updating the variant definitions in the Base Input component and standardizing formatting, border radii, and class assignments in the Select component. A new Storybook file for the Select component is also created.

Changes

File(s) Change Summary
apps/core/.../page.tsx Added new React component Page rendering a container with a Select dropdown (with items like “Popularity”, “Highest price”, “Lowest price”) and an Input field with label.
packages/ui/.../base-input.tsx
packages/ui/.../select.tsx
Improved styling and formatting; updated BaseInputProps and integrated error variant with size variants in Base Input; standardized semicolon usage, border radius, and class names in Select.
apps/storybook/.../select.stories.tsx Added new Storybook file with Default and WithCustomStyling stories for the Select component, showcasing standard and custom-styled variants.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant P as Page Component
    participant S as Select Dropdown
    participant I as Input Field

    U->>P: Request page render
    P->>S: Render Select with release options
    P->>I: Render Input with label/helper text
    U->>S: Open dropdown and select option
    U->>I: Enter text into Input field
Loading

Suggested reviewers

  • mrbadri

Poem

Oh, what a hop in the code today,
A brand-new Page leads the way,
Select and Input dance in neat array,
With styling crisp as morning ray,
This rabbit cheers—code leaps, hip-hip-hooray! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

Scope: all 2 workspace projects
 ERR_PNPM_FETCH_404  GET http://10.0.0.28:4873/@repo%2Feslint-config: Not Found - 404

This error happened while installing a direct dependency of /tmp/eslint

@repo/eslint-config is not in the npm registry, or you have no permission to fetch it.

No authorization header was set for the request.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d77152 and dea5840.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (4)
  • apps/core/app/test/page.tsx (1 hunks)
  • apps/storybook/src/stories/select.stories.tsx (1 hunks)
  • packages/ui/src/components/atoms/base-input.tsx (1 hunks)
  • packages/ui/src/components/atoms/select.tsx (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/core/app/test/page.tsx
  • packages/ui/src/components/atoms/base-input.tsx
  • apps/storybook/src/stories/select.stories.tsx
  • packages/ui/src/components/atoms/select.tsx

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 2

🔭 Outside diff range comments (1)
apps/core/app/test/page.tsx (1)

1-34: 💡 Verification agent

🧩 Analysis chain

Add proper testing setup

Since this is a test page, consider adding proper test cases using React Testing Library or similar testing framework.


🏁 Script executed:

#!/bin/bash
# Check if testing libraries are installed
npm list @testing-library/react @testing-library/jest-dom

# Check for existing test files
find . -name "*.test.tsx" -o -name "*.spec.tsx"

Length of output: 167


Action Required: Set Up Testing for the Page Component

There are no testing libraries installed and no test files detected, so please add a proper testing setup. Consider the following:

  • Install Testing Libraries: Add packages like @testing-library/react and @testing-library/jest-dom to your project dependencies.
  • Write Test Cases: Create test files (e.g., page.test.tsx) for the component, covering key interactions and UI rendering.
  • Setup Test Runner: Configure your project to run tests (using Jest or a similar framework) to ensure future changes don’t break expected functionality.
🧹 Nitpick comments (4)
packages/ui/src/components/atoms/base-input.tsx (2)

6-10: Add TypeScript documentation

Consider adding JSDoc comments to improve code documentation and IDE support.

+/**
+ * Base input props interface extending HTML input attributes
+ * @property {boolean} error - Indicates if the input is in an error state
+ */
 export interface BaseInputProps
   extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
     VariantProps<typeof baseInputVariants> {
   error?: boolean;
 }

12-29: Optimize focus transition and error state visibility

  1. The transition duration of 500ms for focus state might feel slow
  2. Consider adding a subtle background color change for error state
 export const baseInputVariants = cva(
-  "flex h-10 w-full bg-card rounded-md border border-border ring-offset-background file:border-0 file:bg-transparent  transition-shadow duration-500 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 text-sm file:text-sm placeholder:text-muted-foreground font-normal file:font-medium focus:ring-2 focus:ring-primary focus:ring-offset-2",
+  "flex h-10 w-full bg-card rounded-md border border-border ring-offset-background file:border-0 file:bg-transparent transition-shadow duration-200 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 text-sm file:text-sm placeholder:text-muted-foreground font-normal file:font-medium focus:ring-2 focus:ring-primary focus:ring-offset-2",
   {
     variants: {
       size: {
         sm: "px-4 py-2.5 h-9",
         md: "px-4 py-2.5 h-[52px]",
         lg: "px-4 py-4 h-14",
       },
       error: {
-        true: "ring-2 ring-error focus-visible:ring-error focus-visible:ring-offset-2",
+        true: "ring-2 ring-error focus-visible:ring-error focus-visible:ring-offset-2 bg-error/5",
       },
     },
     defaultVariants: {
       size: "md",
     },
   },
 );
packages/ui/src/components/atoms/select.tsx (2)

23-26: Improve hover states and touch targets

The SelectTrigger could benefit from:

  1. Hover state styling
  2. Larger touch targets for mobile users (minimum 44px as per WCAG)
 className={cn(
-  "flex h-10 w-full items-center justify-between rounded-lg border border-input  px-3 py-2 text-sm  placeholder:text-muted-foreground focus:outline-none  disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
+  "flex h-11 w-full items-center justify-between rounded-lg border border-input px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 hover:bg-muted/50 transition-colors",
   baseInputVariants({ size: "sm" }),
   className,
 )}

80-81: Ensure consistent border radius

The SelectContent uses a different border radius than the trigger. Consider using the same radius for visual consistency.

 className={cn(
-  "relative  z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border bg-card text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+  "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-lg border bg-card text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2405b94 and 1002c9f.

📒 Files selected for processing (3)
  • apps/core/app/test/page.tsx (1 hunks)
  • packages/ui/src/components/atoms/base-input.tsx (1 hunks)
  • packages/ui/src/components/atoms/select.tsx (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: merge-pr

Copy link
Contributor

@mrbadri mrbadri left a comment

Choose a reason for hiding this comment

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

@ErfanKashef
Please Add Select Component in Storybook
same Button Component

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

🧹 Nitpick comments (2)
apps/storybook/src/stories/select.stories.tsx (2)

51-63: Consider adding more customization examples.

The custom styling example demonstrates Tailwind class customization well, but consider expanding it to showcase more advanced customization scenarios such as different sizes, states (disabled, error), or custom dropdown positioning.


1-64: Missing accessibility testing scenarios.

The stories should include examples demonstrating keyboard navigation, screen reader support, and ARIA attributes handling. This ensures the component meets accessibility standards.

Consider adding examples like:

export const WithAccessibilityFeatures: Story = {
  render: () => (
    <div>
      <label id="fruit-label">Select a fruit</label>
      <Select aria-labelledby="fruit-label">
        <SelectTrigger>
          <SelectValue placeholder="Choose a fruit" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="apple">Apple</SelectItem>
          <SelectItem value="banana">Banana</SelectItem>
          <SelectItem value="orange">Orange</SelectItem>
        </SelectContent>
      </Select>
      <p className="text-sm text-gray-500 mt-1">
        Press Tab to focus, Space to open, and Arrow keys to navigate
      </p>
    </div>
  ),
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1002c9f and 6d77152.

⛔ Files ignored due to path filters (1)
  • bun.lockb is excluded by !**/bun.lockb
📒 Files selected for processing (1)
  • apps/storybook/src/stories/select.stories.tsx (1 hunks)
🔇 Additional comments (3)
apps/storybook/src/stories/select.stories.tsx (3)

1-12: Good component organization.

The imports are well-structured with appropriate grouping - React core, Storybook utilities, and the Select component with its subcomponents. This follows best practices for import organization.


14-21: Proper Storybook metadata setup.

The metadata configuration is well-structured with appropriate title, tags, and control parameters. The use of autodocs tag will automatically generate documentation for this component, which is excellent for maintainability.


27-49: Well-structured Select component demonstration.

The Default story showcases a complete implementation with proper component hierarchy, including groups, labels, items, and separators. This provides a good reference for developers who will use this component.

@ErfanKashef ErfanKashef force-pushed the feat/#251-Select-Component branch from 6d77152 to dea5840 Compare February 25, 2025 19:23
@ErfanKashef ErfanKashef merged commit d60b808 into main Feb 25, 2025
0 of 3 checks passed
@ErfanKashef ErfanKashef deleted the feat/#251-Select-Component branch February 25, 2025 19:26
@mrbadri
Copy link
Contributor

mrbadri commented Feb 25, 2025

Closes #251

@mrbadri
Copy link
Contributor

mrbadri commented Feb 25, 2025

Close #251

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.

3 participants