UNPKG

3.89 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 flat-container-elevation: null,
33 flat-outline-color: null,
34 flat-outline-width: null,
35 elevated-container-elevation: null,
36 elevated-container-color: null,
37 elevated-container-shadow-color: null,
38 container-surface-tint-layer-color: null,
39 label-text-font: null,
40 label-text-line-height: null,
41 label-text-size: null,
42 label-text-weight: null,
43 label-text-tracking: null,
44 label-text-color: null,
45 with-icon-icon-size: null,
46 with-icon-icon-color: null,
47 flat-disabled-outline-color: null,
48 flat-disabled-outline-opacity: null,
49 disabled-label-text-color: null,
50 disabled-label-text-opacity: null,
51 with-icon-disabled-icon-color: null,
52 with-icon-disabled-icon-opacity: null,
53 elevated-disabled-container-elevation: null,
54 elevated-disabled-container-color: null,
55 elevated-disabled-container-opacity: null,
56 hover-state-layer-color: null,
57 hover-state-layer-opacity: null,
58 hover-label-text-color: null,
59 with-icon-hover-icon-color: null,
60 elevated-hover-container-elevation: null,
61 focus-state-layer-color: null,
62 focus-state-layer-opacity: null,
63 focus-label-text-color: null,
64 flat-focus-outline-color: null,
65 with-icon-focus-icon-color: null,
66 elevated-focus-container-elevation: null,
67 pressed-state-layer-color: null,
68 pressed-state-layer-opacity: null,
69 pressed-label-text-color: null,
70 with-icon-pressed-icon-color: null,
71 elevated-pressed-container-elevation: null,
72);
73
74$_custom-property-prefix: 'assist-chip';
75
76@mixin theme($theme, $resolvers: resolvers.$material) {
77 @include theme.validate-theme($_light-theme, $theme);
78
79 // Resolve elevation.
80 @each $key
81 in (
82 flat-container-elevation,
83 elevated-container-elevation,
84 elevated-disabled-container-elevation,
85 elevated-hover-container-elevation,
86 elevated-focus-container-elevation,
87 elevated-pressed-container-elevation
88 )
89 {
90 $value: map.get($theme, $key);
91 @if $value {
92 $theme: map.set(
93 $theme,
94 $key,
95 meta.call(
96 $elevation-resolver: map.get($resolvers, elevation),
97 $elevation: $value,
98 $shadow-color: map.get($theme, elevated-container-shadow-color),
99 )
100 );
101 }
102 }
103
104 @include keys.declare-custom-properties(
105 $theme,
106 $prefix: $_custom-property-prefix
107 );
108}
109
110@mixin theme-styles($theme, $resolvers: resolvers.$material) {
111 @include theme.validate-theme($_light-theme, $theme);
112 $theme: keys.create-theme-properties(
113 $theme,
114 $prefix: $_custom-property-prefix
115 );
116 @include chip-theme.theme-styles($theme, $resolvers: $resolvers);
117}