-
Notifications
You must be signed in to change notification settings - Fork 32
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
[WIP] feat(Toggle): Implement base component #3860
Conversation
✅ Deploy Preview for storybook-navy-digital-mod-uk ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great start! A few important things we need to consider:
- Usage within forms and integration with different supported form libraries.
- Understanding the difference between controlled and uncontrolled and supporting them.
- It might be worth using an
input type="checkbox"
(rememberdefaultChecked
). - Make sure the component supports a
forwardedRef
. - Check it plays nice with the
Field
wrapper component. - Update form usage examples and Playwright tests.
- Make sure the appropriate ARIA and other a11y attributes are applied to the control.
- The user should be able to manipulate the component solely by using the keyboard.
- Styled focus state is missing.
- The component should support an error state.
- Red outline (see other form controls).
Very happy for you to continue rolling your own implementation as a learning exercise, but we need to make sure to address all of the stuff above. There is quite a lot to consider, which is why I suggested styling a hardened headless implementation like the Radix one:
https://github.com/radix-ui/primitives/blob/main/packages/react/switch/src/Switch.tsx
e6ba17f
to
b4badca
Compare
eeddec5
to
a7bfc30
Compare
feat(Toggle): Created Toggle component feat(Toggle): Created Toggle component feat(Toggle): Working on spacing issues feat(Toggle): Working on spacing issues feat(Toggle): Spacing feat(Toggle): Added Aria labels feat(Toggle): Added test file feat(Toggle): Added toggle to formik story feat(Toggle): Centering Icons in Knobs feat(Toggle): Scaled toggle to be bigger feat(Toggle): Added keyboard handling feat(Toggle): Updated test file feat(Toggle): Updated toggle component feat(Toggle): updated toggle test file feat(Toggle): Updated form tests feat(Toggle): Fixed cursor issues with disabled component feat(Toggle): Updated form tests
a7bfc30
to
04543e5
Compare
Quality Gate passedIssues Measures |
Related issue
Closes #3859
Overview
Created a Toggle component
Reason
To add a Toggle component to the design system
Work carried out
Example.
Screenshot
Screen.Recording.2024-08-15.at.18.03.38.mov
Developer notes
At the next major release, we should change the name of this component to Switch and change the current Switch component to ToggleGroup / Toggle