-
Notifications
You must be signed in to change notification settings - Fork 526
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
Add ToggleSwitch component #1933
Conversation
🦋 Changeset detectedLatest commit: bb78093 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
What do we think of calling it |
docs/content/Switch.mdx
Outdated
/> | ||
<PropsTableRow name="defaultOn" type="boolean" description="Uncontrolled - whether the switch is turned on" /> | ||
<PropsTableRow name="disabled" type="boolean" description="Whether the switch is ready for user input" /> | ||
<PropsTableRow name="isLoading" type="boolean" description="Whether the switch is ready for user input" /> |
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.
Can we change this to loading
?
<PropsTableRow name="isLoading" type="boolean" description="Whether the switch is ready for user input" /> | |
<PropsTableRow name="loading" type="boolean" description="Whether the switch is ready for user input" /> |
Also, is it intentional that the description is the same as the disabled
prop?
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.
Not intentional. Thanks for flagging that.
src/Switch.tsx
Outdated
display="inline-flex" | ||
alignItems="center" | ||
flexDirection={statusLabelPosition === 'start' ? 'row' : 'row-reverse'} | ||
mb={4} |
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.
Why does this component have a margin bottom?
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.
I have no idea where this came from. Removing.
docs/content/Switch.mdx
Outdated
<PropsTableRow name="defaultOn" type="boolean" description="Uncontrolled - whether the switch is turned on" /> | ||
<PropsTableRow name="disabled" type="boolean" description="Whether the switch is ready for user input" /> | ||
<PropsTableRow name="isLoading" type="boolean" description="Whether the switch is ready for user input" /> | ||
<PropsTableRow name="on" type="boolean" description="Whether the switch is turned on" /> |
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.
Should we call this prop checked
instead of on
to align with the <input type="checkbox">
API?
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.
I'm good with that.
src/Switch.tsx
Outdated
}, [onChange, onProp, isControlled]) | ||
|
||
return ( | ||
<Box |
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.
Should this component render a visually hidden checkbox in case people plan to use this inside a form?
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.
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.
Ah okay. Should we mention that in the docs?
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.
<button role=switch>
sounds like the right thing to do.
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.
Sure, I'll include something in the docs.
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.
@colebemis - I'm not sure where in the React docs this should go. Could I add a new heading for accessibility?
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
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.
Looks good! 👍
Co-authored-by: Cole Bemis <colebemis@github.com>
Co-authored-by: Cole Bemis <colebemis@github.com>
Update: it's merged |
Help wanted: the |
Ohh.. I think the same
Not quite sure why this is needed, but I assume something with re-generating some "snapshot" so it can be compared? This probably should be documented if it's needed every time |
A PR has also been opened for documenting interface guidelines: primer/design#249 |
@simurai - that doesn't seem to have worked 🤔 Could you check my last commit and let me know if I did something wrong? I updated the snapshots, but |
Ahh, yess.. sorry. I missed the
Here the commit fa9ff75 that seems to now pass CI (Visual testing still needs an approval). Something weird in fa9ff75 are the changes to |
Thanks for fixing that @simurai ! |
Adds a toggle switch for turning settings on and off and immediately save the change.
Closes https://github.com/github/primer/issues/690
Screenshots
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.