UNPKG

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