Skip to content

Chore/bug fixes #78

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Chore/bug fixes #78

wants to merge 2 commits into from

Conversation

Harman-singh-waraich
Copy link
Contributor

@Harman-singh-waraich Harman-singh-waraich commented May 5, 2025

PR-Codex overview

This PR introduces new features and improvements across various components, including the addition of Form export, enhancements to the Accordion and DraggableList components, and updates to the BigNumberField to support a name prop.

Detailed summary

  • Added export for Form in src/lib/index.ts.
  • Updated Accordion and CustomAccordion to utilize isUndefined for defaultExpanded.
  • Enhanced BigNumberField to include a name prop.
  • Added dragDisabled and deletionDisabled props to DraggableList.
  • Introduced story variants for disabling drag and delete operations in draggable-list.stories.tsx.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Accordion components now support setting a default expanded section.
    • Draggable lists can now have drag-and-drop and deletion features independently disabled.
    • Big number input fields now support a name attribute for improved form integration.
    • Added a central export for the Form component for easier imports.
  • Documentation

    • Storybook stories updated to showcase drag and deletion disabling options for draggable lists.
  • Style

    • Removed slot attributes from increment and decrement button props in big number field controls.

Copy link
Contributor

coderabbitai bot commented May 5, 2025

Walkthrough

The changes introduce new optional properties and improved configurability to several UI components. The CustomAccordion and Accordion components now support a defaultExpanded prop for more precise control over their initial state. The DraggableList component gains two boolean flags, dragDisabled and deletionDisabled, allowing independent enabling or disabling of drag-and-drop and deletion features. The BigNumberField component now accepts a name prop for form integration. Additionally, the Form component is exported from the main index, and Storybook stories for DraggableList are updated to demonstrate the new flags.

Changes

File(s) Change Summary
src/lib/accordion/custom.tsx, src/lib/accordion/index.tsx Added optional defaultExpanded prop to AccordionProps and CustomAccordion; updated state initialization logic to use isUndefined utility for explicit undefined checks.
src/lib/draggable-list/index.tsx Added dragDisabled and deletionDisabled boolean props to DraggableList; updated logic to conditionally disable drag-and-drop and deletion features based on these flags.
src/lib/form/bignumber-field/index.tsx Added optional name prop to BigNumberFieldComponentProps and passed it to the underlying input for form compatibility.
src/lib/form/bignumber-field/useBigNumberField.tsx Removed the slot attribute from increment and decrement button props returned by utility functions.
src/lib/index.ts Added export for Form from "./form/index" to main library index.
src/stories/draggable-list.stories.tsx Added argTypes for dragDisabled and deletionDisabled to DraggableList stories; introduced new stories demonstrating each flag independently.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DraggableList
    participant ListBox

    User->>DraggableList: Render with dragDisabled or deletionDisabled props
    DraggableList->>ListBox: Pass drag hooks if dragDisabled is false
    DraggableList-->>User: Render drag handle if dragDisabled is false
    DraggableList-->>User: Render delete button if deletionDisabled is false
Loading

Suggested reviewers

  • alcercu

Poem

In the garden of code where features grow,
New props have sprouted—just so you know!
Accordions expand with intent declared,
Draggable lists now finely prepared.
A field gets a name for forms to delight,
And stories show toggles in Storybook light.
🐇 Cheers to the team for making it right!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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 or @coderabbitai title 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

netlify bot commented May 5, 2025

Deploy Preview for kleros-v2-ui-storybook ready!

Name Link
🔨 Latest commit 5db1c0c
🔍 Latest deploy log https://app.netlify.com/sites/kleros-v2-ui-storybook/deploys/6818a5cde7ae5400081a9f17
😎 Deploy Preview https://deploy-preview-78--kleros-v2-ui-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

sonarqubecloud bot commented May 5, 2025

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)
src/stories/draggable-list.stories.tsx (2)

41-47: Good demonstration story for disabled drag functionality.

The DragDisabled story effectively showcases the component with drag operations disabled. There's a minor typo in the JSDoc comment - an extra space after dragDisabled.

