UNPKG

3.76 kBSCSSView Raw
1// Copyright 2021 Google Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21@use '@material/theme/keys';
22@use '@material/theme/theme';
23@use '@material/theme/theme-color';
24@use '@material/tokens/resolvers';
25@use './fab-theme';
26@use 'sass:map';
27
28$height: 56px !default;
29$mini-height: 40px !default;
30$shape-radius: 50% !default;
31$ripple-target: '.mdc-fab__ripple';
32
33$_light-theme: (
34 container-color: secondary,
35 container-elevation: 6,
36 container-height: 40px,
37 container-shadow-color: black,
38 container-shape: $shape-radius,
39 container-width: 40px,
40 focus-container-elevation: null,
41 focus-icon-color: null,
42 focus-outline-color: null,
43 focus-outline-width: null,
44 focus-state-layer-color: theme-color.$primary,
45 focus-state-layer-opacity: null,
46 hover-container-elevation: null,
47 hover-icon-color: null,
48 hover-state-layer-color: theme-color.$primary,
49 hover-state-layer-opacity: null,
50 icon-color: on-secondary,
51 icon-size: 24px,
52 lowered-container-elevation: null,
53 lowered-focus-container-elevation: null,
54 lowered-hover-container-elevation: null,
55 lowered-pressed-container-elevation: null,
56 pressed-container-elevation: null,
57 pressed-icon-color: null,
58 pressed-ripple-color: null,
59 pressed-ripple-opacity: null,
60 pressed-state-layer-color: theme-color.$primary,
61 pressed-state-layer-opacity: null,
62);
63
64$custom-property-prefix: 'fab-small';
65
66///
67/// Applies the given theme as custom properties without any selectors.
68///
69/// @param {Map} $theme - Theme configuration to use for theming the small fab.
70/// @param {Map} $resolvers [resolvers.$material] - map of resolver functions
71/// that resolve token names to a valid Material theme config.
72@mixin theme($theme, $resolvers: resolvers.$material) {
73 @include theme.validate-theme($_light-theme, $theme);
74 $resolved-theme: fab-theme.resolve-theme($theme, $resolvers);
75 @include keys.declare-custom-properties(
76 $resolved-theme,
77 $prefix: $custom-property-prefix
78 );
79}
80
81///
82/// Applies the themable styles for small fabs and exposes CSS custom properties
83/// as well as selectors.
84///
85/// @param {Map} $theme - Theme configuration to use for theming the small fab.
86/// @param {Map} $resolvers [resolvers.$material] - map of resolver functions
87/// that resolve token names to a valid Material theme config.
88///
89@mixin theme-styles($theme, $resolvers: resolvers.$material) {
90 @include theme.validate-theme($_light-theme, $theme);
91
92 $theme: keys.create-theme-properties(
93 $theme,
94 $prefix: $custom-property-prefix
95 );
96 @include fab-theme.base-theme-styles($theme, $resolvers: $resolvers);
97
98 $shape-radius: map.get($theme, container-shape);
99 @if $shape-radius {
100 @include fab-theme.shape-radius($shape-radius);
101 }
102}