UNPKG

3.89 kBSCSSView Raw
1@use 'sass:map';
2@use 'sass:meta';
3@use '../core/style/private';
4@use '../core/theming/theming';
5@use '../core/typography/typography';
6@use '../core/typography/typography-utils';
7
8$chip-remove-font-size: 18px;
9
10@mixin _element-color($foreground, $background) {
11 background-color: $background;
12 color: $foreground;
13
14 .mat-chip-remove {
15 color: $foreground;
16 opacity: 0.4;
17 }
18}
19
20
21// Applies the background color for a ripple element.
22// If the color value provided is not a Sass color,
23// we assume that we've been given a CSS variable.
24// Since we can't perform alpha-blending on a CSS variable,
25// we instead add the opacity directly to the ripple element.
26@mixin _ripple-background($palette, $default-contrast, $opacity) {
27 $background-color: theming.get-color-from-palette($palette, $default-contrast, $opacity);
28 background-color: $background-color;
29 @if (meta.type-of($background-color) != color) {
30 opacity: $opacity;
31 }
32}
33
34@mixin _palette-styles($palette) {
35 @include _element-color(theming.get-color-from-palette($palette, default-contrast),
36 theming.get-color-from-palette($palette));
37
38 .mat-ripple-element {
39 @include _ripple-background($palette, default-contrast, 0.1);
40 }
41}
42
43/// @deprecated Use `mat.chips-color` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
44/// @breaking-change 17.0.0
45@mixin color($config-or-theme) {
46 $config: theming.get-color-config($config-or-theme);
47 $is-dark-theme: map.get($config, is-dark);
48 $primary: map.get($config, primary);
49 $accent: map.get($config, accent);
50 $warn: map.get($config, warn);
51 $background: map.get($config, background);
52 $foreground: map.get($config, foreground);
53
54 $unselected-background: theming.get-color-from-palette($background, unselected-chip);
55 $unselected-foreground: theming.get-color-from-palette($foreground, text);
56
57 .mat-chip.mat-standard-chip {
58 @include _element-color($unselected-foreground, $unselected-background);
59
60 &:not(.mat-chip-disabled) {
61 &:active {
62 @include private.private-theme-elevation(3, $config);
63 }
64
65 .mat-chip-remove:hover {
66 opacity: 0.54;
67 }
68 }
69
70 &.mat-chip-disabled {
71 opacity: 0.4;
72 }
73
74 &::after {
75 background: map.get($foreground, base);
76 }
77 }
78
79 .mat-chip.mat-standard-chip.mat-chip-selected {
80 &.mat-primary {
81 @include _palette-styles($primary);
82 }
83
84 &.mat-warn {
85 @include _palette-styles($warn);
86 }
87
88 &.mat-accent {
89 @include _palette-styles($accent);
90 }
91 }
92}
93
94/// @deprecated Use `mat.chips-typography` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
95/// @breaking-change 17.0.0
96@mixin typography($config-or-theme) {
97 $config: typography.private-typography-to-2014-config(
98 theming.get-typography-config($config-or-theme));
99 .mat-chip {
100 font-size: typography-utils.font-size($config, body-2);
101 font-weight: typography-utils.font-weight($config, body-2);
102
103 .mat-chip-trailing-icon.mat-icon,
104 .mat-chip-remove.mat-icon {
105 font-size: $chip-remove-font-size;
106 }
107 }
108}
109
110@mixin _density($config-or-theme) {}
111
112/// @deprecated Use `mat.chips-theme` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
113/// @breaking-change 17.0.0
114@mixin theme($theme-or-color-config) {
115 $theme: theming.private-legacy-get-theme($theme-or-color-config);
116 @include theming.private-check-duplicate-theme-styles($theme, 'mat-legacy-chips') {
117 $color: theming.get-color-config($theme);
118 $density: theming.get-density-config($theme);
119 $typography: theming.get-typography-config($theme);
120
121 @if $color != null {
122 @include color($color);
123 }
124 @if $density != null {
125 @include _density($density);
126 }
127 @if $typography != null {
128 @include typography($typography);
129 }
130 }
131}
132
133