|
1 | | -@use '@material/theme/custom-properties' as mdc-custom-properties; |
2 | | -@use '@material/tooltip/tooltip' as mdc-tooltip; |
3 | | -@use '@material/tooltip/plain-tooltip-theme' as mdc-plain-tooltip-theme; |
4 | | -@use '../core/tokens/m2/mdc/plain-tooltip' as m2-mdc-plain-tooltip; |
5 | | - |
6 | | -@include mdc-custom-properties.configure($emit-fallback-values: false, |
7 | | - $emit-fallback-vars: false) { |
8 | | - $mdc-tooltip-token-slots: m2-mdc-plain-tooltip.get-token-slots(); |
9 | | - |
10 | | - // Add the MDC tooltip static styles. |
11 | | - @include mdc-tooltip.static-styles(); |
12 | | - |
13 | | - .mat-mdc-tooltip { |
14 | | - // Add the official slots for the MDC tooltip. |
15 | | - @include mdc-plain-tooltip-theme.theme-styles($mdc-tooltip-token-slots); |
16 | | - } |
17 | | -} |
| 1 | +@use '../core/tokens/m2/mdc/plain-tooltip' as tokens-mdc-plain-tooltip; |
| 2 | +@use '../core/tokens/token-utils'; |
18 | 3 |
|
19 | 4 | .mat-mdc-tooltip { |
20 | 5 | // We don't use MDC's positioning so this has to be relative. |
21 | 6 | position: relative; |
22 | 7 | transform: scale(0); |
| 8 | + display: inline-flex; |
23 | 9 |
|
24 | 10 | // Increases the area of the tooltip so the user's pointer can go from the trigger directly to it. |
25 | 11 | &::before { |
|
59 | 45 | } |
60 | 46 | } |
61 | 47 |
|
| 48 | +.mat-mdc-tooltip-surface { |
| 49 | + word-break: normal; |
| 50 | + overflow-wrap: anywhere; |
| 51 | + padding: 4px 8px; |
| 52 | + min-width: 40px; |
| 53 | + max-width: 200px; |
| 54 | + min-height: 24px; |
| 55 | + max-height: 40vh; |
| 56 | + box-sizing: border-box; |
| 57 | + overflow: hidden; |
| 58 | + text-align: center; |
| 59 | + |
| 60 | + // TODO(crisbeto): these styles aren't necessary, but they were present in |
| 61 | + // MDC and removing them is likely to cause screenshot differences. |
| 62 | + will-change: transform, opacity; |
| 63 | + |
| 64 | + @include token-utils.use-tokens( |
| 65 | + tokens-mdc-plain-tooltip.$prefix, |
| 66 | + tokens-mdc-plain-tooltip.get-token-slots() |
| 67 | + ) { |
| 68 | + @include token-utils.create-token-slot(background-color, container-color); |
| 69 | + @include token-utils.create-token-slot(color, supporting-text-color); |
| 70 | + @include token-utils.create-token-slot(border-radius, container-shape); |
| 71 | + @include token-utils.create-token-slot(font-family, supporting-text-font); |
| 72 | + @include token-utils.create-token-slot(font-size, supporting-text-size); |
| 73 | + @include token-utils.create-token-slot(font-weight, supporting-text-weight); |
| 74 | + @include token-utils.create-token-slot(line-height, supporting-text-line-height); |
| 75 | + @include token-utils.create-token-slot(letter-spacing, supporting-text-tracking); |
| 76 | + } |
| 77 | + |
| 78 | + // Renders an outline in high contrast mode. |
| 79 | + &::before { |
| 80 | + position: absolute; |
| 81 | + box-sizing: border-box; |
| 82 | + width: 100%; |
| 83 | + height: 100%; |
| 84 | + top: 0; |
| 85 | + left: 0; |
| 86 | + border: 1px solid transparent; |
| 87 | + border-radius: inherit; |
| 88 | + content: ''; |
| 89 | + pointer-events: none; |
| 90 | + } |
| 91 | + |
| 92 | + .mdc-tooltip--multiline & { |
| 93 | + text-align: left; |
| 94 | + } |
| 95 | + |
| 96 | + [dir='rtl'] .mdc-tooltip--multiline & { |
| 97 | + text-align: right; |
| 98 | + } |
| 99 | +} |
| 100 | + |
62 | 101 | // We need the additional specificity here, because it can be overridden by `.cdk-overlay-panel`. |
63 | 102 | .mat-mdc-tooltip-panel.mat-mdc-tooltip-panel-non-interactive { |
64 | 103 | pointer-events: none; |
65 | 104 | } |
66 | 105 |
|
67 | | -// TODO(crisbeto): we may be able to use MDC directly for these animations. |
68 | | - |
69 | 106 | @keyframes mat-mdc-tooltip-show { |
70 | 107 | 0% { |
71 | 108 | opacity: 0; |
|
0 commit comments