|
1 | 1 | @use 'sass:map';
|
2 | 2 | @use '@angular/cdk';
|
3 |
| -@use '@material/menu-surface' as mdc-menu-surface; |
4 | 3 | @use '@material/list/evolution-mixins' as mdc-list-mixins;
|
5 | 4 | @use '@material/list/evolution-variables' as mdc-list-variables;
|
| 5 | +@use '@material/typography/typography' as mdc-typography; |
| 6 | +@use '../core/tokens/m2/mat/menu' as tokens-mat-menu; |
| 7 | +@use '../core/tokens/token-utils'; |
6 | 8 | @use '../core/mdc-helpers/mdc-helpers';
|
7 | 9 | @use '../core/style/menu-common';
|
8 | 10 | @use '../core/style/button-common';
|
9 | 11 |
|
10 |
| - |
11 |
| -@include mdc-helpers.disable-mdc-fallback-declarations { |
12 |
| - @include mdc-menu-surface.core-styles($query: structure); |
13 |
| -} |
14 |
| - |
15 | 12 | // Prevent rendering mat-menu as it can affect the flex layout.
|
16 | 13 | mat-menu {
|
17 | 14 | display: none;
|
18 | 15 | }
|
19 | 16 |
|
20 | 17 | .mat-mdc-menu-content {
|
21 | 18 | @include mdc-list-mixins.list-base($query: structure);
|
| 19 | + |
| 20 | + &, |
| 21 | + .mat-mdc-menu-item .mdc-list-item__primary-text { |
| 22 | + @include mdc-typography.smooth-font(); |
| 23 | + @include token-utils.use-tokens(tokens-mat-menu.$prefix, tokens-mat-menu.get-token-slots()) { |
| 24 | + @include token-utils.create-token-slot(font-family, item-label-text-font); |
| 25 | + @include token-utils.create-token-slot(line-height, item-label-text-line-height); |
| 26 | + @include token-utils.create-token-slot(font-size, item-label-text-size); |
| 27 | + @include token-utils.create-token-slot(letter-spacing, item-label-text-tracking); |
| 28 | + @include token-utils.create-token-slot(font-weight, item-label-text-weight); |
| 29 | + } |
| 30 | + } |
22 | 31 | }
|
23 | 32 |
|
24 | 33 | .mat-mdc-menu-panel {
|
| 34 | + @include token-utils.create-token-values(tokens-mat-menu.$prefix, |
| 35 | + tokens-mat-menu.get-unthemable-tokens()); |
| 36 | + box-sizing: border-box; |
| 37 | + outline: 0; |
| 38 | + |
| 39 | + @include token-utils.use-tokens(tokens-mat-menu.$prefix, tokens-mat-menu.get-token-slots()) { |
| 40 | + @include token-utils.create-token-slot(border-radius, container-shape); |
| 41 | + @include token-utils.create-token-slot(background-color, container-color); |
| 42 | + } |
| 43 | + |
| 44 | + // TODO(crisbeto): we don't need this for anything, but it was there when |
| 45 | + // we used MDC's structural styles and removing it leads to sub-pixels |
| 46 | + // differences in text rendering which break a lot of screenshots internally. |
| 47 | + // We should clean it up eventually and re-approve all the screenshots. |
| 48 | + will-change: transform, opacity; |
| 49 | + |
25 | 50 | // Prevent users from interacting with the panel while it's animating. Note that
|
26 | 51 | // people won't be able to click through it, because the overlay pane will catch the click.
|
27 | 52 | // This fixes the following issues:
|
@@ -78,6 +103,20 @@ mat-menu {
|
78 | 103 | $height-config: map.get(mdc-list-variables.$one-line-item-density-config, height);
|
79 | 104 | min-height: map.get($height-config, default);
|
80 | 105 |
|
| 106 | + @include token-utils.use-tokens(tokens-mat-menu.$prefix, tokens-mat-menu.get-token-slots()) { |
| 107 | + // The class selector isn't specific enough to overide the link pseudo selectors so we need |
| 108 | + // to target them specifically, otherwise the item color might be overwritten by the user |
| 109 | + // agent resets of the app. |
| 110 | + &, &:visited, &:link { |
| 111 | + @include token-utils.create-token-slot(color, item-label-text-color); |
| 112 | + } |
| 113 | + |
| 114 | + .mat-icon-no-color, |
| 115 | + .mat-mdc-menu-submenu-icon { |
| 116 | + @include token-utils.create-token-slot(color, item-icon-color); |
| 117 | + } |
| 118 | + } |
| 119 | + |
81 | 120 | // If the MDC list is loaded after the menu, this gets overwritten which breaks the text
|
82 | 121 | // alignment. Ideally we'd wrap all the MDC mixins above with this selector, but the increased
|
83 | 122 | // specificity breaks some internal overrides.
|
@@ -130,6 +169,20 @@ mat-menu {
|
130 | 169 | @include menu-common.item-submenu-trigger(mdc-list-variables.$side-padding);
|
131 | 170 | }
|
132 | 171 |
|
| 172 | + &:not([disabled]) { |
| 173 | + @include token-utils.use-tokens(tokens-mat-menu.$prefix, tokens-mat-menu.get-token-slots()) { |
| 174 | + &:hover { |
| 175 | + @include token-utils.create-token-slot(background-color, item-hover-state-layer-color); |
| 176 | + } |
| 177 | + |
| 178 | + &.cdk-program-focused, |
| 179 | + &.cdk-keyboard-focused, |
| 180 | + &.mat-mdc-menu-item-highlighted { |
| 181 | + @include token-utils.create-token-slot(background-color, item-focus-state-layer-color); |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | + |
133 | 186 | @include cdk.high-contrast(active, off) {
|
134 | 187 | $outline-width: 1px;
|
135 | 188 |
|
|
0 commit comments