@@ -15,7 +15,135 @@ See the License for the specific language governing permissions and
1515limitations under the License.
1616*/
1717
18- $light-theme : ();
18+ @use ' sass:map' ;
19+ @use ' sass:string' ;
20+ @use ' sass:selector' ;
21+ @use ' @material/elevation/elevation-theme' ;
22+ @use ' @material/theme/theme' ;
23+ @use ' @material/theme/theme-color' ;
24+ @use ' @material/theme/custom-properties' ;
25+ @use ' @material/theme/shadow-dom' ;
26+ @use ' @material/fab/variables' as fab-variables ;
27+ @use ' @material/mwc-ripple/src/ripple-theme' ;
28+
29+ // TODO(b/153370936): replace with theme.resolve()
30+ $light-theme : (
31+ ink-color : theme-color .prop-value (on-secondary ),
32+ ink-color-hover : theme-color .prop-value (on-secondary ),
33+ ink-color-focus : theme-color .prop-value (on-secondary ),
34+ ink-color-press : theme-color .prop-value (on-secondary ),
35+ container-color : theme-color .prop-value (secondary ),
36+ container-color-hover : theme-color .prop-value (secondary ),
37+ container-color-focus : theme-color .prop-value (secondary ),
38+ container-color-press : theme-color .prop-value (secondary ),
39+ icon-size : 24px ,
40+ extended-icon-padding : fab-variables .$extended-icon-padding ,
41+ extended-label-padding : fab-variables .$extended-label-padding ,
42+ ripple : (
43+ state : currentcolor ,
44+ opacity-hover : 0.04 ,
45+ opacity-focus : 0.12 ,
46+ opacity-press : 0.1 ,
47+ ),
48+ elevation-shadow-color : black ,
49+ icon-font-family : ' Material Icons' ,
50+ );
1951
2052@mixin theme ($theme : $light-theme ) {
53+ $container-color : map .get ($theme , container-color );
54+ @if $container-color {
55+ --mdc-theme-secondary : #{$container-color } ;
56+ }
57+
58+ $icon-font-family : map .get ($theme , icon-font-family );
59+ @if $icon-font-family {
60+ --mdc-icon-font : #{$icon-font-family } ;
61+ }
62+
63+ $ink-color : map .get ($theme , ink-color );
64+ @if $ink-color {
65+ --mdc-theme-on-secondary : #{$ink-color } ;
66+ }
67+
68+ $elevation-shadow-color : map .get ($theme , elevation-shadow-color );
69+ @if $elevation-shadow-color {
70+ --mdc-fab-box-shadow : #{elevation-theme .elevation-box-shadow (
71+ 6 ,
72+ $color : $elevation-shadow-color
73+ )} ;
74+ }
75+
76+ @include shadow-dom .host-aware (selector .append (& , ' :hover' )) {
77+ $hover-container-color : map .get ($theme , container-color-hover );
78+ @if $hover-container-color {
79+ --mdc-theme-secondary : #{$hover-container-color } ;
80+ }
81+
82+ $hover-ink-color : map .get ($theme , ink-color-hover );
83+ @if $hover-ink-color {
84+ --mdc-theme-on-secondary : #{$hover-ink-color } ;
85+ }
86+ }
87+
88+ @include shadow-dom .host-aware (selector .append (& , ' :focus,:focus-within' )) {
89+ $focus-container-color : map .get ($theme , container-color-focus );
90+ @if $focus-container-color {
91+ --mdc-theme-secondary : #{$focus-container-color } ;
92+ }
93+
94+ $focus-ink-color : map .get ($theme , ink-color-focus );
95+ @if $focus-ink-color {
96+ --mdc-theme-on-secondary : #{$focus-ink-color } ;
97+ }
98+ }
99+
100+ @include shadow-dom .host-aware (
101+ selector .append (& , ' :hover,:focus,:focus-within' )
102+ ) {
103+ @if $elevation-shadow-color {
104+ --mdc-fab-box-shadow : #{elevation-theme .elevation-box-shadow (
105+ 8 ,
106+ $color : $elevation-shadow-color
107+ )} ;
108+ }
109+ }
110+
111+ @include shadow-dom .host-aware (selector .append (& , ' :active' )) {
112+ $press-container-color : map .get ($theme , container-color-press );
113+ @if $press-container-color {
114+ --mdc-theme-secondary : #{$press-container-color } ;
115+ }
116+
117+ $press-ink-color : map .get ($theme , ink-color-press );
118+ @if $press-ink-color {
119+ --mdc-theme-on-secondary : #{$press-ink-color } ;
120+ }
121+
122+ @if $elevation-shadow-color {
123+ --mdc-fab-box-shadow : #{elevation-theme .elevation-box-shadow (
124+ 12 ,
125+ $color : $elevation-shadow-color
126+ )} ;
127+ }
128+ }
129+
130+ $icon-size : map .get ($theme , icon-size );
131+ @if $icon-size {
132+ --mdc-icon-size : #{$icon-size } ;
133+ }
134+
135+ $extended-icon-padding : map .get ($theme , extended-icon-padding );
136+ @if $extended-icon-padding {
137+ --mdc-fab-extended-icon-padding : #{$extended-icon-padding } ;
138+ }
139+
140+ $extended-label-padding : map .get ($theme , extended-label-padding );
141+ @if $extended-label-padding {
142+ --mdc-fab-extended-label-padding : #{$extended-label-padding } ;
143+ }
144+
145+ $ripple : map .get ($theme , ripple );
146+ @if $ripple {
147+ @include ripple-theme .theme ($ripple );
148+ }
21149}
0 commit comments