table-v2.scss 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. @use 'sass:map';
  2. @use 'mixins/mixins' as *;
  3. @use 'mixins/var' as *;
  4. @use 'common/var' as *;
  5. @mixin center-flex() {
  6. display: flex;
  7. align-items: center;
  8. }
  9. @mixin cell-padding() {
  10. padding: 0 8px;
  11. }
  12. @mixin safe-padding() {
  13. padding-inline-end: getCssVar('table-scrollbar-size');
  14. }
  15. @mixin cell-alignment() {
  16. @include when('align-center') {
  17. justify-content: center;
  18. text-align: center;
  19. }
  20. @include when('align-right') {
  21. justify-content: flex-end;
  22. text-align: right;
  23. }
  24. }
  25. @mixin table-root() {
  26. display: flex;
  27. flex-direction: column-reverse;
  28. position: absolute;
  29. overflow: hidden;
  30. top: 0;
  31. background-color: getCssVar('bg', 'color');
  32. }
  33. @mixin hidden-scrollbar {
  34. .#{$namespace}-virtual-scrollbar {
  35. opacity: 0;
  36. }
  37. .#{$namespace}-vl__vertical,
  38. .#{$namespace}-vl__horizontal {
  39. z-index: -1;
  40. }
  41. }
  42. @include b('table-v2') {
  43. @include set-component-css-var('table', $table);
  44. }
  45. @include b('table-v2') {
  46. font-size: 14px;
  47. * {
  48. box-sizing: border-box;
  49. }
  50. @include e('root') {
  51. position: relative;
  52. // for showing the scrollbar when mouse is on the root table
  53. &:hover {
  54. @include e('main') {
  55. .#{$namespace}-virtual-scrollbar {
  56. opacity: 1;
  57. }
  58. }
  59. }
  60. }
  61. @include e('main') {
  62. @include table-root;
  63. left: 0;
  64. .#{$namespace}-vl__horizontal,
  65. .#{$namespace}-vl__vertical {
  66. z-index: 2;
  67. }
  68. }
  69. @include e('left') {
  70. @include table-root;
  71. left: 0;
  72. box-shadow: 2px 0 4px 0 rgb(0 0 0 / 6%);
  73. @include hidden-scrollbar;
  74. }
  75. @include e('right') {
  76. @include table-root;
  77. right: 0;
  78. box-shadow: -2px 0 4px 0 rgb(0 0 0 / 6%);
  79. @include hidden-scrollbar;
  80. @include e('header-row') {
  81. @include safe-padding;
  82. }
  83. @include e('row') {
  84. @include safe-padding;
  85. }
  86. }
  87. @include e('header-wrapper') {
  88. overflow: hidden;
  89. }
  90. @include e('header') {
  91. position: relative;
  92. overflow: hidden;
  93. }
  94. @include e('footer') {
  95. position: absolute;
  96. left: 0;
  97. right: 0;
  98. bottom: 0;
  99. overflow: hidden;
  100. }
  101. @include e('empty') {
  102. position: absolute;
  103. left: 0;
  104. }
  105. @include e('overlay') {
  106. position: absolute;
  107. left: 0;
  108. right: 0;
  109. top: 0;
  110. bottom: 0;
  111. z-index: 9999;
  112. }
  113. @include e('header-row') {
  114. display: flex;
  115. border-bottom: getCssVar('table', 'border');
  116. @include e('header-cell') {
  117. @include center-flex;
  118. @include cell-padding;
  119. @include cell-alignment;
  120. height: 100%;
  121. user-select: none;
  122. overflow: hidden;
  123. background-color: getCssVar('table-header', 'bg-color');
  124. color: getCssVar('table-header', 'text-color');
  125. font-weight: bold;
  126. @include when(sortable) {
  127. cursor: pointer;
  128. }
  129. &:hover {
  130. .#{$namespace}-icon {
  131. display: block;
  132. }
  133. }
  134. }
  135. @include e('sort-icon') {
  136. transition: opacity, display getCssVar('transition-duration', '');
  137. opacity: 0.6;
  138. display: none;
  139. @include when(sorting) {
  140. display: block;
  141. opacity: 1;
  142. }
  143. }
  144. }
  145. @include e('row') {
  146. border-bottom: getCssVar('table', 'border');
  147. @include center-flex;
  148. transition: background-color getCssVar('transition-duration', '');
  149. @include when('hovered') {
  150. background-color: getCssVar('table-row', 'hover-bg-color');
  151. }
  152. &:hover {
  153. background-color: getCssVar('table-row', 'hover-bg-color');
  154. }
  155. @include e('row-cell') {
  156. height: 100%;
  157. overflow: hidden;
  158. @include center-flex;
  159. @include cell-padding;
  160. @include cell-alignment;
  161. }
  162. @include e('expand-icon') {
  163. margin: 0 4px;
  164. cursor: pointer;
  165. user-select: none;
  166. svg {
  167. transition: transform getCssVar('transition-duration', '');
  168. }
  169. @include when(expanded) {
  170. svg {
  171. transform: rotate(90deg);
  172. }
  173. }
  174. }
  175. }
  176. &:not(.is-dynamic) {
  177. @include e('cell-text') {
  178. overflow: hidden;
  179. text-overflow: ellipsis;
  180. white-space: nowrap;
  181. }
  182. }
  183. @include when(dynamic) {
  184. @include e('row') {
  185. overflow: hidden;
  186. align-items: stretch;
  187. @include e('row-cell') {
  188. word-break: break-all;
  189. }
  190. }
  191. }
  192. }