_form-field-focus-overlay.scss 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. @use '../core/tokens/m2/mat/form-field' as tokens-mat-form-field;
  2. @use '../core/tokens/token-utils';
  3. @use '../core/style/layout-common';
  4. // MDC text-field used to use their ripple in order to show a focus and hover effect for
  5. // text-fields. This is unnecessary because the ripples bring in a lot of unnecessary
  6. // styles and runtime code while the actual goal for the text-field is simply showing a
  7. // focus and hover effect. The ripples will unnecessarily provide CSS selectors and JS
  8. // runtime code for launching interaction ripples at pointer location. This is not needed
  9. // for the text-field, so we create our own minimal focus overlay styles. Our focus overlay
  10. // uses the exact same logic to compute the colors as in the default MDC text-field ripples.
  11. @mixin private-form-field-focus-overlay() {
  12. .mat-mdc-form-field-focus-overlay {
  13. @include layout-common.fill;
  14. opacity: 0;
  15. pointer-events: none; // Make sure we don't block click on the prefix/suffix.
  16. @include token-utils.use-tokens(
  17. tokens-mat-form-field.$prefix, tokens-mat-form-field.get-token-slots()) {
  18. @include token-utils.create-token-slot(background-color, state-layer-color);
  19. .mat-mdc-text-field-wrapper:hover & {
  20. @include token-utils.create-token-slot(opacity, hover-state-layer-opacity);
  21. }
  22. .mat-mdc-form-field.mat-focused & {
  23. @include token-utils.create-token-slot(opacity, focus-state-layer-opacity);
  24. }
  25. }
  26. }
  27. }