Skip to content

Added slider component #50

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

Merged
merged 3 commits into from
Apr 9, 2025
Merged

Conversation

ahmrafi22
Copy link
Contributor

@ahmrafi22 ahmrafi22 commented Mar 25, 2025

Simplified the design by removing the value tooltip, so all custom logic related to showing the value is no longer included. Only installed the @radix-ui/react-slider dependency using pnpm add @radix-ui/react-slider.

Summary by CodeRabbit

  • New Features

    • A customizable slider component has been added to enhance the UI experience. It supports adjustable minimum, maximum, and default values, and comes in two styling variants—default and thin—for versatile usage and improved accessibility.
  • Documentation

    • Comprehensive guides and live examples are now available, offering clear installation instructions and usage tips to help seamlessly integrate the new slider into your projects.

Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces a new customizable Slider component built with React and the @radix-ui/react-slider library. The component supports two variants ("default" and "thin") and is designed using forwardRef and useMemo hooks for controlled rendering. Additionally, export indexes and configuration files are updated to include the Slider, while documentation and preview examples are added to showcase its usage. The project’s dependency list is also updated to support the new slider functionality.

Changes

File(s) Change Summary
components/ui/Slider/Slider.tsx
components/ui/Slider/index.ts
Added a new Slider component with support for "default" and "thin" variants; introduced a module index export.
components/ui/index.ts Updated to export the newly added Slider component.
config/components.ts Added a new slider configuration with its dependency and file path; included examples for default and thin slider styles.
content/docs/components/slider.mdx Created documentation for the Slider component, including installation instructions and usage examples.
package.json Added the dependency "@radix-ui/react-slider": "^1.2.3".
preview/components/slider-style-default.tsx
preview/components/slider-style-thin.tsx
Introduced new preview components to demonstrate the default and thin slider styles.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant P as Parent Component
    participant S as Slider Component
    participant R as Radix Slider Primitive

    U->>P: Request slider display
    P->>S: Render Slider with props (defaultValue, min, max, variant)
    S->>R: Initialize Radix Slider (via forwardRef)
    R-->>S: Render track, thumb, and feedback elements
    S-->>P: Expose rendered DOM for further interactions
    U->>S: Interact with slider (drag thumb)
    S->>R: Update slider value via internal state
    R-->>S: Return updated state to reflect UI changes
Loading

Possibly related PRs

  • Added slider component #50: The changes in the main PR are directly related to those in the retrieved PR as both introduce a new Slider component in the same file and utilize the @radix-ui/react-slider library, although the retrieved PR simplifies the design by removing the value tooltip.

Poem

I'm a hopping rabbit with a code-filled heart,
Sliding through changes, a brand new start.
Two styles abound—default and thin,
With every movement, new magic within.
Bugs nibbled away, now all's fresh and new,
A carrot of praise for the team that pulled it through!
Hooray for sliders that smoothly glide!


📜 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 83e8967 and 5865fec.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • components/ui/index.ts (1 hunks)
  • config/components.ts (2 hunks)
  • package.json (1 hunks)

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 4

🔭 Outside diff range comments (1)
components/ui/index.ts (1)

2-10: ⚠️ Potential issue

Unrelated issue: Duplicate export for Input component.

There's a duplicate export for the Input component on lines 2 and 9. While this isn't related to your current changes, it should be fixed to avoid potential issues.

export * from "./Button";
export * from "./Input";
export * from "./Textarea";
export * from "./Checkbox";
export * from "./Radio";
export * from "./Select";
export * from "./Switch";
export * from "./Label";
-export * from "./Input";
export * from "./Text";
🧹 Nitpick comments (1)
content/docs/components/slider.mdx (1)

4-4: Future date in lastUpdated field.

The lastUpdated date is set to "25 Mar, 2025", which is in the future. Consider updating it to the current date or removing the specific date until release.

-lastUpdated: 25 Mar, 2025
+lastUpdated: March 2024
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 346e014 and 42f1a5e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • components/ui/Slider/Slider.tsx (1 hunks)
  • components/ui/Slider/index.ts (1 hunks)
  • components/ui/index.ts (1 hunks)
  • config/components.ts (2 hunks)
  • content/docs/components/slider.mdx (1 hunks)
  • package.json (1 hunks)
  • preview/components/slider-style-default.tsx (1 hunks)
  • preview/components/slider-style-thin.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
