_banner.scss 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. // Selector '.mdc-*' should only be used in this project.
  23. // stylelint-disable selector-class-pattern --
  24. // Internal styling for Tooltip MDC component.
  25. @use 'sass:math';
  26. @use '@material/feature-targeting/feature-targeting';
  27. @use '@material/typography/typography';
  28. @use '@material/button/button-theme';
  29. @use '@material/ripple/ripple-theme';
  30. @use '@material/rtl/rtl';
  31. @use './banner-theme';
  32. $_text-type-scale: body2;
  33. $_min-width: 344px;
  34. $_max-width: 720px;
  35. // Minimum banner height minus standard text height, divided by 2 for both top
  36. // and bottom padding. This is used to support two/three line banners.
  37. $_text-padding-top-bottom: math.div(52px - 20px, 2);
  38. $_enter-duration: 300ms;
  39. $_exit-duration: 250ms;
  40. /// Core styles for banner component.
  41. @mixin core-styles($query: feature-targeting.all()) {
  42. $feat-structure: feature-targeting.create-target($query, structure);
  43. $feat-animation: feature-targeting.create-target($query, animation);
  44. @include banner-theme.graphic-color(
  45. banner-theme.$graphic-color,
  46. $query: $query
  47. );
  48. @include banner-theme.graphic-background-color(
  49. banner-theme.$graphic-background-color,
  50. $query: $query
  51. );
  52. @include banner-theme.min-width($_min-width, $query: $query);
  53. @include banner-theme.max-width($_max-width, $query: $query);
  54. @include static-styles($query: $query);
  55. .mdc-banner {
  56. @include banner-theme.theme-styles(
  57. banner-theme.$light-theme,
  58. $query: $query
  59. );
  60. }
  61. .mdc-banner__secondary-action {
  62. @include feature-targeting.targets($feat-structure) {
  63. @include rtl.reflexive-property(margin, 0, 8px);
  64. }
  65. }
  66. }
  67. @mixin static-styles($query: feature-targeting.all()) {
  68. $feat-structure: feature-targeting.create-target($query, structure);
  69. $feat-animation: feature-targeting.create-target($query, animation);
  70. .mdc-banner {
  71. @include banner-theme.z-index(banner-theme.$z-index, $query: $query);
  72. @include feature-targeting.targets($feat-structure) {
  73. // Mobile view styles.
  74. @media (max-width: banner-theme.$mobile-breakpoint) {
  75. // Span across viewport for fixed mobile view.
  76. .mdc-banner__fixed {
  77. left: 0;
  78. right: 0;
  79. }
  80. .mdc-banner__text {
  81. @include rtl.reflexive-property(margin, 16px, 36px);
  82. }
  83. }
  84. border-bottom-style: solid;
  85. box-sizing: border-box;
  86. display: none;
  87. flex-shrink: 0;
  88. height: 0;
  89. position: relative;
  90. width: 100%;
  91. }
  92. &.mdc-banner--mobile-stacked {
  93. @media (max-width: banner-theme.$mobile-breakpoint) {
  94. @include banner-theme.layout-stacked($query: $query);
  95. }
  96. }
  97. }
  98. .mdc-banner--opening,
  99. .mdc-banner--open,
  100. .mdc-banner--closing {
  101. @include feature-targeting.targets($feat-structure) {
  102. display: flex;
  103. }
  104. }
  105. .mdc-banner--open {
  106. @include feature-targeting.targets($feat-animation) {
  107. transition: height $_enter-duration ease;
  108. }
  109. .mdc-banner__content {
  110. @include feature-targeting.targets($feat-animation) {
  111. transition: transform $_enter-duration ease;
  112. }
  113. @include feature-targeting.targets($feat-structure) {
  114. transform: translateY(0);
  115. }
  116. }
  117. }
  118. .mdc-banner--closing {
  119. @include feature-targeting.targets($feat-animation) {
  120. transition: height $_exit-duration ease;
  121. }
  122. .mdc-banner__content {
  123. @include feature-targeting.targets($feat-animation) {
  124. transition: transform $_exit-duration ease;
  125. }
  126. }
  127. }
  128. .mdc-banner--centered {
  129. @include banner-theme.position-centered($query: $query);
  130. }
  131. .mdc-banner__fixed {
  132. @include feature-targeting.targets($feat-structure) {
  133. border-bottom-style: solid;
  134. box-sizing: border-box;
  135. height: inherit;
  136. position: fixed;
  137. width: 100%;
  138. }
  139. }
  140. .mdc-banner__content {
  141. @include feature-targeting.targets($feat-structure) {
  142. display: flex;
  143. min-height: 52px;
  144. position: absolute;
  145. transform: translateY(-100%);
  146. width: 100%;
  147. }
  148. }
  149. .mdc-banner__graphic-text-wrapper {
  150. @include feature-targeting.targets($feat-structure) {
  151. display: flex;
  152. width: 100%;
  153. }
  154. }
  155. .mdc-banner__graphic {
  156. @include feature-targeting.targets($feat-structure) {
  157. @include rtl.reflexive-property(margin, 16px, 0);
  158. flex-shrink: 0;
  159. margin-top: 16px;
  160. margin-bottom: 16px;
  161. text-align: center;
  162. }
  163. }
  164. .mdc-banner__icon {
  165. @include feature-targeting.targets($feat-structure) {
  166. position: relative;
  167. top: 50%;
  168. transform: translateY(-50%);
  169. }
  170. }
  171. .mdc-banner__text {
  172. @include feature-targeting.targets($feat-structure) {
  173. @include rtl.reflexive-property(margin, 24px, 90px);
  174. align-self: center;
  175. flex-grow: 1;
  176. padding-top: $_text-padding-top-bottom;
  177. padding-bottom: $_text-padding-top-bottom;
  178. }
  179. }
  180. .mdc-banner__actions {
  181. @include feature-targeting.targets($feat-structure) {
  182. @include rtl.reflexive-property(padding, 0, 8px);
  183. align-self: flex-end;
  184. display: flex;
  185. flex-shrink: 0;
  186. padding-bottom: 8px;
  187. padding-top: 8px;
  188. }
  189. }
  190. .mdc-banner__secondary-action {
  191. @include feature-targeting.targets($feat-structure) {
  192. @include rtl.reflexive-property(margin, 0, 8px);
  193. }
  194. }
  195. }