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

Allow boolean type on radio button values #1430

Closed
wants to merge 1 commit into from
Closed

Allow boolean type on radio button values #1430

wants to merge 1 commit into from

Conversation

3ximus
Copy link

@3ximus 3ximus commented Sep 11, 2024

📑 Description

This PR just adds the boolean type to a radio button. It should be possible to have a 2 options radio button group that saves the true false.
It seems like it would be possible anyway but the lsp typechecker throws some errors.

Status

  • Not Completed
  • Completed

✅ Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • I have checked the page with https://validator.unl.edu/
  • All the tests have passed
  • My pull request is based on the latest commit (not the npm version).

Summary by CodeRabbit

  • New Features

    • Enhanced the RadioButton component to accept boolean values for the group and value properties, increasing flexibility in usage.
  • Documentation

    • Updated documentation to reflect the new capabilities of the RadioButton component, ensuring users are informed about the expanded property types.

Copy link

vercel bot commented Sep 11, 2024

@3ximus is attempting to deploy a commit to the Themesberg Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Sep 11, 2024

Walkthrough

The changes involve updating the RadioButton.svelte component and its corresponding JSON configuration to allow the group and value properties to accept boolean types in addition to string and number types. This modification broadens the input flexibility for these properties while maintaining existing default values. Documentation comments have been revised to reflect these updates.

Changes

Files Change Summary
src/lib/forms/RadioButton.svelte Updated group and value properties to accept boolean in addition to string and number.
src/routes/component-data/RadioButton.json Modified group and value properties to include boolean type in the JSON configuration.

Poem

🐇 In the meadow where radios play,
A new type joins the fray today.
Strings and numbers, now a trio,
With booleans hopping, oh what a show!
Flexibility blooms, like flowers in spring,
Our RadioButton dances, ready to sing! 🎶


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 235523d and ccf30de.

Files selected for processing (2)
  • src/lib/forms/RadioButton.svelte (2 hunks)
  • src/routes/component-data/RadioButton.json (1 hunks)
Additional comments not posted (6)
src/routes/component-data/RadioButton.json (2)

1-1: LGTM: The group property now accepts boolean values.

The changes to the group property are approved. Allowing boolean values in addition to string and number types provides more flexibility for configuring radio button groups.

The default value of an empty string is still appropriate.


1-1: LGTM: The value property now accepts boolean values.

The changes to the value property are approved. Allowing boolean values in addition to string and number types provides more flexibility for configuring radio button values.

The default value of an empty string is still appropriate.

src/lib/forms/RadioButton.svelte (4)

6-6: LGTM!

The changes to the group prop are approved. Allowing boolean values in addition to string and number values aligns with the PR objective.


7-7: LGTM!

The changes to the value prop are approved. Allowing boolean values in addition to string and number values aligns with the PR objective.


46-46: Documentation looks good!

The documentation for the group prop has been updated correctly to reflect the code changes.


47-47: Documentation looks good!

The documentation for the value prop has been updated correctly to reflect the code changes.


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

vercel bot commented Sep 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
flowbite-svelte ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 21, 2024 2:49pm

@shinokada
Copy link
Collaborator

Radio buttons are used for selecting one option from multiple choices, which is typically represented by strings or numbers. Booleans are more commonly used with checkboxes.
Using booleans for radio button values might be less intuitive for other developers using the component.
We have Toggle component for this one as well.

@3ximus
Copy link
Author

3ximus commented Sep 22, 2024

I agree with you that on most cases a Toggle would be more appropriate. I have a use-case though where the underlying value is a boolean but presenting a switch it's less clear to the user as to what happens on each boolean value. You can say it should not be a boolean in the first place too, but I feel like it is unnecessary to constraint the value type. If you don't think so and this goes against the design principles feel free to close the PR.

Cheers

@shinokada
Copy link
Collaborator

I think your case is very rare. I suggest to create your own component to suit your situation. I close the PR for now. Thank you for your contribution.

@shinokada shinokada closed this Sep 22, 2024
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