-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(ripple): Add new states mixins #1624
Changes from 1 commit
857bd92
b8b7113
6b600e0
d15527e
9a68fdf
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 |
---|---|---|
|
@@ -116,14 +116,14 @@ $mdc-ripple-common-styles-emitted_: false !default; | |
} | ||
} | ||
|
||
@mixin mdc-states-focus-opacity($opacity, $include-focus-within: false) { | ||
@mixin mdc-states-focus-opacity($opacity, $has-nested-focusable-element: false) { | ||
// Focus overrides hover by reusing the ::before pseudo-element. | ||
// :focus-within generally works on non-MS browsers and matches when a *child* of the element has focus. | ||
// It is useful for cases where a component has a focusable element within the root node, e.g. text field, | ||
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. maybe the argument should be |
||
// but undesirable in general in case of nested stateful components. | ||
// We use a modifier class for JS-enabled surfaces to support all use cases in all browsers. | ||
$cssOnlyFocusSelector: if( | ||
$include-focus-within, | ||
$has-nested-focusable-element, | ||
"&:not(.mdc-ripple-upgraded):focus::before, &:not(.mdc-ripple-upgraded):focus-within::before", | ||
"&:not(.mdc-ripple-upgraded):focus::before" | ||
); | ||
|
@@ -157,7 +157,7 @@ $mdc-ripple-common-styles-emitted_: false !default; | |
} | ||
|
||
// Simple mixin which automatically selects opacity values based on whether the ink color is light or dark. | ||
@mixin mdc-states-color($color: black, $include-focus-within: false) { | ||
@mixin mdc-states($color: black, $has-nested-focusable-element: false) { | ||
$color-value: mdc-theme-prop-value($color); | ||
$opacity-map: if( | ||
mdc-theme-tone($color-value) == "light", | ||
|
@@ -167,7 +167,7 @@ $mdc-ripple-common-styles-emitted_: false !default; | |
|
||
@include mdc-states-base-color($color); | ||
@include mdc-states-hover-opacity(map-get($opacity-map, "hover")); | ||
@include mdc-states-focus-opacity(map-get($opacity-map, "focus")); | ||
@include mdc-states-focus-opacity(map-get($opacity-map, "focus"), $has-nested-focusable-element); | ||
@include mdc-states-press-opacity(map-get($opacity-map, "press")); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
|
||
.mdc-ripple-surface { | ||
@include mdc-ripple-surface; | ||
@include mdc-states-color; | ||
@include mdc-states; | ||
@include mdc-ripple-radius; | ||
|
||
position: relative; | ||
|
@@ -35,11 +35,11 @@ | |
} | ||
|
||
&--primary { | ||
@include mdc-states-color(primary); | ||
@include mdc-states(primary, true); | ||
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. Can we use a named param for @include mdc-states(primary, $has-nested-focusable-element: true); At some point I'd like to go through all of our Sass mixins and use named params for all non-obvious boolean values. 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. Yeah, this was actually just for testing and I forgot to remove it... and I sort of intentionally broke exactly this rule to try to remind myself to remove it... but instead you reminded me! |
||
} | ||
|
||
&--accent { | ||
@include mdc-states-color(secondary); | ||
@include mdc-states(secondary); | ||
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. Why does 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. Because I'm dumb and forgot to remove something I put in simply to verify that the mixin worked as intended (since the only component that will actually use that parameter is text field). :D Fixed. |
||
} | ||
} | ||
|
||
|
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.
I dont think I understand the difference between mdc-states-color and mdc-states-base-color.