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

Adding Radio Input component #27

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

Conversation

ivyalin2015
Copy link

@ivyalin2015 ivyalin2015 commented Dec 15, 2024

Adding Radio Input component

♻️ Current situation & Problem

Add Radio input component

⚙️ Release Notes

  • Allows users to select one option from a dropdown list with as many items as desired
  • Uses standardized coloring
  • closes Add Radio input component #16

📚 Documentation

Please ensure that you properly document any additions in conformance to Spezi Documentation Guide.

This RadioInput component provides a template to create a multiple choice question.
image

✅ Testing

Please ensure that the PR meets the testing requirements set by CodeCov and that new functionality is appropriately tested.
My tests mainly focus on rendering but do not include confirmation that different items can be selected.

📝 Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

@ivyalin2015 ivyalin2015 changed the title Audrey/checkbox Adding Radio Input component Dec 15, 2024
@arkadiuszbachorski arkadiuszbachorski self-requested a review January 2, 2025 18:02
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/components/Checkbox/Checkbox.stories.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.stories.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.stories.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.stories.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.tsx Outdated Show resolved Hide resolved
src/RadioInput/RadioInput.tsx Outdated Show resolved Hide resolved
@arkadiuszbachorski
Copy link
Collaborator

@ivyalin2015 Thank you for working on this! I left couple comments, could you please address them?

Copy link
Collaborator

@arkadiuszbachorski arkadiuszbachorski left a comment

Choose a reason for hiding this comment

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

We also need index.tsx file in the Radio directory that exports Radio components. This is necessary, because we want components/Radio to be a module itself.

Furthermore, we need Checkbox to be exported from src/index.tsx (to make it accessible from @stanfordspezi/spezi-web-design-system module) and from package.json (to make it accessible as @stanfordspezi/spezi-web-design-system/components/Radio).

Referencing this PR should help: https://github.com/StanfordSpezi/spezi-web-design-system/pull/36/files

package.json Outdated
@@ -206,11 +206,13 @@
"@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't need these dependencies.

src/components/Radio/Radio.tsx Outdated Show resolved Hide resolved
…el in storybook

SideLabel formatting caused the text + indicator not to be centered
@ivyalin2015
Copy link
Author

Ready for another check! I had to modify one of the formatting features in SideLabel for this request. SideLabel.stories.tsx might need some styling edits for the Storybook so that the text and switch are centered.

@arkadiuszbachorski arkadiuszbachorski self-requested a review January 29, 2025 20:52
Copy link
Collaborator

@arkadiuszbachorski arkadiuszbachorski left a comment

Choose a reason for hiding this comment

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

Thank you for iterating on this. We're almost there!

src/components/Radio/Radio.stories.tsx Outdated Show resolved Hide resolved
src/components/SideLabel/SideLabel.tsx Show resolved Hide resolved
src/components/Radio/Radio.tsx Outdated Show resolved Hide resolved
src/components/Radio/Radio.tsx Outdated Show resolved Hide resolved
src/components/Radio/Radio.tsx Outdated Show resolved Hide resolved
src/components/Radio/Radio.test.tsx Outdated Show resolved Hide resolved
src/components/Radio/Radio.test.tsx Show resolved Hide resolved
src/components/Radio/Radio.stories.tsx Show resolved Hide resolved
src/components/Radio/Radio.stories.tsx Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Collaborator

@arkadiuszbachorski arkadiuszbachorski left a comment

Choose a reason for hiding this comment

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

There are still conflicts in this branch. Please merge StanfordSpezi:main into your branch, using git merge.

Afterwards, please make sure that Radio is exposed in the package.json in the exports.

That should be the last steps! :)


export const Default = () => (
<RadioGroup
className="flex flex-col space-y-4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is still a className here

Comment on lines +35 to +44
const option1 = screen.getByTestId('option1')
const option2 = screen.getByTestId('option2')

fireEvent.click(option1)
expect(option1).toBeChecked()
expect(option2).not.toBeChecked()

fireEvent.click(option2)
expect(option2).toBeChecked()
expect(option1).not.toBeChecked()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good job! 🚀

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.

Add Radio input component
2 participants