mixin.less 7.5 KB

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