|
1 | 1 | @use 'sass:color';
|
2 | 2 | @use 'sass:map';
|
3 |
| -@use 'sass:math'; |
4 |
| -@use '@angular/cdk'; |
5 | 3 | @use '../core/theming/theming';
|
6 | 4 | @use '../core/theming/inspection';
|
7 | 5 | @use '../core/typography/typography';
|
8 | 6 | @use '../core/tokens/m2/mat/badge' as tokens-mat-badge;
|
9 | 7 | @use '../core/tokens/token-utils';
|
10 | 8 | @use '../core/style/sass-utils';
|
11 | 9 |
|
12 |
| -// TODO(crisbeto): some of these variables aren't used anymore and should be deleted. |
13 |
| -$font-size: 12px; |
14 |
| -$font-weight: 600; |
15 |
| -$default-size: 22px !default; |
16 |
| -$small-size: $default-size - 6; |
17 |
| -$large-size: $default-size + 6; |
18 |
| -$_badge-structure-emitted: false !default; |
19 |
| - |
20 |
| -// Internally there are some builds that throw an error if they can't figure out the values |
21 |
| -// of CSS variables during compliation. This flag temporarily enables fallbacks for these builds. |
22 |
| -// Eventually we should clean them up. |
23 |
| -$_emit-fallback-vars: true; |
24 |
| - |
25 |
| -// Mixin for building offset given different sizes |
26 |
| -@mixin _badge-size($size, $font-size-token) { |
27 |
| - // This mixin isn't used in the context of a theme so we can disable the ampersand check. |
28 |
| - // stylelint-disable material/no-ampersand-beyond-selector-start |
29 |
| - .mat-badge-content { |
30 |
| - width: $size; |
31 |
| - height: $size; |
32 |
| - line-height: $size; |
33 |
| - |
34 |
| - @if ($font-size-token) { |
35 |
| - @include token-utils.use-tokens(tokens-mat-badge.$prefix, |
36 |
| - tokens-mat-badge.get-token-slots()) { |
37 |
| - @include token-utils.create-token-slot(font-size, $font-size-token, $_emit-fallback-vars); |
38 |
| - } |
39 |
| - } |
40 |
| - } |
41 |
| - |
42 |
| - &.mat-badge-above .mat-badge-content { |
43 |
| - top: math.div(-$size, 2); |
44 |
| - } |
45 |
| - |
46 |
| - &.mat-badge-below .mat-badge-content { |
47 |
| - bottom: math.div(-$size, 2); |
48 |
| - } |
49 |
| - |
50 |
| - &.mat-badge-before .mat-badge-content { |
51 |
| - left: -$size; |
52 |
| - } |
53 |
| - |
54 |
| - [dir='rtl'] &.mat-badge-before .mat-badge-content { |
55 |
| - left: auto; |
56 |
| - right: -$size; |
57 |
| - } |
58 |
| - |
59 |
| - &.mat-badge-after .mat-badge-content { |
60 |
| - right: -$size; |
61 |
| - } |
62 |
| - |
63 |
| - [dir='rtl'] &.mat-badge-after .mat-badge-content { |
64 |
| - right: auto; |
65 |
| - left: -$size; |
66 |
| - } |
67 |
| - |
68 |
| - &.mat-badge-overlap { |
69 |
| - &.mat-badge-before .mat-badge-content { |
70 |
| - left: math.div(-$size, 2); |
71 |
| - } |
72 |
| - |
73 |
| - [dir='rtl'] &.mat-badge-before .mat-badge-content { |
74 |
| - left: auto; |
75 |
| - right: math.div(-$size, 2); |
76 |
| - } |
77 |
| - |
78 |
| - &.mat-badge-after .mat-badge-content { |
79 |
| - right: math.div(-$size, 2); |
80 |
| - } |
81 |
| - |
82 |
| - [dir='rtl'] &.mat-badge-after .mat-badge-content { |
83 |
| - right: auto; |
84 |
| - left: math.div(-$size, 2); |
85 |
| - } |
86 |
| - } |
87 |
| - // stylelint-enable |
88 |
| -} |
89 |
| - |
90 |
| -// Structural styles for the badge. They have to be included as a part of the theme, |
91 |
| -// because the badge is a directive and we have no other way of attaching styles to it. |
92 |
| -@mixin _badge-structure { |
93 |
| - .mat-badge { |
94 |
| - position: relative; |
95 |
| - |
96 |
| - // The badge should make sure its host is overflow visible so that the badge content |
97 |
| - // can be rendered outside of the element. Some components such as <mat-icon> explicitly |
98 |
| - // style `overflow: hidden` so this requires extra specificity so that it does not |
99 |
| - // depend on style load order. |
100 |
| - &.mat-badge { |
101 |
| - overflow: visible; |
102 |
| - } |
103 |
| - } |
104 |
| - |
105 |
| - .mat-badge-content { |
106 |
| - position: absolute; |
107 |
| - text-align: center; |
108 |
| - display: inline-block; |
109 |
| - border-radius: 50%; |
110 |
| - transition: transform 200ms ease-in-out; |
111 |
| - transform: scale(0.6); |
112 |
| - overflow: hidden; |
113 |
| - white-space: nowrap; |
114 |
| - text-overflow: ellipsis; |
115 |
| - pointer-events: none; |
116 |
| - |
117 |
| - @include token-utils.use-tokens(tokens-mat-badge.$prefix, tokens-mat-badge.get-token-slots()) { |
118 |
| - @include token-utils.create-token-slot(background-color, background-color); |
119 |
| - @include token-utils.create-token-slot(color, text-color); |
120 |
| - @include token-utils.create-token-slot(font-family, text-font, $_emit-fallback-vars); |
121 |
| - @include token-utils.create-token-slot(font-size, text-size, $_emit-fallback-vars); |
122 |
| - @include token-utils.create-token-slot(font-weight, text-weight, $_emit-fallback-vars); |
123 |
| - } |
124 |
| - |
125 |
| - @include cdk.high-contrast(active, off) { |
126 |
| - outline: solid 1px; |
127 |
| - border-radius: 0; |
128 |
| - } |
129 |
| - } |
130 |
| - |
131 |
| - .mat-badge-disabled .mat-badge-content { |
132 |
| - @include token-utils.use-tokens(tokens-mat-badge.$prefix, tokens-mat-badge.get-token-slots()) { |
133 |
| - @include token-utils.create-token-slot(background-color, disabled-state-background-color); |
134 |
| - @include token-utils.create-token-slot(color, disabled-state-text-color); |
135 |
| - } |
136 |
| - } |
137 |
| - |
138 |
| - .mat-badge-hidden .mat-badge-content { |
139 |
| - display: none; |
140 |
| - } |
141 |
| - |
142 |
| - .ng-animate-disabled .mat-badge-content, |
143 |
| - .mat-badge-content._mat-animation-noopable { |
144 |
| - transition: none; |
145 |
| - } |
146 |
| - |
147 |
| - // The active class is added after the element is added |
148 |
| - // so it can animate scale to default |
149 |
| - .mat-badge-content.mat-badge-active { |
150 |
| - // Scale to `none` instead of `1` to avoid blurry text in some browsers. |
151 |
| - transform: none; |
152 |
| - } |
153 |
| - |
154 |
| - .mat-badge-small { |
155 |
| - @include _badge-size($small-size, small-size-text-size); |
156 |
| - } |
157 |
| - |
158 |
| - .mat-badge-medium { |
159 |
| - @include _badge-size($default-size, null); |
160 |
| - } |
161 |
| - |
162 |
| - .mat-badge-large { |
163 |
| - @include _badge-size($large-size, large-size-text-size); |
164 |
| - } |
165 |
| -} |
166 |
| - |
167 | 10 | @mixin base($theme) {
|
168 | 11 | @if inspection.get-theme-version($theme) == 1 {
|
169 | 12 | @include _theme-from-tokens(inspection.get-theme-tokens($theme, base));
|
@@ -218,18 +61,6 @@ $_emit-fallback-vars: true;
|
218 | 61 | @include _theme-from-tokens(inspection.get-theme-tokens($theme));
|
219 | 62 | }
|
220 | 63 | @else {
|
221 |
| - // Try to reduce the number of times that the structural styles are emitted. |
222 |
| - @if not $_badge-structure-emitted { |
223 |
| - @include _badge-structure; |
224 |
| - |
225 |
| - // Only flip the flag if the mixin is included at the top level. Otherwise the first |
226 |
| - // inclusion might be inside of a theme class which will exclude the structural styles |
227 |
| - // from all other themes. |
228 |
| - @if not & { |
229 |
| - $_badge-structure-emitted: true !global; |
230 |
| - } |
231 |
| - } |
232 |
| - |
233 | 64 | @include base($theme);
|
234 | 65 | @if inspection.theme-has($theme, color) {
|
235 | 66 | @include color($theme);
|
|
0 commit comments