@xihan-ui/styles 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/css/tree.css CHANGED
@@ -383,26 +383,88 @@
383
383
  }
384
384
 
385
385
  /*
386
- * 缩进参考线:每一层子节点的行首画一道竖线,对齐父节点展开箭头的中线,层级深时一眼看得出谁跟谁同层。
387
- * 线画在子层容器自己的伪元素上:定位在子层里,只贯穿这一层的全部子孙,不越出父节点的范围。
386
+ * 连接线:父节点展开箭头的中线向下引一道竖线,每个子节点从竖线横出一段接到自己行首(├),
387
+ * 最后一个子节点的竖线止于它那一行的中线(└),层级深时一眼看得出谁挂在谁下面。
388
+ * 线由每个子节点自己画:子节点的行画「这一段竖线 + 横出的那一段」,展开着的非末位分支再由它的子层
389
+ * 把竖线接过它整棵子树,交给下一个兄弟。子节点之间、分支行与子层之间的间距由线向上下伸出补齐,竖线不断开。
390
+ * 只画在竖排的子层里:顶层节点没有父节点可连,横排的末端层没有行首可接。
391
+ * 首个与末位子节点按子层里的结构次序认:子层里只放节点,收起的子树整块不显示、不影响次序。
388
392
  * 它是内部分隔的一种,颜色取 border-subtle;行悬停与选中换面时线压在面上照样看得见
389
393
  */
390
394
  [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'] {
391
395
  position: relative;
392
396
  }
393
397
 
394
- [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content']::before {
398
+ /* 竖线落在父节点展开箭头的中线上:父行的行首内边距加半个箭头盒,换算到缩进了一格的子节点坐标里。
399
+ 向上伸出的量补的是上方那段间距(首个子节点补分支行与子层之间的那段),向下补到下一个兄弟 */
400
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item'],
401
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch'] > [data-scope='tree'][data-part='branch-control'] {
402
+ --xh-_tree-line-x: calc(
403
+ var(--xh-tree-row-px, var(--xh-_tree-row-px)) +
404
+ var(--xh-_tree-indicator-size) / 2 -
405
+ var(--xh-stroke-thin) / 2 -
406
+ var(--xh-tree-indent, var(--xh-_tree-indent))
407
+ );
408
+ --xh-_tree-line-top: 0px;
409
+ --xh-_tree-line-bottom: var(--xh-tree-branch-content-gap, var(--xh-list-option-gap));
410
+
411
+ position: relative;
412
+ }
413
+
414
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item']:first-child,
415
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch']:first-child > [data-scope='tree'][data-part='branch-control'] {
416
+ --xh-_tree-line-top: var(--xh-tree-branch-gap, var(--xh-list-option-gap));
417
+ }
418
+
419
+ /* 展开着的非末位分支:行下面先是它自己的子层,竖线只伸到子层顶上,余下那段由子层接着画 */
420
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch'] > [data-scope='tree'][data-part='branch-control'][data-state='open'] {
421
+ --xh-_tree-line-bottom: var(--xh-tree-branch-gap, var(--xh-list-option-gap));
422
+ }
423
+
424
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item']::before,
425
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch'] > [data-scope='tree'][data-part='branch-control']::before {
426
+ content: '';
427
+ position: absolute;
428
+ inset-block: calc(var(--xh-_tree-line-top) * -1) calc(var(--xh-_tree-line-bottom) * -1);
429
+ inset-inline-start: var(--xh-_tree-line-x);
430
+ /* 分支横出到展开箭头盒的起点;叶子没有箭头,横线穿过占位那一格接到正文前 */
431
+ inline-size: calc(var(--xh-tree-row-px, var(--xh-_tree-row-px)) - var(--xh-_tree-line-x));
432
+ border-inline-start: var(--xh-stroke-thin) solid var(--xh-tree-line-color, var(--xh-border-subtle));
433
+ /* 横出的那段落在行的中线:线盒上下伸出的量不对称时按差值的一半补回 */
434
+ background: linear-gradient(var(--xh-tree-line-color, var(--xh-border-subtle)), var(--xh-tree-line-color, var(--xh-border-subtle)))
435
+ 0 calc(50% + (var(--xh-_tree-line-top) - var(--xh-_tree-line-bottom)) / 2) / 100% var(--xh-stroke-thin) no-repeat;
436
+ pointer-events: none;
437
+ }
438
+
439
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item']::before {
440
+ inline-size: calc(
441
+ var(--xh-tree-row-px, var(--xh-_tree-row-px)) +
442
+ var(--xh-_tree-indicator-size) -
443
+ var(--xh-_tree-line-x)
444
+ );
445
+ }
446
+
447
+ /* 最后一个子节点:竖线止于行的中线并在那里拐向行首(└),下面不再有兄弟要接 */
448
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item']:last-child::before,
449
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch']:last-child > [data-scope='tree'][data-part='branch-control']::before {
450
+ inset-block-end: calc(50% - var(--xh-stroke-thin) / 2);
451
+ border-block-end: var(--xh-stroke-thin) solid var(--xh-tree-line-color, var(--xh-border-subtle));
452
+ background: none;
453
+ }
454
+
455
+ /* 展开着的非末位分支:它的子层把父节点那道竖线接过整棵子树,一直伸到下一个兄弟。
456
+ 子层的盒与分支同起点(缩进是子层自己的内边距),竖线位置与分支行里那一段相同 */
457
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch']:not(:last-child) > [data-scope='tree'][data-part='branch-content']::after {
395
458
  content: '';
