UNPKG

4.11 kBSCSSView Raw
1//
2// Copyright 2021 Google Inc.
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files (the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20// THE SOFTWARE.
21//
22
23@use 'sass:map';
24@use '@material/theme/theme';
25@use '@material/theme/keys';
26@use '@material/tokens/resolvers';
27@use './chip-theme';
28
29$_light-theme: (
30 container-shape: null,
31 container-height: null,
32 container-elevation: null,
33 outline-color: null,
34 outline-width: null,
35 container-shadow-color: null,
36 label-text-font: null,
37 label-text-line-height: null,
38 label-text-size: null,
39 label-text-weight: null,
40 label-text-tracking: null,
41 label-text-color: null,
42 with-trailing-icon-trailing-icon-size: null,
43 with-trailing-icon-trailing-icon-color: null,
44 with-leading-icon-leading-icon-size: null,
45 with-leading-icon-leading-icon-color: null,
46 with-avatar-avatar-size: null,
47 with-avatar-avatar-shape: null,
48 disabled-outline-color: null,
49 disabled-outline-opacity: null,
50 disabled-label-text-color: null,
51 disabled-label-text-opacity: null,
52 with-trailing-icon-disabled-trailing-icon-color: null,
53 with-trailing-icon-disabled-trailing-icon-opacity: null,
54 with-leading-icon-disabled-leading-icon-color: null,
55 with-leading-icon-disabled-leading-icon-opacity: null,
56 with-avatar-disabled-avatar-opacity: null,
57 hover-state-layer-color: null,
58 hover-state-layer-opacity: null,
59 hover-label-text-color: null,
60 with-trailing-icon-hover-trailing-icon-color: null,
61 with-leading-icon-hover-leading-icon-color: null,
62 focus-state-layer-color: null,
63 focus-state-layer-opacity: null,
64 focus-label-text-color: null,
65 focus-outline-color: null,
66 with-trailing-icon-focus-trailing-icon-color: null,
67 with-leading-icon-focus-leading-icon-color: null,
68 pressed-state-layer-color: null,
69 pressed-state-layer-opacity: null,
70 pressed-label-text-color: null,
71 with-trailing-icon-pressed-trailing-icon-color: null,
72 with-leading-icon-pressed-leading-icon-color: null,
73 container-surface-tint-layer-color: null,
74);
75
76$_custom-property-prefix: 'input-chip';
77
78@mixin theme($theme, $resolvers: resolvers.$material) {
79 @include theme.validate-theme($_light-theme, $theme);
80
81 // Resolve elevation.
82 @each $key
83 in (
84 flat-container-elevation,
85 elevated-container-elevation,
86 elevated-disabled-container-elevation,
87 elevated-hover-container-elevation,
88 elevated-focus-container-elevation,
89 elevated-pressed-container-elevation
90 )
91 {
92 $value: map.get($theme, $key);
93 @if $value {
94 $theme: map.set(
95 $theme,
96 $key,
97 meta.call(
98 $elevation-resolver: map.get($resolvers, elevation),
99 $elevation: $value,
100 $shadow-color: map.get($theme, elevated-container-shadow-color),
101 )
102 );
103 }
104 }
105
106 @include keys.declare-custom-properties(
107 $theme,
108 $prefix: $_custom-property-prefix
109 );
110}
111
112@mixin theme-styles($theme, $resolvers: resolvers.$material) {
113 @include theme.validate-theme($_light-theme, $theme);
114 $theme: keys.create-theme-properties(
115 $theme,
116 $prefix: $_custom-property-prefix
117 );
118 @include chip-theme.theme-styles($theme, $resolvers: $resolvers);
119}