UNPKG

5.13 kBSCSSView Raw
1//
2// Copyright 2020 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// stylelint-disable selector-class-pattern --
24// Selector '.mdc-*' should only be used in this project.
25
26@use '@material/feature-targeting/feature-targeting';
27@use '@material/rtl/rtl';
28@use '@material/touch-target/mixins' as touch-target-mixins;
29@use '@material/typography/typography';
30@use './button-base';
31@use './button-filled';
32@use './button-filled-theme';
33@use './button-outlined';
34@use './button-outlined-theme';
35@use './button-protected';
36@use './button-protected-theme';
37@use './button-ripple';
38@use './button-text';
39@use './button-text-theme';
40@use './button-theme';
41@use './button-shared-theme';
42
43// For backwards compatibility.
44@forward './button-base' show deprecated-base, base, icon, icon-trailing, icon-svg, icon-contained, icon-contained-trailing, deprecated-icon, deprecated-icon-trailing, deprecated-icon-svg, deprecated-icon-contained, deprecated-icon-contained-trailing;
45
46@mixin styles($query: feature-targeting.all()) {
47 @include static-styles($query: $query);
48 @include theme-styles($query: $query);
49}
50
51@mixin theme-styles($query: feature-targeting.all()) {
52 .mdc-button {
53 @include button-text-theme.theme-styles(
54 button-text-theme.$light-theme,
55 $query: $query
56 );
57 }
58 .mdc-button--unelevated {
59 @include button-filled-theme.theme-styles(
60 button-filled-theme.$light-theme,
61 $query: $query
62 );
63 }
64 .mdc-button--raised {
65 @include button-protected-theme.theme-styles(
66 button-protected-theme.$light-theme,
67 $query: $query
68 );
69 }
70 .mdc-button--outlined {
71 @include button-outlined-theme.theme-styles(
72 button-outlined-theme.$light-theme,
73 $query: $query
74 );
75 }
76}
77
78@mixin static-styles($query: feature-targeting.all()) {
79 @include static-styles-without-ripple($query: $query);
80 @include button-ripple.static-styles($query: $query);
81}
82
83@mixin static-styles-without-ripple($query: feature-targeting.all()) {
84 @include button-base.static-styles($query: $query);
85 @include button-text.static-styles-without-ripple($query: $query);
86 @include button-filled.static-styles-without-ripple($query: $query);
87 @include button-protected.static-styles-without-ripple($query: $query);
88 @include button-outlined.static-styles-without-ripple($query: $query);
89}
90
91// Legacy mixins
92
93@mixin without-ripple($query: feature-targeting.all()) {
94 @include button-base.deprecated-static-styles-without-ripple($query: $query);
95 @include button-text.static-styles-without-ripple($query: $query);
96 @include button-filled.static-styles-without-ripple($query: $query);
97 @include button-protected.static-styles-without-ripple($query: $query);
98 @include button-outlined.static-styles-without-ripple($query: $query);
99 @include _theme-styles-without-ripple($query: $query);
100}
101
102@mixin _theme-styles-without-ripple($query: feature-targeting.all()) {
103 @include button-text-theme.deprecated-theme-styles($query: $query);
104 @include button-filled-theme.deprecated-theme-styles($query: $query);
105 @include button-outlined-theme.deprecated-theme-styles($query: $query);
106 // Elevation has been recategorized into theme styles. Keeping old elevation
107 // styles here for backwards compatibility.
108 .mdc-button--raised {
109 @include button-protected.raised($query: $query);
110 }
111}
112
113// @deprecated - use styles() instead.
114@mixin core-styles($query: feature-targeting.all()) {
115 @include styles($query: $query);
116 // TODO: remove this rule since padding now takes care of icon margins.
117 $feat-structure: feature-targeting.create-target($query, structure);
118 .mdc-button--raised,
119 .mdc-button--unelevated,
120 .mdc-button--outlined {
121 .mdc-button__icon {
122 @include feature-targeting.targets($feat-structure) {
123 // Icons inside contained buttons have different styles due to increased button padding
124 @include button-base.icon-contained;
125 }
126 }
127
128 .mdc-button__label + .mdc-button__icon {
129 @include feature-targeting.targets($feat-structure) {
130 @include button-base.icon-contained-trailing;
131 }
132 }
133 }
134}