UNPKG

7.31 kBSCSSView Raw
1//
2// Copyright 2017 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@import "@material/elevation/mixins";
24@import "@material/ripple/mixins";
25@import "@material/rtl/mixins";
26@import "@material/theme/mixins";
27@import "@material/typography/mixins";
28@import "./mixins";
29@import "./variables";
30
31// postcss-bem-linter: define toolbar
32.mdc-toolbar {
33 @include mdc-toolbar-fill-color-accessible(primary);
34
35 display: flex;
36 position: relative;
37 flex-direction: column;
38 justify-content: space-between;
39 box-sizing: border-box;
40 width: 100%;
41
42 &__row {
43 display: flex;
44 position: relative;
45 align-items: center;
46 box-sizing: border-box;
47 width: 100%;
48 height: auto;
49 min-height: $mdc-toolbar-row-height;
50
51 // TODO: refactor this out when #23 is implemented
52 @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint) and (orientation: landscape) {
53 min-height: $mdc-toolbar-mobile-landscape-row-height;
54 }
55
56 // TODO: refactor this out when #23 is implemented
57 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
58 min-height: $mdc-toolbar-mobile-row-height;
59 }
60 }
61
62 &__section {
63 display: inline-flex;
64 flex: 1;
65 align-items: start;
66 justify-content: center;
67 box-sizing: border-box;
68 min-width: 0;
69 height: 100%;
70 padding: $mdc-toolbar-element-section-padding;
71 z-index: 1;
72
73 @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint) and (orientation: landscape) {
74 padding: 0;
75 }
76
77 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
78 padding: $mdc-toolbar-element-mobile-section-padding 0;
79 }
80
81 &--align-start {
82 @include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-section-horizontal-padding);
83
84 justify-content: flex-start;
85 order: -1;
86
87 @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint) and (orientation: landscape) {
88 @include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-mobile-section-horizontal-padding);
89 }
90
91 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
92 @include mdc-rtl-reflexive-box(padding, "left", $mdc-toolbar-mobile-section-horizontal-padding);
93 }
94 }
95
96 &--align-end {
97 @include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-section-horizontal-padding);
98
99 justify-content: flex-end;
100 order: 1;
101
102 @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint) and (orientation: landscape) {
103 @include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-mobile-section-horizontal-padding);
104 }
105
106 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
107 @include mdc-rtl-reflexive-box(padding, "right", $mdc-toolbar-mobile-section-horizontal-padding);
108 }
109 }
110 }
111
112 &__title {
113 @include mdc-typography(headline6);
114 @include mdc-typography-overflow-ellipsis;
115 @include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-element-horizontal-padding-desktop);
116
117 align-self: center;
118 padding: 12px 0;
119 line-height: 1.5rem;
120 z-index: 1;
121 }
122
123 &__icon,
124 &__menu-icon {
125 @include mdc-toolbar-icon_;
126 }
127}
128
129.mdc-toolbar__menu-icon + .mdc-toolbar__title {
130 @include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-title-margin-to-menu-icon-desktop);
131}
132
133@media (max-width: $mdc-toolbar-mobile-breakpoint) {
134 .mdc-toolbar__title {
135 @include mdc-rtl-reflexive-box(margin, left, $mdc-toolbar-element-horizontal-padding-mobile);
136 }
137}
138
139.mdc-toolbar--fixed {
140 @include mdc-elevation(4);
141
142 position: fixed;
143 top: 0;
144 left: 0;
145 z-index: 4;
146}
147
148.mdc-toolbar--flexible {
149 // bem linter is disabled because it cannot correctly reconcile mdc prefix for css variables.
150 // stylelint-disable-next-line plugin/selector-bem-pattern
151 --mdc-toolbar-ratio-to-extend-flexible: #{$mdc-toolbar-ratio-to-extend-flexible};
152
153 .mdc-toolbar__row:first-child {
154 height: $mdc-toolbar-row-height * $mdc-toolbar-ratio-to-extend-flexible;
155 height:
156 calc(
157 #{$mdc-toolbar-row-height} *
158 var(--mdc-toolbar-ratio-to-extend-flexible, #{$mdc-toolbar-ratio-to-extend-flexible})
159 );
160
161 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
162 height: $mdc-toolbar-mobile-row-height * $mdc-toolbar-ratio-to-extend-flexible;
163 height:
164 calc(
165 #{$mdc-toolbar-mobile-row-height} *
166 var(--mdc-toolbar-ratio-to-extend-flexible, #{$mdc-toolbar-ratio-to-extend-flexible})
167 );
168 }
169
170 &::after {
171 // The style ensures the pseudo element will be defined and can easily be styled
172 position: absolute;
173 content: "";
174 }
175 }
176
177 // stylelint-disable plugin/selector-bem-pattern
178 // bem linter is disabled because it cannot handle multiple top level selector
179 &-default-behavior {
180 .mdc-toolbar__title {
181 @include mdc-typography(headline6);
182
183 align-self: flex-end;
184 line-height: 1.5rem;
185 }
186
187 .mdc-toolbar__row:first-child::after {
188 top: 0;
189 left: 0;
190 width: 100%;
191 height: 100%;
192 transition: opacity .2s ease;
193 opacity: 1;
194 }
195
196 &.mdc-toolbar--flexible-space-minimized {
197 .mdc-toolbar__row:first-child::after {
198 opacity: 0;
199 }
200
201 .mdc-toolbar__title {
202 font-weight: #{map-get($mdc-typography-font-weight-values, medium)};
203 }
204 }
205 }
206}
207
208.mdc-toolbar--waterfall {
209 &.mdc-toolbar--fixed {
210 @include mdc-elevation(0);
211
212 transition: mdc-elevation-transition-value();
213 will-change: $mdc-elevation-property;
214
215 &.mdc-toolbar--flexible-space-minimized {
216 @include mdc-elevation(4);
217 }
218
219 &.mdc-toolbar--fixed-lastrow-only {
220 &.mdc-toolbar--flexible-space-minimized {
221 @include mdc-elevation(0);
222 }
223
224 &.mdc-toolbar--fixed-at-last-row {
225 @include mdc-elevation(4);
226 }
227 }
228 }
229}
230// postcss-bem-linter: end
231// stylelint-enable plugin/selector-bem-pattern
232
233.mdc-toolbar-fixed-adjust {
234 padding-top: $mdc-toolbar-row-height;
235
236 @media (max-width: $mdc-toolbar-mobile-landscape-width-breakpoint) and (max-height: $mdc-toolbar-mobile-breakpoint) {
237 padding-top: $mdc-toolbar-mobile-landscape-row-height;
238 }
239
240 @media (max-width: $mdc-toolbar-mobile-breakpoint) {
241 padding-top: $mdc-toolbar-mobile-row-height;
242 }
243}
244
245.mdc-toolbar__section--shrink-to-fit {
246 flex: none;
247}