Skip to content

feat(focus indicators): Add config map to base focus indicators mixin and tweak some default styles. #19206

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

Merged
merged 3 commits into from
May 1, 2020

Conversation

zelliott
Copy link
Collaborator

This is the first PR in a series of PRs to refresh the focus indicators API in preparation for formal documentation being added. This PR includes the following changes:

  • The mixin mat-strong-focus-indicators (and the MDC equivalent) now both accept a $config map that developers can use to configure focus indicator styles (e.g. border-style, border-width, border-radius).
  • I changed some of the default focus indicator styles (e.g. increased width from 2px -> 3px, updated some of the default offsets).

Future PRs will:

  • Add per-component customization mixins.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 29, 2020
/// }
@mixin mat-strong-focus-indicators-theme($themeOrColor) {
@mixin mat-strong-focus-indicators-theme($theme-or-color) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jelbourn & @mmalerba: Do we still want to have a standalone mat-strong-focus-indicators-theme mixin? One option is to merge this into the mat-strong-focus-indicators mixin (i.e. add a border-color key into the $config), but then if developers want to toggle focus indicator styles on light/dark backgrounds, a bunch of redundant styles are re-declared. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

IMO it makes sense to keep it, because the color depends on the theme.

}

// By default, all focus indicators are flush with the bounding box of their
// host element. For particular elements (listed below), default inset/offset
// values are necessary to ensure that the focus indicator is sufficiently
// contrastive and renders appropriately.

.mat-focus-indicator.mat-button-base::before,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the default inset/offset styles to (1) work nicely with the $border-width parameter and (2) more-accurately target the elements that actually need default inset/offset values. For example, previously all mat-button-base had an offset focus indicator, now only flat button, raised button, fab, and mini fab do. The rationale behind this is that offseting focus indicators is a bit dangerous from a design perspective, as it's easy for them to be clipped by adjacent elements or containers with overflow: hidden.

}

// By default, all focus indicators are flush with the bounding box of their
// host element. For particular elements (listed below), default inset/offset
// values are necessary to ensure that the focus indicator is sufficiently
// contrastive and renders appropriately.

.mat-focus-indicator.mat-button-base::before,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jelbourn & @mmalerba: If a developer wishes to add an offset to flat & raised buttons but not text buttons, how would we allow that with the per-component customization mixins? We were thinking there would be a mat-button-strong-focus-indicator mixin, but maybe we need to be a bit more specific and have mat-flat-button-strong-focus-indicator, mat-raised-button-strong-focus-indicator, etc. The button mixin could also accept a $type parameter. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably separate mixins, to be consistent with what we've done so far. so... many... mixins...

@zelliott zelliott requested a review from crisbeto April 29, 2020 14:59
}

// By default, all focus indicators are flush with the bounding box of their
// host element. For particular elements (listed below), default inset/offset
// values are necessary to ensure that the focus indicator is sufficiently
// contrastive and renders appropriately.

.mat-focus-indicator.mat-button-base::before,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: I was thinking that in a follow-up PR these default inset/offset styles would be replaced by the per-component customization mixins with the default inset/offset values.

}

.mat-focus-indicator.mat-tab-link::before,
.mat-focus-indicator.mat-tab-label::before {
margin: $mat-focus-indicator-border-width * 2;
margin: 5px;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI: The reason why some of these. values are a function of $border-width and others are not is because the focus indicator grows inward as its width is increased.

@zelliott zelliott requested a review from a team as a code owner April 29, 2020 15:12
/// }
@mixin mat-strong-focus-indicators-theme($themeOrColor) {
@mixin mat-strong-focus-indicators-theme($theme-or-color) {
Copy link
Member

Choose a reason for hiding this comment

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

IMO it makes sense to keep it, because the color depends on the theme.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn
Copy link
Member

Looks like you just need to rebase this branch on master

@jelbourn jelbourn added merge safe action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release and removed target: development-branch labels Apr 30, 2020
@jelbourn jelbourn merged commit 574345c into angular:master May 1, 2020
@zelliott zelliott deleted the focus-indicators branch May 1, 2020 20:04
@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 Jun 1, 2020
@jelbourn jelbourn added the Accessibility This issue is related to accessibility (a11y) label Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants