|
2 | 2 | @use '@material/fab' as mdc-fab;
|
3 | 3 | @use '@material/fab/extended-fab-theme' as mdc-extended-fab-theme;
|
4 | 4 | @use '@material/fab/fab-theme' as mdc-fab-theme;
|
| 5 | +@use '@material/fab/fab-small-theme' as mdc-fab-small-theme; |
5 | 6 | @use '@material/typography/typography' as mdc-typography;
|
6 | 7 | @use '@material/theme/custom-properties' as mdc-custom-properties;
|
7 | 8 |
|
|
13 | 14 | @use '../core/tokens/m2/mdc/extended-fab' as tokens-mdc-extended-fab;
|
14 | 15 | @use '../core/tokens/m2/mdc/fab' as tokens-mdc-fab;
|
15 | 16 | @use '../core/tokens/m2/mat/fab' as tokens-mat-fab;
|
| 17 | +@use '../core/tokens/m2/mdc/fab-small' as tokens-mdc-fab-small; |
| 18 | +@use '../core/tokens/m2/mat/fab-small' as tokens-mat-fab-small; |
16 | 19 |
|
17 | 20 | @include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) {
|
18 | 21 | $mdc-fab-token-slots: tokens-mdc-fab.get-token-slots();
|
| 22 | + $mdc-fab-small-token-slots: tokens-mdc-fab-small.get-token-slots(); |
19 | 23 | $mdc-extended-fab-token-slots: tokens-mdc-extended-fab.get-token-slots();
|
20 | 24 | $exclude-tokens: (
|
21 | 25 | // Exclude the elevation tokens here since we output them manually below.
|
|
30 | 34 | // some unnecessary typography styles for the extended FAB.
|
31 | 35 | @include mdc-fab.static-styles($query: mdc-helpers.$mdc-base-styles-query);
|
32 | 36 |
|
33 |
| - .mat-mdc-fab, .mat-mdc-mini-fab { |
| 37 | + .mat-mdc-fab { |
34 | 38 | @include mdc-fab-theme.theme-styles(map.merge($mdc-fab-token-slots, $exclude-tokens));
|
35 | 39 | }
|
36 | 40 |
|
| 41 | + .mat-mdc-mini-fab { |
| 42 | + @include mdc-fab-small-theme.theme-styles( |
| 43 | + map.merge($mdc-fab-small-token-slots, $exclude-tokens)); |
| 44 | + } |
| 45 | + |
37 | 46 | .mat-mdc-extended-fab {
|
38 | 47 | // Before tokens MDC included the font smoothing automatically, but with
|
39 | 48 | // tokens it doesn't. We add it since it can cause tiny differences in
|
|
46 | 55 |
|
47 | 56 | .mat-mdc-fab, .mat-mdc-mini-fab {
|
48 | 57 | @include button-base.mat-private-button-interactive();
|
49 |
| - @include button-base.mat-private-button-touch-target(true, tokens-mat-fab.$prefix, |
50 |
| - tokens-mat-fab.get-token-slots()); |
51 |
| - @include button-base.mat-private-button-ripple(tokens-mat-fab.$prefix, |
52 |
| - tokens-mat-fab.get-token-slots()); |
53 | 58 | @include style-private.private-animation-noop();
|
54 | 59 | flex-shrink: 0; // Prevent the button from shrinking since it's always supposed to be a circle.
|
55 | 60 |
|
56 |
| - @include mdc-helpers.disable-mdc-fallback-declarations { |
57 |
| - @include token-utils.use-tokens(tokens-mat-fab.$prefix, tokens-mat-fab.get-token-slots()) { |
58 |
| - @include token-utils.create-token-slot(color, foreground-color, inherit); |
59 |
| - } |
60 |
| - } |
61 |
| - |
62 |
| - @include token-utils.use-tokens(tokens-mdc-fab.$prefix, tokens-mdc-fab.get-token-slots()) { |
63 |
| - @include button-base.mat-private-button-elevation(container-elevation); |
64 |
| - |
65 |
| - &:hover { |
66 |
| - @include button-base.mat-private-button-elevation(hover-container-elevation); |
67 |
| - } |
68 |
| - |
69 |
| - &:focus { |
70 |
| - @include button-base.mat-private-button-elevation(focus-container-elevation); |
71 |
| - } |
72 |
| - |
73 |
| - &:active, &:focus:active { |
74 |
| - @include button-base.mat-private-button-elevation(pressed-container-elevation); |
75 |
| - } |
76 |
| - } |
77 |
| - |
78 |
| - @include button-base.mat-private-button-disabled { |
79 |
| - // Necessary for interactive disabled buttons. |
80 |
| - &, &:focus { |
81 |
| - box-shadow: none; |
82 |
| - } |
83 |
| - |
84 |
| - @include token-utils.use-tokens(tokens-mat-fab.$prefix, tokens-mat-fab.get-token-slots()) { |
85 |
| - @include token-utils.create-token-slot(color, disabled-state-foreground-color); |
86 |
| - @include token-utils.create-token-slot(background-color, disabled-state-container-color); |
87 |
| - } |
88 |
| - } |
89 |
| - |
90 | 61 | // MDC adds some styles to fab and mini-fab that conflict with some of our focus indicator
|
91 | 62 | // styles and don't actually do anything. This undoes those conflicting styles.
|
92 | 63 | &:not(.mdc-ripple-upgraded):focus::before {
|
|
111 | 82 | $offset: calc(#{$border-width} + 2px);
|
112 | 83 | margin: calc(#{$offset} * -1);
|
113 | 84 | }
|
| 85 | + |
| 86 | + @include button-base.mat-private-button-disabled { |
| 87 | + // Necessary for interactive disabled buttons. |
| 88 | + &, &:focus { |
| 89 | + box-shadow: none; |
| 90 | + } |
| 91 | + } |
114 | 92 | }
|
115 | 93 |
|
116 |
| -.mat-mdc-extended-fab { |
117 |
| - @include token-utils.use-tokens(tokens-mdc-extended-fab.$prefix, |
118 |
| - tokens-mdc-extended-fab.get-token-slots()) { |
| 94 | +@mixin _fab-elevation($mdc-tokens) { |
| 95 | + @include token-utils.use-tokens($mdc-tokens...) { |
119 | 96 | @include button-base.mat-private-button-elevation(container-elevation);
|
120 | 97 |
|
121 | 98 | &:hover {
|
|
130 | 107 | @include button-base.mat-private-button-elevation(pressed-container-elevation);
|
131 | 108 | }
|
132 | 109 | }
|
| 110 | +} |
| 111 | + |
| 112 | +@mixin _fab-structure($mdc-tokens, $mat-tokens) { |
| 113 | + @include button-base.mat-private-button-touch-target(true, $mat-tokens...); |
| 114 | + @include button-base.mat-private-button-ripple($mat-tokens...); |
| 115 | + |
| 116 | + @include mdc-helpers.disable-mdc-fallback-declarations { |
| 117 | + @include token-utils.use-tokens($mat-tokens...) { |
| 118 | + @include token-utils.create-token-slot(color, foreground-color, inherit); |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + @include _fab-elevation($mdc-tokens); |
| 123 | + |
| 124 | + @include button-base.mat-private-button-disabled { |
| 125 | + @include token-utils.use-tokens($mat-tokens...) { |
| 126 | + @include token-utils.create-token-slot(color, disabled-state-foreground-color); |
| 127 | + @include token-utils.create-token-slot(background-color, disabled-state-container-color); |
| 128 | + } |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +.mat-mdc-fab { |
| 133 | + @include _fab-structure( |
| 134 | + (tokens-mdc-fab.$prefix, tokens-mdc-fab.get-token-slots()), |
| 135 | + (tokens-mat-fab.$prefix, tokens-mat-fab.get-token-slots()), |
| 136 | + ); |
| 137 | +} |
| 138 | + |
| 139 | +.mat-mdc-mini-fab { |
| 140 | + @include _fab-structure( |
| 141 | + (tokens-mdc-fab-small.$prefix, tokens-mdc-fab-small.get-token-slots()), |
| 142 | + (tokens-mat-fab-small.$prefix, tokens-mat-fab-small.get-token-slots()), |
| 143 | + ); |
| 144 | +} |
| 145 | + |
| 146 | +.mat-mdc-extended-fab { |
| 147 | + @include _fab-elevation((tokens-mdc-extended-fab.$prefix, |
| 148 | + tokens-mdc-extended-fab.get-token-slots())); |
133 | 149 |
|
134 | 150 | @include button-base.mat-private-button-disabled {
|
135 | 151 | // Necessary for interactive disabled buttons.
|
|
146 | 162 | );
|
147 | 163 | }
|
148 | 164 |
|
| 165 | + // All FABs are square except the extended ones so we |
| 166 | + // need to set the touch target back to full-width. |
| 167 | + .mat-mdc-button-touch-target { |
| 168 | + width: 100%; |
| 169 | + } |
| 170 | + |
149 | 171 | // For Extended FAB with text label followed by icon.
|
150 | 172 | // We are checking for the a button class because white this is a FAB it
|
151 | 173 | // uses the same template as button.
|
|
159 | 181 | }
|
160 | 182 | }
|
161 | 183 |
|
162 |
| -// All FABs are square except the extended ones so we |
163 |
| -// need to set the touch target back to full-width. |
164 |
| -.mat-mdc-extended-fab .mat-mdc-button-touch-target { |
165 |
| - width: 100%; |
166 |
| -} |
|
0 commit comments