source: trip-planner-front/node_modules/@angular/material/badge/_badge-theme.scss@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.5 KB
Line 
1// This contains all of the styles for the badge
2// rather than just the color/theme because of
3// no style sheet support for directives.
4@use 'sass:color';
5@use 'sass:map';
6@use 'sass:meta';
7@use '../core/theming/theming';
8@use '../core/typography/typography';
9@use '../core/typography/typography-utils';
10@use '../core/style/private';
11@use '../../cdk/a11y';
12
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// Mixin for building offset given different sizes
21@mixin _badge-size($size) {
22 // This mixin isn't used in the context of a theme so we can disable the ampersand check.
23 // stylelint-disable material/no-ampersand-beyond-selector-start
24 .mat-badge-content {
25 width: $size;
26 height: $size;
27 line-height: $size;
28 }
29
30 &.mat-badge-above {
31 .mat-badge-content {
32 top: private.private-div(-$size, 2);
33 }
34 }
35
36 &.mat-badge-below {
37 .mat-badge-content {
38 bottom: private.private-div(-$size, 2);
39 }
40 }
41
42 &.mat-badge-before {
43 .mat-badge-content {
44 left: -$size;
45 }
46 }
47
48 [dir='rtl'] &.mat-badge-before {
49 .mat-badge-content {
50 left: auto;
51 right: -$size;
52 }
53 }
54
55 &.mat-badge-after {
56 .mat-badge-content {
57 right: -$size;
58 }
59 }
60
61 [dir='rtl'] &.mat-badge-after {
62 .mat-badge-content {
63 right: auto;
64 left: -$size;
65 }
66 }
67
68 &.mat-badge-overlap {
69 &.mat-badge-before {
70 .mat-badge-content {
71 left: private.private-div(-$size, 2);
72 }
73 }
74
75 [dir='rtl'] &.mat-badge-before {
76 .mat-badge-content {
77 left: auto;
78 right: private.private-div(-$size, 2);
79 }
80 }
81
82 &.mat-badge-after {
83 .mat-badge-content {
84 right: private.private-div(-$size, 2);
85 }
86 }
87
88 [dir='rtl'] &.mat-badge-after {
89 .mat-badge-content {
90 right: auto;
91 left: private.private-div(-$size, 2);
92 }
93 }
94 }
95 // stylelint-enable
96}
97
98// Structural styles for the badge. They have to be included as a part of the theme,
99// because the badge is a directive and we have no other way of attaching styles to it.
100@mixin _badge-structure {
101 .mat-badge {
102 position: relative;
103 }
104
105 .mat-badge-hidden {
106 .mat-badge-content {
107 display: none;
108 }
109 }
110
111 .mat-badge-content {
112 position: absolute;
113 text-align: center;
114 display: inline-block;
115 border-radius: 50%;
116 transition: transform 200ms ease-in-out;
117 transform: scale(0.6);
118 overflow: hidden;
119 white-space: nowrap;
120 text-overflow: ellipsis;
121 pointer-events: none;
122 }
123
124 .ng-animate-disabled .mat-badge-content,
125 .mat-badge-content._mat-animation-noopable {
126 transition: none;
127 }
128
129 // The active class is added after the element is added
130 // so it can animate scale to default
131 .mat-badge-content.mat-badge-active {
132 // Scale to `none` instead of `1` to avoid blurry text in some browsers.
133 transform: none;
134 }
135
136 .mat-badge-small {
137 @include _badge-size($small-size);
138 }
139
140 .mat-badge-medium {
141 @include _badge-size($default-size);
142 }
143
144 .mat-badge-large {
145 @include _badge-size($large-size);
146 }
147}
148
149@mixin color($config-or-theme) {
150 $config: theming.get-color-config($config-or-theme);
151 $accent: map.get($config, accent);
152 $warn: map.get($config, warn);
153 $primary: map.get($config, primary);
154 $background: map.get($config, background);
155 $foreground: map.get($config, foreground);
156
157 .mat-badge-content {
158 color: theming.get-color-from-palette($primary, default-contrast);
159 background: theming.get-color-from-palette($primary);
160
161 @include a11y.high-contrast(active, off) {
162 outline: solid 1px;
163 border-radius: 0;
164 }
165 }
166
167 .mat-badge-accent {
168 .mat-badge-content {
169 background: theming.get-color-from-palette($accent);
170 color: theming.get-color-from-palette($accent, default-contrast);
171 }
172 }
173
174 .mat-badge-warn {
175 .mat-badge-content {
176 color: theming.get-color-from-palette($warn, default-contrast);
177 background: theming.get-color-from-palette($warn);
178 }
179 }
180
181 .mat-badge-disabled {
182 .mat-badge-content {
183 $app-background: theming.get-color-from-palette($background, 'background');
184 $badge-color: theming.get-color-from-palette($foreground, disabled-button);
185
186 // The disabled color usually has some kind of opacity, but because the badge is overlayed
187 // on top of something else, it won't look good if it's opaque. If it is a color *type*,
188 // we convert it into a solid color by taking the opacity from the rgba value and using
189 // the value to determine the percentage of the background to put into foreground when
190 // mixing the colors together.
191 @if (meta.type-of($badge-color) == color and meta.type-of($app-background) == color) {
192 $badge-opacity: opacity($badge-color);
193 background: color.mix($app-background, rgba($badge-color, 1), (1 - $badge-opacity) * 100%);
194 }
195 @else {
196 background: $badge-color;
197 }
198
199 color: theming.get-color-from-palette($foreground, disabled-text);
200 }
201 }
202}
203
204@mixin typography($config-or-theme) {
205 $config: typography.private-typography-to-2014-config(
206 theming.get-typography-config($config-or-theme));
207 .mat-badge-content {
208 font-weight: $font-weight;
209 font-size: $font-size;
210 font-family: typography-utils.font-family($config);
211 }
212
213 .mat-badge-small .mat-badge-content {
214 // Set the font size to 75% of the original.
215 font-size: $font-size * 0.75;
216 }
217
218 .mat-badge-large .mat-badge-content {
219 font-size: $font-size * 2;
220 }
221}
222
223@mixin _density($config-or-theme) {}
224
225@mixin theme($theme-or-color-config) {
226 $theme: theming.private-legacy-get-theme($theme-or-color-config);
227 @include theming.private-check-duplicate-theme-styles($theme, 'mat-badge') {
228 $color: theming.get-color-config($theme);
229 $density: theming.get-density-config($theme);
230 $typography: theming.get-typography-config($theme);
231
232 // Try to reduce the number of times that the structural styles are emitted.
233 @if not $_badge-structure-emitted {
234 @include _badge-structure;
235
236 // Only flip the flag if the mixin is included at the top level. Otherwise the first
237 // inclusion might be inside of a theme class which will exclude the structural styles
238 // from all other themes.
239 @if not & {
240 $_badge-structure-emitted: true !global;
241 }
242 }
243
244 @if $color != null {
245 @include color($color);
246 }
247 @if $density != null {
248 @include _density($density);
249 }
250 @if $typography != null {
251 @include typography($typography);
252 }
253 }
254}
Note: See TracBrowser for help on using the repository browser.