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

feat(ripple): Expose mdc-states-opacity; fix press fallback #2402

Merged
merged 6 commits into from
Mar 16, 2018

Conversation

kfranqueiro
Copy link
Contributor

This is needed to support #2354 (see feat/ripple-states-opacity...fix/text-field/no-ripple for how it will be used for that).

This refactors logic out of a private function in mdc-ripple/mixins into a pair of functions (one public, one private) in mdc-ripple/functions (which is a new file). This has no effect on existing code or backwards compatibility, but adds an additional public Sass API.

This also changes the fallback for the --mdc-ripple-fg-opacity variable to 0 in ripple's styles for keyframes, which allows suppressing press ripple by omitting the styles altogether. This has no effect on MDC Web's own use of states which currently always defines press styles, and has no effect on using the states mixins as documented, since in those cases this variable will always be defined.

@kfranqueiro kfranqueiro changed the title Feat/ripple states opacity feat(ripple) Expose mdc-states-opacity; fix press fallback Mar 14, 2018
@kfranqueiro kfranqueiro changed the title feat(ripple) Expose mdc-states-opacity; fix press fallback feat(ripple): Expose mdc-states-opacity; fix press fallback Mar 14, 2018
@bonniezhou bonniezhou self-assigned this Mar 14, 2018
@@ -145,8 +145,7 @@
// Simple mixin for activated states which automatically selects opacity values based on whether the ink color is
// light or dark.
@mixin mdc-states-activated($color, $has-nested-focusable-element: false) {
$opacity-map: mdc-states-opacities_($color);
$activated-opacity: map-get($opacity-map, "activated");
$activated-opacity: mdc-states-opacity($color, activated);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do activated and selected need to be surrounded in quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to stay consistent with the usage pattern we use for mdc-theme-prop, where primary, secondary, etc. aren't surrounded in quotes when used as values.

Either should technically work, though unquoted values could be seen as a bit sloppy since they may be coerced to color if recognized as one (e.g. black), but even this is harmless as long as the usage is consistent both in the map's keys and in map-get invocations.

If quoting is something we want to eventually encourage instead, we'd want to do so for mdc-theme-prop as well though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok leaving it without quotes LGTM


@return $opacity-map;
}

@mixin mdc-states-interactions_($color, $has-nested-focusable-element, $opacity-modifier: 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the new public function here too?

Copy link
Contributor Author

@kfranqueiro kfranqueiro Mar 15, 2018

Choose a reason for hiding this comment

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

I debated this, but since I'm doing multiple lookups on the same map it seemed like calling the public function repeatedly with the same color is wasted cycles to choose the same map. I'll test whether it actually has any noticeable impact whatsoever on build time though, 'cause I can see the argument that it'd be more readable.

@codecov-io
Copy link

codecov-io commented Mar 15, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@e215ca8). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2402   +/-   ##
=========================================
  Coverage          ?   98.89%           
=========================================
  Files             ?      100           
  Lines             ?     4145           
  Branches          ?      531           
=========================================
  Hits              ?     4099           
  Misses            ?       46           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e215ca8...7c1e8ab. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants