|
2 | 2 | @import '../core/typography/typography-utils'; |
3 | 3 |
|
4 | 4 | // Applies a focus style to an mat-button element for each of the supported palettes. |
5 | | -@mixin _mat-button-focus-color($theme) { |
| 5 | +@mixin _mat-button-focus-overlay-color($theme) { |
6 | 6 | $primary: map-get($theme, primary); |
7 | 7 | $accent: map-get($theme, accent); |
8 | 8 | $warn: map-get($theme, warn); |
|
24 | 24 | } |
25 | 25 | } |
26 | 26 |
|
27 | | -@mixin _mat-button-ripple-color($theme, $hue, $opacity: 0.2) { |
| 27 | +@mixin _mat-button-ripple-color($theme, $hue, $opacity: 0.1) { |
28 | 28 | $primary: map-get($theme, primary); |
29 | 29 | $accent: map-get($theme, accent); |
30 | 30 | $warn: map-get($theme, warn); |
|
43 | 43 | } |
44 | 44 |
|
45 | 45 | // Applies a property to an mat-button element for each of the supported palettes. |
46 | | -@mixin _mat-button-theme-color($theme, $property, $color: 'default') { |
| 46 | +@mixin _mat-button-theme-property($theme, $property, $hue) { |
47 | 47 | $primary: map-get($theme, primary); |
48 | 48 | $accent: map-get($theme, accent); |
49 | 49 | $warn: map-get($theme, warn); |
50 | 50 | $background: map-get($theme, background); |
51 | 51 | $foreground: map-get($theme, foreground); |
52 | 52 |
|
53 | 53 | &.mat-primary { |
54 | | - #{$property}: mat-color($primary, $color); |
| 54 | + #{$property}: mat-color($primary, $hue); |
55 | 55 | } |
56 | 56 | &.mat-accent { |
57 | | - #{$property}: mat-color($accent, $color); |
| 57 | + #{$property}: mat-color($accent, $hue); |
58 | 58 | } |
59 | 59 | &.mat-warn { |
60 | | - #{$property}: mat-color($warn, $color); |
| 60 | + #{$property}: mat-color($warn, $hue); |
61 | 61 | } |
62 | 62 |
|
63 | 63 | &.mat-primary, &.mat-accent, &.mat-warn, &[disabled] { |
|
76 | 76 | $foreground: map-get($theme, foreground); |
77 | 77 |
|
78 | 78 | .mat-button, .mat-icon-button, .mat-stroked-button { |
| 79 | + // Buttons without a background color should inherit the font color. This is necessary to |
| 80 | + // ensure that the button is readable on custom background colors. It's wrong to always assume |
| 81 | + // that those buttons are always placed inside of containers with the default background |
| 82 | + // color of the theme (e.g. themed toolbars). |
| 83 | + color: inherit; |
79 | 84 | background: transparent; |
80 | 85 |
|
81 | | - @include _mat-button-focus-color($theme); |
82 | | - @include _mat-button-theme-color($theme, 'color'); |
83 | | - } |
84 | | - |
85 | | - .mat-raised-button, .mat-fab, .mat-mini-fab { |
86 | | - // Default properties when not using any [color] value. |
87 | | - color: mat-color($foreground, text); |
88 | | - background-color: mat-color($background, raised-button); |
89 | | - |
90 | | - @include _mat-button-theme-color($theme, 'color', default-contrast); |
91 | | - @include _mat-button-theme-color($theme, 'background-color'); |
| 86 | + @include _mat-button-theme-property($theme, 'color', default); |
| 87 | + @include _mat-button-focus-overlay-color($theme); |
92 | 88 |
|
93 | | - // Add ripple effect with contrast color to buttons that don't have a focus overlay. |
94 | | - @include _mat-button-ripple-color($theme, default-contrast); |
95 | | - } |
96 | | - |
97 | | - // Add ripple effect with default color to flat buttons, which also have a focus overlay. |
98 | | - .mat-button { |
99 | | - @include _mat-button-ripple-color($theme, default, 0.1); |
| 89 | + // Setup the ripple color to be based on the color palette. The opacity can be a bit weaker |
| 90 | + // than for icon-buttons, because normal and stroked buttons have a focus overlay. |
| 91 | + @include _mat-button-ripple-color($theme, default); |
100 | 92 | } |
101 | 93 |
|
102 | | - .mat-flat-button { |
103 | | - // Default properties when not using any [color] value. |
| 94 | + .mat-flat-button, .mat-raised-button, .mat-fab, .mat-mini-fab { |
| 95 | + // Default font and background color when not using any color palette. |
104 | 96 | color: mat-color($foreground, text); |
105 | | - |
106 | 97 | background-color: mat-color($background, raised-button); |
107 | | - @include _mat-button-theme-color($theme, 'color', default-contrast); |
108 | | - @include _mat-button-theme-color($theme, 'background-color'); |
109 | 98 |
|
110 | | - // Add ripple effect with contrast color to buttons that don't have a focus overlay. |
| 99 | + @include _mat-button-theme-property($theme, 'color', default-contrast); |
| 100 | + @include _mat-button-theme-property($theme, 'background-color', default); |
111 | 101 | @include _mat-button-ripple-color($theme, default-contrast); |
112 | 102 | } |
113 | 103 |
|
114 | | - // Add ripple effect with default color to the icon button. Ripple color needs to be stronger |
115 | | - // since the icon button doesn't have a focus overlay. |
| 104 | + // Since icon buttons don't have a focus overlay, the ripple opacity should be the higher |
| 105 | + // than the default value. |
116 | 106 | .mat-icon-button { |
117 | | - @include _mat-button-ripple-color($theme, default); |
| 107 | + @include _mat-button-ripple-color($theme, default, 0.2); |
118 | 108 | } |
119 | 109 | } |
120 | 110 |
|
121 | 111 | @mixin mat-button-typography($config) { |
122 | | - .mat-button, .mat-raised-button, .mat-icon-button, .mat-stroked-button, .mat-flat-button, |
123 | | - .mat-fab, .mat-mini-fab { |
| 112 | + .mat-button, .mat-raised-button, .mat-icon-button, .mat-stroked-button, |
| 113 | + .mat-flat-button, .mat-fab, .mat-mini-fab { |
124 | 114 | font: { |
125 | 115 | family: mat-font-family($config, button); |
126 | 116 | size: mat-font-size($config, button); |
|
0 commit comments