-/** Drag operations can be disabled with `dragDisabled ` */
+/** Drag operations can be disabled with `dragDisabled` */

49-55: Good demonstration story for disabled deletion functionality.

The DeletionDisabled story effectively showcases the component with delete operations disabled. There's a minor typo in the JSDoc comment - an extra space after deletionDisabled.

-/** Delete operation can be disabled with `deletionDisabled ` */
+/** Delete operation can be disabled with `deletionDisabled` */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0d97b7 and 5db1c0c.

📒 Files selected for processing (7)
  • src/lib/accordion/custom.tsx (2 hunks)
  • src/lib/accordion/index.tsx (2 hunks)
  • src/lib/draggable-list/index.tsx (4 hunks)
  • src/lib/form/bignumber-field/index.tsx (3 hunks)
  • src/lib/form/bignumber-field/useBigNumberField.tsx (0 hunks)
  • src/lib/index.ts (1 hunks)
  • src/stories/draggable-list.stories.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • src/lib/form/bignumber-field/useBigNumberField.tsx
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/lib/accordion/custom.tsx (1)
src/utils/index.ts (1)
  • isUndefined (8-11)
src/lib/accordion/index.tsx (1)
src/utils/index.ts (1)
  • isUndefined (8-11)
🔇 Additional comments (16)
src/lib/index.ts (1)

18-18: LGTM! Form component export added successfully.

The export for the Form component is correctly placed among other form-related exports, following the established pattern in the file. This addition makes the Form component directly importable from the library's main entry point, improving accessibility and consistency.

src/lib/form/bignumber-field/index.tsx (3)

18-19: Good addition of proper documentation.

The JSDoc comment clearly explains the purpose of the new name prop, which is important for developers using this component.


34-34: LGTM! Name prop properly included in component props.

The name prop is correctly added to the component's parameter destructuring.


71-71: LGTM! Name prop correctly passed to Input component.

The name prop is properly passed down to the underlying Input component, enabling proper form integration and HTML form submission.

src/lib/accordion/index.tsx (2)

3-3: Nice import update for consistency.

The addition of isUndefined makes the code more explicit in how it handles undefined/null values.


31-33: Good enhancement in state initialization logic.

Replacing the nullish coalescing operator with an explicit isUndefined check makes the code more consistent with CustomAccordion and clarifies that both null and undefined values for defaultExpanded will result in using -1.

src/lib/accordion/custom.tsx (4)

3-3: Good utility import for consistent null/undefined handling.

Adding the isUndefined utility function import aligns with the approach used in the main Accordion component.


13-13: Nice enhancement with the defaultExpanded prop.

Adding this optional prop improves the component's flexibility by allowing control over which item is initially expanded.


19-19: Good prop handling in component signature.

The defaultExpanded prop is properly destructured from props.


22-24: Improved state initialization with explicit undefined check.

Using isUndefined for state initialization makes the code more explicit about handling both null and undefined values of defaultExpanded.

src/lib/draggable-list/index.tsx (5)

33-36: Well-documented new props with clear purposes.

The addition of dragDisabled and deletionDisabled flags with JSDoc comments clearly explains their purpose, making the component more flexible by allowing independent control over drag and delete operations.


52-53: Good default values maintaining backward compatibility.

Setting both flags to false by default ensures backward compatibility with existing usage of the component, as both drag and delete features remain enabled unless explicitly disabled.


85-85: Correct implementation of drag-and-drop disabling.

The implementation correctly prevents drag functionality by conditionally passing undefined instead of the drag-and-drop hooks when dragDisabled is true.


115-117: Proper visual indication of disabled drag functionality.

The drag handle icon is correctly hidden when drag functionality is disabled, providing a clear visual indication to users that the feature is unavailable.


121-121: Proper implementation of deletion disabling.

The delete button is correctly hidden when deletionDisabled is true, even when the item is hovered, preventing users from attempting to delete items when the feature is disabled.

src/stories/draggable-list.stories.tsx (1)

12-19: Good addition of Storybook controls for new props.

Adding argTypes for the new boolean props provides interactive controls in the Storybook UI, making it easy to test different component states.

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.

1 participant