table-v2.scss 4.2 KB

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