Skip to content

fix: improved accessibility in high contrast mode - #1941

Merged
mmalerba merged 4 commits into
angular:masterfrom
crisbeto:high-contrast-a11y
Dec 5, 2016
Merged

mmalerba merged 4 commits into
angular:masterfrom
crisbeto:high-contrast-a11y

Conversation

@crisbeto

Copy link
Copy Markdown
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
opacity: 0;

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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
Copy Markdown
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.

Comment thread src/lib/button/button.scss Outdated
// 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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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

crisbeto commented Dec 1, 2016 •

Copy link
Copy Markdown
Member Author

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

jelbourn commented Dec 2, 2016

Copy link
Copy Markdown
Contributor

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

crisbeto commented Dec 2, 2016

Copy link
Copy Markdown
Member Author

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

jelbourn commented Dec 2, 2016

Copy link
Copy Markdown
Contributor

@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

jelbourn commented Dec 2, 2016

Copy link
Copy Markdown
Contributor

LGTM, just needs rebase

@crisbeto

crisbeto commented Dec 2, 2016

Copy link
Copy Markdown
Member Author

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

@jelbourn

jelbourn commented Dec 2, 2016

Copy link
Copy Markdown
Contributor

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

@crisbeto

crisbeto commented Dec 2, 2016

Copy link
Copy Markdown
Member Author

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

jelbourn commented Dec 2, 2016

Copy link
Copy Markdown
Contributor

@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
Copy Markdown

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