-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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(toggle): on/off icons for toggle #25459
Conversation
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.
Also the I/O label supposed to appear, not slide in on iOS
native | ionic |
---|---|
RPReplay_Final1655153868.MP4 |
RPReplay_Final1655153898.MP4 |
Somewhat related, but when dragging the toggle the "O" label overlaps the handle
native | ionic |
---|---|
RPReplay_Final1655154138.MP4 |
RPReplay_Final1655153911.MP4 |
Pushed an update to fix the colors for iOS to align with the spec. This does cause an issue with Unsure if we should concern ourself with overriding the text color for this, since it isn't within the iOS spec. I'll need to do some more discovery into rendering of the icons. Originally when just having the icon flip on iOS (like it does for MD), it made the animation of the knob look choppy. It looks like when the knob is active, I need to set the opacity of the icons to zero (and make sure the icons have a transition for opacity). |
When rendering the on icon over an element with an Ionic color, it might be easiest to use the contrast (ex: For the off text, you might be able to use a step color? The color would change slightly across light vs. dark mode, but I don't know if it really matters (as long as the text is accessible). A benefit of using a stepped color is it is easy for developers to customize on a global level. Full customization is out of scope for this task, but using a stepped color would at least let developers customize the text color without much hassle. (For example, if a developers customized the track color, our default color may not be accessible when used on the new track color) |
Ok, I think this is finally ready for another review. Was getting burned by trying to nest our SASS mixins: @include ltr() {
@include position(x, x, x, x);
} Instead of just using the positioning values directly and disabling stylelint. |
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.
@@ -99,3 +99,9 @@ $toggle-md-item-end-padding-bottom: 12px !default; | |||
|
|||
/// @prop - Padding start of the toggle positioned on the end in an item | |||
$toggle-md-item-end-padding-start: $item-md-padding-start !default; | |||
|
|||
/// @prop - The text color of the on/off labels | |||
$toggle-md-on-off-label-color: #000 !default; |
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.
How does the color get set for the "O" on iOS mode?
This definitely some scope creep, so feel free to ignore this for now... But what if we had a global css var for this?
For example, tab bar has a default background that can be customized with --ion-tab-bar-background
:
$tabbar-md-background: var(--ion-tab-bar-background, $background-color) !default; |
Reason why I bring it up is iOS does change the on/off text color when adding high contrast mode.
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.
Another thought: It might be better to do some more design work around this CSS Variable idea we've been playing with. I'd be fine merging this feature in for now, and then we can figure out the CSS Variable stuff next sprint. Does that work for you? I think this feature is great and pretty much done, so I don't think it makes sense to hold this up on the CSS Variable detail.
Yeah I can revert the CSS variable changes and leave them static for now. |
…olor" This reverts commit 5c24018.
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.
Much better. Great job!
Pull request checklist
Please check if your PR fulfills the following requirements:
ionic-docs
repo, in a separate PR. See the contributing guide for details.npm run build
) was run locally and any changes were pushednpm run lint
) has passed locally and any fixes were made for failuresPull request type
Please check the type of change your PR introduces:
What is the current behavior?
The Toggle component does not support the accessibility indications for the toggle checked state.
Issue URL: #20524
What is the new behavior?
Introduces the
switchLabelsEnabled
property toion-toggle
, that developers can use to enable the icon indicators for the toggle's checked state.For Material Design, the checkbox icon will display when the toggle is checked. When the toggle is unchecked, the minus icon will display.
For iOS, the "I" icon will display when the toggle is checked. When the toggle is unchecked, the "O" icon will display. iOS renders both icons in the DOM, in order to accomplish the pulling effect when the toggle changes state.
Does this introduce a breaking change?
Other information
Dev-build:
6.1.10-dev.11655149274.1a5ec2d4