-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
feat(focus indicators): Add config map to base focus indicators mixin and tweak some default styles. #19206
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,60 @@ | ||
@import '../theming/theming'; | ||
@import '../style/layout-common'; | ||
|
||
// Focus indicator styles. | ||
$mat-focus-indicator-border-radius: 4px; | ||
$mat-focus-indicator-border-width: 2px; | ||
$mat-focus-indicator-border-style: solid; | ||
|
||
/// Mixin that turns on strong focus indicators. | ||
/// | ||
/// @example | ||
/// .my-app { | ||
/// @include mat-strong-focus-indicators(); | ||
/// @include mat-strong-focus-indicators($config); | ||
/// } | ||
@mixin mat-strong-focus-indicators() { | ||
@mixin mat-strong-focus-indicators($config: ()) { | ||
// Default focus indicator config. | ||
$default-config: ( | ||
border-style: solid, | ||
border-width: 3px, | ||
border-radius: 4px, | ||
); | ||
|
||
// Merge default config with user config. | ||
$config: map-merge($default-config, $config); | ||
$border-style: map-get($config, border-style); | ||
$border-width: map-get($config, border-width); | ||
$border-radius: map-get($config, border-radius); | ||
|
||
// Base styles for the focus indicators. | ||
// Base styles for focus indicators. | ||
.mat-focus-indicator::before { | ||
@include mat-fill(); | ||
|
||
border-radius: $mat-focus-indicator-border-radius; | ||
border: $mat-focus-indicator-border-width $mat-focus-indicator-border-style transparent; | ||
box-sizing: border-box; | ||
pointer-events: none; | ||
border: $border-width $border-style transparent; | ||
border-radius: $border-radius; | ||
} | ||
|
||
// 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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-card::before, | ||
.mat-focus-indicator.mat-flat-button::before, | ||
.mat-focus-indicator.mat-raised-button::before, | ||
.mat-focus-indicator.mat-fab::before, | ||
.mat-focus-indicator.mat-mini-fab::before, | ||
.mat-focus-indicator.mat-chip::before, | ||
.mat-focus-indicator.mat-sort-header-button::before { | ||
margin: $mat-focus-indicator-border-width * -2; | ||
margin: -($border-width + 2px); | ||
} | ||
|
||
.mat-focus-indicator.mat-stroked-button::before { | ||
margin: -($border-width + 3px); | ||
} | ||
|
||
.mat-focus-indicator.mat-calendar-body-cell::before { | ||
margin: $mat-focus-indicator-border-width * -1; | ||
margin: -$border-width; | ||
} | ||
|
||
.mat-focus-indicator.mat-tab-link::before, | ||
.mat-focus-indicator.mat-tab-label::before { | ||
margin: $mat-focus-indicator-border-width * 2; | ||
margin: 5px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: The reason why some of these. values are a function of |
||
} | ||
|
||
// Render the focus indicator on focus. Defining a pseudo element's | ||
|
@@ -66,24 +78,24 @@ $mat-focus-indicator-border-style: solid; | |
|
||
/// Mixin that sets the color of the focus indicators. | ||
/// | ||
/// @param {color|map} $themeOrMap | ||
/// @param {color|map} $theme-or-color | ||
/// If theme, focus indicators are set to the primary color of the theme. If | ||
/// color, focus indicators are set to that color. | ||
/// | ||
/// @example | ||
/// .demo-dark-theme { | ||
/// @include mat-strong-focus-indicators-theme($darkThemeMap); | ||
/// @include mat-strong-focus-indicators-theme($dark-theme-map); | ||
/// } | ||
/// | ||
/// @example | ||
/// .demo-red-theme { | ||
/// @include mat-strong-focus-indicators-theme(#F00); | ||
/// @include mat-strong-focus-indicators-theme(#f00); | ||
/// } | ||
@mixin mat-strong-focus-indicators-theme($themeOrColor) { | ||
@mixin mat-strong-focus-indicators-theme($theme-or-color) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jelbourn & @mmalerba: Do we still want to have a standalone There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
.mat-focus-indicator::before { | ||
border-color: if( | ||
type-of($themeOrColor) == 'map', | ||
mat-color(map_get($themeOrColor, primary)), | ||
$themeOrColor); | ||
type-of($theme-or-color) == 'map', | ||
mat-color(map_get($theme-or-color, primary)), | ||
$theme-or-color); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.