396
459
  position: absolute;
397
- inset-block: 0;
398
- /* 父行的行首内边距加半个箭头盒:竖线正好落在父节点展开箭头的中线上 */
460
+ inset-block: 0 calc(var(--xh-tree-branch-content-gap, var(--xh-list-option-gap)) * -1);
399
461
  inset-inline-start: calc(
400
462
  var(--xh-tree-row-px, var(--xh-_tree-row-px)) +
401
463
  var(--xh-tree-indicator-size, var(--xh-_tree-indicator)) / 2 -
402
- var(--xh-stroke-thin) / 2
464
+ var(--xh-stroke-thin) / 2 -
465
+ var(--xh-tree-indent, var(--xh-_tree-indent))
403
466
  );
404
- inline-size: var(--xh-stroke-thin);
405
- background: var(--xh-tree-line-color, var(--xh-border-subtle));
467
+ border-inline-start: var(--xh-stroke-thin) solid var(--xh-tree-line-color, var(--xh-border-subtle));
406
468
  pointer-events: none;
407
469
  }
408
470
 
@@ -631,10 +693,18 @@
631
693
  }
632
694
  }
633
695
 
634
- /* 强制色:参考线是一块底色,系统色下会被抹成 Canvas;换成 GrayText 并只让这条线不参与强制换色 */
696
+ /* 强制色:连接线的横段是一块渐变底色、竖段是描边,系统色下一个被抹掉、一个被换成文字色;
697
+ 两段都写 GrayText,并只让连接线不参与强制换色 */
635
698
  @media (forced-colors: active) {
636
- [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content']::before {
637
- background: GrayText;
699
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='item']::before,
700
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch'] > [data-scope='tree'][data-part='branch-control']::before {
701
+ border-color: GrayText;
702
+ background-image: linear-gradient(GrayText, GrayText);
703
+ forced-color-adjust: none;
704
+ }
705
+
706
+ [data-scope='tree'][data-part='tree'][data-lines] [data-scope='tree'][data-part='branch-content'][data-orientation='vertical'] > [data-scope='tree'][data-part='branch'] > [data-scope='tree'][data-part='branch-content']::after {
707
+ border-color: GrayText;
638
708
  forced-color-adjust: none;
639
709
  }
640
710
  }