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

feat(radio-group): migrate to signals #500

Merged
merged 3 commits into from
Nov 29, 2024
Merged

feat(radio-group): migrate to signals #500

merged 3 commits into from
Nov 29, 2024

Conversation

ashley-hunter
Copy link
Collaborator

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • button
  • calendar
  • card
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • hover-card
  • icon
  • input
  • label
  • menubar
  • navigation-menu
  • pagination
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • sonner
  • spinner
  • switch
  • table
  • tabs
  • textarea
  • toast
  • toggle
  • tooltip
  • typography

What is the current behavior?

Closes #442

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I have migrated these directives to use signals, and have been able to significantly reduce the amount of code required. One change I did make - I can revert if we feel its important to retain - but essentially there was the assumption that a radio button may be used without a group. Personally I don't ever think I have seen an instance where a single radio button is used, as typically that would be what a checkbox is for. Accommodating the potential case for a standalone radio button results in potentially multiple sources of truth, for example, a radio button has a checked state and the group has a value representing which item should be checked. We can always make the group take preference, however this does add a lot of additional code and complexity for a case I don't believe is likely to occur. I'd be interested to hear if anyone has any strong feelings in retaining that functionality, and if so I can restore it.

@ashley-hunter ashley-hunter marked this pull request as ready for review November 26, 2024 22:56
@marcjulian
Copy link
Contributor

This refactoring to signals looks really clean! I will close #344 for now. Perhaps with the new structure it will be easier to implement the changes to support card layouts (#246) and hlm components

e.g.

<hlm-radio-group>
  <hlm-radio value="16.1.4">
    <hlm-radio-indicator indicator />
    v16.1.4
  </hlm-radio>
</hlm-radio-group>

Copy link
Collaborator

@goetzrobin goetzrobin left a comment

Choose a reason for hiding this comment

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

Couple minor comments. I think this looks great!

@ashley-hunter
Copy link
Collaborator Author

Thanks, feedback addressed. If this is something we want to make consistent, we could add an eslint rule to enforce explicit method return types.

@goetzrobin
Copy link
Collaborator

Thanks, feedback addressed. If this is something we want to make consistent, we could add an eslint rule to enforce explicit method return types.

I am a fan of being as explicit as possible so I am down, but as always happy to hear everyone's thoughts!

@goetzrobin goetzrobin merged commit b24f65c into main Nov 29, 2024
6 of 7 checks passed
@ashley-hunter
Copy link
Collaborator Author

I am a fan of being as explicit as possible so I am down, but as always happy to hear everyone's thoughts!

I tend to agree, particularly in a library, it can help prevent unexpected breaking changes due to method signatures changing, but yes, we can get consensus one way or the other and then make it consistent.

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.

refactor(radiogroup): migration to signals
3 participants