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

Feature switch #381

Merged
merged 15 commits into from
Aug 3, 2024
Merged

Feature switch #381

merged 15 commits into from
Aug 3, 2024

Conversation

jindaljyoti
Copy link
Contributor

@jindaljyoti jindaljyoti commented Jul 15, 2024

I have created the story for switch feature.

Summary by CodeRabbit

  • New Features

    • Introduced a new Switch component for customizable toggle functionality.
  • Documentation

    • Added Storybook documentation showcasing different variants of the Switch component.
  • Style

    • Implemented new styles for the Switch component, enhancing its visual integration and interaction.

Copy link
Contributor

coderabbitai bot commented Jul 15, 2024

Walkthrough

The changes introduce a versatile Switch component to the codebase, complete with TypeScript definitions and a Storybook story for interactive UI testing. This component supports customizable styling through various props and enhances user experience with smooth transitions. Additionally, it includes a new SCSS stylesheet for visual styling, enriching the overall component library.

Changes

Files Summary
src/components/ui/Switch/Switch.tsx Created a Switch component with customizable props and state management, including TypeScript typings.
src/components/ui/Switch/Switch.stories.js Added a Storybook story for the Switch component, showcasing different variants and interactive testing.
styles/themes/components/switch.scss Introduced styling for the Switch component, enhancing its visual representation and user feedback.
styles/themes/default.scss Added an import statement for the new switch.scss file to integrate styles into the theme.

Poem

In the realm of code, a switch now gleams,
With customizable styles, it beams.
Sandbox tales and stories told,
A tiny whitespace, a change so bold.
The UI dances, components sing,
A rabbit’s joy in every string!
🌟🐰✨


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
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 830dbc8 and 1875e6a.

Files selected for processing (1)
  • src/components/ui/Switch/Switch.stories.js (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/components/ui/Switch/Switch.stories.js

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 (1)
src/components/ui/Switch/Switch.tsx (1)

6-11: Review of TypeScript type definition.

The SwitchProps type definition is generally well-formed. However, the props?: any; line could be improved by specifying a more detailed type instead of any to ensure type safety.

Consider replacing any with a more specific type or an interface detailing the expected properties.

Tools
Biome

[error] 8-8: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1875e6a and 7911f20.

Files selected for processing (3)
  • src/components/tools/SandboxEditor/SandboxEditor.js (1 hunks)
  • src/components/ui/Switch/Switch.stories.js (1 hunks)
  • src/components/ui/Switch/Switch.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/Switch/Switch.stories.js
Additional context used
Biome
src/components/ui/Switch/Switch.tsx

[error] 8-8: Don't use 'String' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'string' instead

(lint/complexity/noBannedTypes)

Additional comments not posted (3)
src/components/ui/Switch/Switch.tsx (2)

13-18: Component implementation review.

The Switch component is implemented correctly. It uses destructuring for props and applies a custom class through customClassSwitcher. The JSX structure is simple and correct.


20-21: Component export and display name.

Setting the displayName property is a good practice for debugging React components. The export of the component is also handled correctly.

src/components/tools/SandboxEditor/SandboxEditor.js (1)

54-54: Minor JSX modification review.

The addition of whitespace after the <Separator/> component is a minor change and does not affect functionality. This change is likely for visual or layout improvement in the UI.

src/components/ui/Switch/Switch.tsx Outdated Show resolved Hide resolved
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 7911f20 and 47c2fdb.

Files selected for processing (1)
  • src/components/ui/Switch/Switch.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/Switch/Switch.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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 47c2fdb and d1b923a.

Files selected for processing (4)
  • src/components/ui/Switch/Switch.stories.js (1 hunks)
  • src/components/ui/Switch/Switch.tsx (1 hunks)
  • styles/themes/components/switch.scss (1 hunks)
  • styles/themes/default.scss (1 hunks)
Files skipped from review due to trivial changes (1)
  • styles/themes/default.scss
Additional comments not posted (11)
src/components/ui/Switch/Switch.stories.js (5)

1-2: LGTM!

The import statements are correct and necessary for the functionality of the story.


10-15: LGTM!

The usage of SandboxEditor and mapping of Switch components is correct and shows different variants of the switch.


19-23: LGTM!

The export statement is correct and provides necessary metadata for Storybook.


25-25: LGTM!

The All export is correct and serves as a placeholder for future stories.


4-9: Fix the usage of args parameter.

The args parameter is being used directly as a boolean, which might not always be correct. Consider destructuring args to extract the necessary properties.

- const handleChange = (state) => {
+ const handleChange = (state: boolean) => {

Likely invalid or redundant comment.

styles/themes/components/switch.scss (4)

1-4: LGTM!

The styles for .rad-ui-switch are correct and necessary for the functionality of the switch.


6-12: LGTM!

The styles for .rad-ui-switch + button are correct and necessary for the functionality and appearance of the switch.


14-22: LGTM!

The styles for .rad-ui-switch + button::before are correct and necessary for the appearance and transition effects of the switch.


24-46: LGTM!

The styles for .rad-ui-switch + button::after and checked states are correct and necessary for the appearance and transition effects of the switch.

src/components/ui/Switch/Switch.tsx (2)

1-4: LGTM!

The import statements and constant definition are correct and necessary for the functionality of the component.


36-37: LGTM!

The displayName and export statement are correct and necessary for the functionality of the component.

src/components/ui/Switch/Switch.tsx Outdated Show resolved Hide resolved
src/components/ui/Switch/Switch.tsx Outdated Show resolved Hide resolved
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 d1b923a and 32ffc6e.

Files selected for processing (1)
  • src/components/ui/Switch/Switch.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/components/ui/Switch/Switch.tsx

@@ -0,0 +1,46 @@
.rad-ui-switch{
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, we should refactor this

since we're using scss, we can just use 1 base class and nest all the necessary styles inside the base class - we don't need to create independent classes like we do in CSS - scss will take care of bundling it and converting it for us
seems like you are new to SCSS

Take a look at this for better understanding - https://sass-lang.com/documentation/style-rules/

@kotAPI kotAPI merged commit 5838ffd into rad-ui:main Aug 3, 2024
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 26, 2024
@coderabbitai coderabbitai bot mentioned this pull request Nov 11, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 23, 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