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

fix: improved accessibility in high contrast mode #1941

Merged
merged 4 commits into from
Dec 5, 2016

Conversation

crisbeto
Copy link
Member

a11y improvements to the following components in high contrast mode:

  • button - Adds an outline since only the text was visible. Also inverts the tint since it was hiding the text.
  • card, dialog, menu, snack-bar, tooltip - Adds an outline.
  • select - Adds an outline and prevents the ripple from hiding the option text.
  • sidenav - Fixes the backdrop not being opaque.
  • slide-toggle - Fixes component blending in completely with the background.

Fixes #421.
Fixes #1769.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 20, 2016
@@ -79,6 +80,10 @@
border-radius: inherit;
pointer-events: none;
opacity: 0;

@include md-high-contrast {
background-color: rgba(white, 0.5);
Copy link
Member

Choose a reason for hiding this comment

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

Could this be an issue with dark themes (where the text is white)?

(same for other components where you use a white background)

Copy link
Member Author

Choose a reason for hiding this comment

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

It probably would, but I only went for the dark modes in this PR since supporting all modes would add more bloat.

Copy link
Member

Choose a reason for hiding this comment

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

If we make these styles part of the theme, they can simply use the theme's background and foreground palettes to draw an appropriate color.

Copy link
Member

Choose a reason for hiding this comment

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

This would look something like

// in _button-theme.scss
@include md-high-contrast {
  background-color: if($theme.is-dark, white, black);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, although I had to flip the conditions since the colors are inverted. Might have to re-test this after we have dark themes implemented.

// Add an outline to make it more visible in high contrast mode.
@include md-high-contrast {
[md-button], [md-raised-button], [md-icon-button], [md-fab], [md-mini-fab] {
border: solid 1px;
Copy link
Member

Choose a reason for hiding this comment

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

Why border and not outline, since the latter won't affect layout?
(here and elsewhere)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, I hadn't though about it. I'll give it a try and see how it works out. One nice side effect of using the border is that we don't have to specify the color, it inherits from the text color.

Copy link
Member

Choose a reason for hiding this comment

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

You could do the same for outline using currentColor

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried it out and it looks like using outline works, however we can't apply a radius to it. This means that the round buttons would end up looking like this:

m5veqaz

Copy link
Member

Choose a reason for hiding this comment

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

I think that is acceptable for high contrast mode.

@crisbeto
Copy link
Member Author

crisbeto commented Dec 1, 2016

Switched over all of the border instances to use outline (except the slide toggle since it looked weird and the border doesn't affect layout there). Regarding using the theme background for the button overlay, it is being used already, I only overwrote the black one.

@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

Slide-toggle colors also be affected by the theme?

Dark themes should already be working; you can see an example on the sample app (toggle is on the top right).

@crisbeto
Copy link
Member Author

crisbeto commented Dec 2, 2016

I guess, although it seems like IE behaves the same both with the dark and the light theme. It doesn't try to invert colors.

@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

@crisbeto in that case it seems fine, then

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Dec 2, 2016
@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

LGTM, just needs rebase

@crisbeto
Copy link
Member Author

crisbeto commented Dec 2, 2016

I'll rebase it, but it probably makes sense to revert the light/dark distinction for the button overlay.

@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

That's fine if IE renders it the same either way

@crisbeto
Copy link
Member Author

crisbeto commented Dec 2, 2016

I mean IE renders the light and dark theme the same. In that case we should also use the same overlay color.

a11y improvements to the following components in high contrast mode:

* `button` - Adds an outline since only the text was visible. Also inverts the tint since it was hiding the text.
* `card`, `dialog`, `menu`, `snack-bar`, `tooltip` - Adds an outline.
* `select` - Adds an outline and prevents the ripple from hiding the option text.
* `sidenav` - Fixes the backdrop not being opaque.
* `slide-toggle` - Fixes component blending in completely with the background.

Fixes angular#421.
Fixes angular#1769.
@jelbourn
Copy link
Member

jelbourn commented Dec 2, 2016

@crisbeto yeah, I meant that if IE treats light and dark the same way then it's fine to go back to how you originally had it.

@mmalerba mmalerba merged commit 5cf7d17 into angular:master Dec 5, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a11y(buttons): Low contrast on focused buttons md-fab: High Contrast mode has no focus indicator
4 participants