preview/components/slider-style-default.tsx (1)
preview/components/slider-style-thin.tsx (1)
  • SliderDefault (4-25)
🔇 Additional comments (12)
components/ui/Slider/index.ts (1)

1-1: The barrel file pattern is correctly implemented.

This export statement follows the standard practice for component libraries, making the Slider component easily importable by consumers.

components/ui/index.ts (1)

19-19: Export correctly added for the new Slider component.

The Slider component export maintains consistency with the established pattern in this file.

package.json (1)

22-22: Radix UI slider dependency correctly added.

The dependency is added with proper versioning and maintains alphabetical ordering in the dependencies section.

content/docs/components/slider.mdx (1)

1-54: Documentation structure is comprehensive and well-organized.

The documentation follows the established pattern for component docs, including metadata, installation instructions (both CLI and manual), and examples showing the component variants.

preview/components/slider-style-thin.tsx (1)

1-25: LGTM! A well-structured thin slider component.

The SliderDefault component correctly implements a thin variant of the slider with appropriate styling and accessibility attributes. The component structure follows React best practices with proper organization and component composition.

preview/components/slider-style-default.tsx (1)

1-25: LGTM! Clean implementation of the default slider variant.

The component correctly implements the default slider variant with proper structure and accessibility attributes. Both slider examples (this and the thin variant) maintain consistent properties with only the necessary variations.

components/ui/Slider/Slider.tsx (5)

7-17: LGTM! Well-defined variant styling using CVA.

The slider variants are appropriately defined using class-variance-authority, allowing for good style encapsulation and reuse.


19-23: LGTM! Clear and concise type definition.

The SliderProps interface properly extends the Radix UI Slider props while adding the variant property.


24-49: LGTM! Well-implemented component using forwardRef and useMemo.

The component correctly uses React's forwardRef API for DOM access and efficiently handles value calculations with useMemo. The default values are appropriately handled, and the component properly accepts and processes all expected props.


50-93: LGTM! Clean JSX structure with proper styling classes.

The rendering logic is well-organized with appropriate class names applied conditionally based on variants. The component structure follows accessibility best practices, and the slider elements (track, range, thumb) are correctly styled.


96-98: LGTM! Proper component naming.

The displayName property is correctly set for better debugging experience in React DevTools.

config/components.ts (1)

309-322: LGTM! Properly configured slider examples.

The slider examples are correctly configured with appropriate names, file paths, and lazy loading of preview components.

<ComponentInstall>
<ComponentInstall.Cli>
```sh
npx shadcn@latest add "https://retroui.dev/r/slider.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the CLI installation URL.

The CLI installation command references a URL to a JSON file that might not exist yet for this new component. Please verify that this URL will be valid when the PR is merged.


🏁 Script executed:

#!/bin/bash
# Check if the slider.json file exists or is planned to be created
curl -s -o /dev/null -w "%{http_code}" https://retroui.dev/r/slider.json

Length of output: 78


Action Required: Fix the CLI installation URL for slider.json

The verification shows that the URL https://retroui.dev/r/slider.json currently returns a 404 error, meaning the JSON file is not found. Please update the URL to the correct endpoint or ensure the JSON file is created and accessible by the time this PR is merged.

  • File: content/docs/components/slider.mdx
  • Location: Line 19
  • Snippet:
        npx shadcn@latest add "https://retroui.dev/r/slider.json"

Comment on lines +78 to +82
slider: {
name: "slider",
dependencies: ["@radix-ui/react-slider"],
filePath: "components/ui/Slider.tsx",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the file path for the slider component.

The file path in the configuration doesn't match the actual implementation path. The slider component is implemented in "components/ui/Slider/Slider.tsx" but referenced as "components/ui/Slider.tsx".

  slider: {
    name: "slider",
    dependencies: ["@radix-ui/react-slider"],
-    filePath: "components/ui/Slider.tsx",
+    filePath: "components/ui/Slider/Slider.tsx",
  }
📝 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
slider: {
name: "slider",
dependencies: ["@radix-ui/react-slider"],
filePath: "components/ui/Slider.tsx",
}
slider: {
name: "slider",
dependencies: ["@radix-ui/react-slider"],
filePath: "components/ui/Slider/Slider.tsx",
}

ahmrafi22 and others added 2 commits March 25, 2025 17:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@ariflogs ariflogs merged commit ecf1e27 into Logging-Stuff:main Apr 9, 2025
@coderabbitai coderabbitai bot mentioned this pull request Apr 17, 2025
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