mixin.less 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. @import '../../style/mixins/index';
  2. @tree-prefix-cls: ~'@{ant-prefix}-tree';
  3. @select-tree-prefix-cls: ~'@{ant-prefix}-select-tree';
  4. @tree-motion: ~'@{ant-prefix}-motion-collapse';
  5. @tree-node-padding: (@padding-xs / 2);
  6. @tree-node-hightlight-color: inherit;
  7. .antTreeSwitcherIcon(@type: 'tree-default-open-icon') {
  8. .@{tree-prefix-cls}-switcher-icon,
  9. .@{select-tree-prefix-cls}-switcher-icon {
  10. display: inline-block;
  11. font-size: 10px;
  12. vertical-align: baseline;
  13. svg {
  14. transition: transform 0.3s;
  15. }
  16. }
  17. }
  18. .drop-indicator() {
  19. .@{tree-prefix-cls}-drop-indicator {
  20. position: absolute;
  21. // it should displayed over the following node
  22. z-index: 1;
  23. height: 2px;
  24. background-color: @primary-color;
  25. border-radius: 1px;
  26. pointer-events: none;
  27. &::after {
  28. position: absolute;
  29. top: -3px;
  30. left: -6px;
  31. width: 8px;
  32. height: 8px;
  33. background-color: transparent;
  34. border: 2px solid @primary-color;
  35. border-radius: 50%;
  36. content: '';
  37. }
  38. }
  39. }
  40. .antTreeFn(@custom-tree-prefix-cls) {
  41. @custom-tree-node-prefix-cls: ~'@{custom-tree-prefix-cls}-treenode';
  42. .reset-component();
  43. background: @tree-bg;
  44. border-radius: @border-radius-base;
  45. transition: background-color 0.3s;
  46. &-focused:not(:hover):not(&-active-focused) {
  47. background: @primary-1;
  48. }
  49. // =================== Virtual List ===================
  50. &-list-holder-inner {
  51. align-items: flex-start;
  52. }
  53. &.@{custom-tree-prefix-cls}-block-node {
  54. .@{custom-tree-prefix-cls}-list-holder-inner {
  55. align-items: stretch;
  56. // >>> Title
  57. .@{custom-tree-prefix-cls}-node-content-wrapper {
  58. flex: auto;
  59. }
  60. // >>> Drag
  61. .@{custom-tree-node-prefix-cls}.dragging {
  62. position: relative;
  63. &::after {
  64. position: absolute;
  65. top: 0;
  66. right: 0;
  67. bottom: @tree-node-padding;
  68. left: 0;
  69. border: 1px solid @primary-color;
  70. opacity: 0;
  71. animation: ant-tree-node-fx-do-not-use 0.3s;
  72. animation-play-state: running;
  73. animation-fill-mode: forwards;
  74. content: '';
  75. pointer-events: none;
  76. }
  77. }
  78. }
  79. }
  80. // ===================== TreeNode =====================
  81. .@{custom-tree-node-prefix-cls} {
  82. display: flex;
  83. align-items: flex-start;
  84. padding: 0 0 @tree-node-padding 0;
  85. outline: none;
  86. // Disabled
  87. &-disabled {
  88. // >>> Title
  89. .@{custom-tree-prefix-cls}-node-content-wrapper {
  90. color: @disabled-color;
  91. cursor: not-allowed;
  92. &:hover {
  93. background: transparent;
  94. }
  95. }
  96. }
  97. &-active .@{custom-tree-prefix-cls}-node-content-wrapper {
  98. background: @tree-node-hover-bg;
  99. }
  100. &:not(&-disabled).filter-node .@{custom-tree-prefix-cls}-title {
  101. color: @tree-node-hightlight-color;
  102. font-weight: 500;
  103. }
  104. }
  105. // >>> Indent
  106. &-indent {
  107. align-self: stretch;
  108. white-space: nowrap;
  109. user-select: none;
  110. &-unit {
  111. display: inline-block;
  112. width: @tree-title-height;
  113. }
  114. }
  115. // >>> Drag Handler
  116. &-draggable-icon {
  117. width: @tree-title-height;
  118. line-height: @tree-title-height;
  119. text-align: center;
  120. opacity: 0.2;
  121. transition: opacity @animation-duration-slow;
  122. .@{custom-tree-node-prefix-cls}:hover & {
  123. opacity: 0.45;
  124. }
  125. }
  126. // >>> Switcher
  127. &-switcher {
  128. .antTreeSwitcherIcon();
  129. position: relative;
  130. flex: none;
  131. align-self: stretch;
  132. width: @tree-title-height;
  133. margin: 0;
  134. line-height: @tree-title-height;
  135. text-align: center;
  136. cursor: pointer;
  137. user-select: none;
  138. &-noop {
  139. cursor: default;
  140. }
  141. &_close {
  142. .@{custom-tree-prefix-cls}-switcher-icon {
  143. svg {
  144. transform: rotate(-90deg);
  145. }
  146. }
  147. }
  148. &-loading-icon {
  149. color: @primary-color;
  150. }
  151. &-leaf-line {
  152. position: relative;
  153. z-index: 1;
  154. display: inline-block;
  155. width: 100%;
  156. height: 100%;
  157. // https://github.com/ant-design/ant-design/issues/31884
  158. &::before {
  159. position: absolute;
  160. top: 0;
  161. right: 12px;
  162. bottom: -@tree-node-padding;
  163. margin-left: -1px;
  164. border-right: 1px solid @normal-color;
  165. content: ' ';
  166. }
  167. &::after {
  168. position: absolute;
  169. width: @tree-title-height - 14px;
  170. height: @tree-title-height - 10px;
  171. border-bottom: 1px solid @normal-color;
  172. content: ' ';
  173. }
  174. }
  175. }
  176. // >>> Checkbox
  177. &-checkbox {
  178. top: initial;
  179. margin: ((@tree-title-height - @checkbox-size) / 2) 8px 0 0;
  180. }
  181. // >>> Title
  182. & &-node-content-wrapper {
  183. position: relative;
  184. z-index: auto;
  185. min-height: @tree-title-height;
  186. margin: 0;
  187. padding: 0 4px;
  188. color: inherit;
  189. line-height: @tree-title-height;
  190. background: transparent;
  191. border-radius: @border-radius-base;
  192. cursor: pointer;
  193. transition: all 0.3s, border 0s, line-height 0s, box-shadow 0s;
  194. &:hover {
  195. background-color: @tree-node-hover-bg;
  196. }
  197. &.@{custom-tree-prefix-cls}-node-selected {
  198. background-color: @tree-node-selected-bg;
  199. }
  200. // Icon
  201. .@{custom-tree-prefix-cls}-iconEle {
  202. display: inline-block;
  203. width: @tree-title-height;
  204. height: @tree-title-height;
  205. line-height: @tree-title-height;
  206. text-align: center;
  207. vertical-align: top;
  208. &:empty {
  209. display: none;
  210. }
  211. }
  212. }
  213. // https://github.com/ant-design/ant-design/issues/28217
  214. &-unselectable &-node-content-wrapper:hover {
  215. background-color: transparent;
  216. }
  217. // ==================== Draggable =====================
  218. &-node-content-wrapper {
  219. line-height: @tree-title-height;
  220. user-select: none;
  221. .drop-indicator();
  222. }
  223. .@{custom-tree-node-prefix-cls}.drop-container {
  224. > [draggable] {
  225. box-shadow: 0 0 0 2px @primary-color;
  226. }
  227. }
  228. // ==================== Show Line =====================
  229. &-show-line {
  230. // ================ Indent lines ================
  231. .@{custom-tree-prefix-cls}-indent {
  232. &-unit {
  233. position: relative;
  234. height: 100%;
  235. &::before {
  236. position: absolute;
  237. top: 0;
  238. right: (@tree-title-height / 2);
  239. bottom: -@tree-node-padding;
  240. border-right: 1px solid @border-color-base;
  241. content: '';
  242. }
  243. &-end {
  244. &::before {
  245. display: none;
  246. }
  247. }
  248. }
  249. }
  250. // ============== Cover Background ==============
  251. .@{custom-tree-prefix-cls}-switcher {
  252. background: @component-background;
  253. &-line-icon {
  254. // https://github.com/ant-design/ant-design/issues/32813
  255. vertical-align: -0.15em;
  256. }
  257. }
  258. }
  259. .@{custom-tree-node-prefix-cls}-leaf-last {
  260. .@{custom-tree-prefix-cls}-switcher {
  261. &-leaf-line {
  262. &::before {
  263. top: auto !important;
  264. bottom: auto !important;
  265. height: @tree-title-height - 10px !important;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. @keyframes ant-tree-node-fx-do-not-use {
  272. 0% {
  273. opacity: 0;
  274. }
  275. 100% {
  276. opacity: 1;
  277. }
  278. }