_data-table.scss 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. // stylelint-disable selector-class-pattern --
  23. // NOTE: We disable `selector-class-pattern` above to allow using `mdc-` class
  24. // selectors.
  25. @use 'sass:list';
  26. @use '@material/animation/functions';
  27. @use '@material/checkbox/mixins' as checkbox-mixins;
  28. @use '@material/density/functions' as density-functions;
  29. @use '@material/dom/mixins' as dom;
  30. @use '@material/elevation/mixins';
  31. @use '@material/feature-targeting/feature-targeting';
  32. @use '@material/rtl/rtl';
  33. @use '@material/shape/mixins' as shape-mixins;
  34. @use '@material/theme/theme';
  35. @use '@material/theme/theme-color';
  36. @use '@material/typography/typography';
  37. @use './data-table-cell';
  38. @use './data-table-header-cell';
  39. @use './data-table-pagination';
  40. @use './data-table-progress-indicator';
  41. @use './data-table-theme';
  42. @mixin core-styles($query: feature-targeting.all()) {
  43. @include table-styles($query: $query);
  44. @include data-table-theme.sort-icon-color(
  45. data-table-theme.$sort-icon-color,
  46. $query: $query
  47. );
  48. @include data-table-theme.sort-icon-active-color(
  49. data-table-theme.$sort-icon-active-color,
  50. $query: $query
  51. );
  52. @include data-table-progress-indicator.static-styles($query: $query);
  53. @include data-table-pagination.core-styles($query: $query);
  54. }
  55. @mixin static-styles($query: feature-targeting.all()) {
  56. $feat-structure: feature-targeting.create-target($query, structure);
  57. .mdc-data-table {
  58. @include feature-targeting.targets($feat-structure) {
  59. // Makes the table scroll smoothly in iOS.
  60. // NOTE: Root element should not be scrollable, added this for backward
  61. // compatibility.
  62. -webkit-overflow-scrolling: touch;
  63. display: inline-flex;
  64. flex-direction: column;
  65. box-sizing: border-box;
  66. position: relative;
  67. }
  68. }
  69. .mdc-data-table__table-container {
  70. @include feature-targeting.targets($feat-structure) {
  71. // Makes the table scroll smoothly in iOS.
  72. -webkit-overflow-scrolling: touch;
  73. overflow-x: auto;
  74. width: 100%;
  75. }
  76. }
  77. .mdc-data-table__table {
  78. @include feature-targeting.targets($feat-structure) {
  79. min-width: 100%; // Makes table full-width of its container (Firefox / IE11)
  80. border: 0;
  81. white-space: nowrap;
  82. border-spacing: 0;
  83. /**
  84. * With table-layout:fixed, table and column widths are defined by the width
  85. * of the first row of cells. Cells in subsequent rows do not affect column
  86. * widths. This results in a predictable table layout and may also speed up
  87. * rendering.
  88. */
  89. table-layout: fixed;
  90. }
  91. }
  92. }
  93. // This API includes only the table styles without the sorting, pagination and
  94. // loading styles. It is intended to be used by frameworks that only need the
  95. // table styles.
  96. @mixin table-styles($query: feature-targeting.all()) {
  97. $feat-structure: feature-targeting.create-target($query, structure);
  98. $feat-typography: feature-targeting.create-target($query, typography);
  99. $feat-animation: feature-targeting.create-target($query, animation);
  100. // postcss-bem-linter: define data-table
  101. .mdc-data-table__content {
  102. @include typography.typography(body2, $query: $query);
  103. }
  104. .mdc-data-table {
  105. @include data-table-theme.fill-color(
  106. data-table-theme.$fill-color,
  107. $query: $query
  108. );
  109. @include data-table-theme.shape-radius(
  110. data-table-theme.$shape-radius,
  111. $query: $query
  112. );
  113. @include data-table-theme.stroke-size(
  114. data-table-theme.$stroke-size,
  115. $query: $query
  116. );
  117. @include data-table-theme.stroke-color(
  118. data-table-theme.$stroke-color,
  119. $query: $query
  120. );
  121. }
  122. // Note that we don't output the color styles inside the `@at-root`,
  123. // because it makes it difficult to consume by projects that wrap their
  124. // themes in a class (e.g. `.my-theme { @include mdc-data-table-core-style() }`).
  125. @include data-table-theme.row-fill-color(
  126. data-table-theme.$row-fill-color,
  127. $query: $query
  128. );
  129. @include data-table-theme.header-row-fill-color(
  130. data-table-theme.$header-row-fill-color,
  131. $query: $query
  132. );
  133. @include data-table-theme.selected-row-fill-color(
  134. data-table-theme.$selected-row-fill-color,
  135. $query: $query
  136. );
  137. @include data-table-theme.divider-color(
  138. data-table-theme.$divider-color,
  139. $query: $query
  140. );
  141. @include data-table-theme.divider-size(
  142. data-table-theme.$divider-size,
  143. $query: $query
  144. );
  145. @include data-table-theme.row-hover-fill-color(
  146. data-table-theme.$row-hover-fill-color,
  147. $query: $query
  148. );
  149. @include data-table-theme.header-row-text-color(
  150. data-table-theme.$header-row-text-color,
  151. $query: $query
  152. );
  153. @include data-table-theme.row-text-color(
  154. data-table-theme.$row-text-color,
  155. $query: $query
  156. );
  157. @include data-table-theme.density(
  158. data-table-theme.$default-density-scale,
  159. $query: $query
  160. );
  161. @include data-table-theme.cell-padding(
  162. $leading-padding: data-table-theme.$cell-leading-padding,
  163. $trailing-padding: data-table-theme.$cell-trailing-padding,
  164. $query: $query
  165. );
  166. @include data-table-cell.core-styles($query: $query);
  167. @include data-table-header-cell.core-styles($query: $query);
  168. .mdc-data-table--sticky-header {
  169. @include data-table-header-cell.header-cell-sticky($query: $query);
  170. }
  171. @include static-styles($query);
  172. @include data-table-header-cell.static-styles($query);
  173. @include data-table-cell.static-styles($query);
  174. @include data-table-pagination.static-styles($query);
  175. @include data-table-progress-indicator.static-styles($query);
  176. }
  177. @mixin theme-baseline($query: feature-targeting.all()) {
  178. @include data-table-theme.checked-icon-color(
  179. data-table-theme.$checked-icon-color,
  180. $query: $query
  181. );
  182. }