infogo-tree
Version:
A vue tree component using virtual list.
421 lines (358 loc) • 8.39 kB
text/less
#ctree-tree-styles () {
// prefix
@tree-prefix: ~"@{ctree-prefix}-tree";
@tree-node-prefix: ~"@{tree-prefix}-node";
// Tree
.@{tree-prefix} {
// 覆盖整个树并且垂直居中
.wrap-tree () {
width: 100%;
height: 100%;
display: flex;
align-items: center;
position: absolute;
top: 0;
left: 0;
}
// 容器
&__wrapper {
width: 100%;
height: 100%;
position: relative;
&.noChild {
.ctree-tree-node__node-body {
.ctree-tree-node__square:first-of-type {
display: none;
}
}
}
}
// 滚动区域
&__scroll-area {
width: 100%;
height: 100%;
overflow: auto;
position: relative;
display: flex;
padding: 0 16px;
box-sizing: border-box;
&::-webkit-scrollbar-button {
background-color: #f1f1f2;
border-radius: 6px;
}
&::-webkit-scrollbar-track {
background-color: #f1f1f2;
}
&::-webkit-scrollbar-thumb:hover {
// height: 50px;
border-radius: 6px;
}
&::-webkit-scrollbar-thumb {
// background-color: #d8d9dd !important;
background-color: #C2C2C2 ;
border-radius: 6px;
&:hover {
background-color: #7D7D7D ;
}
}
/*---滚动条大小--*/
&::-webkit-scrollbar {
width: 8px ;
height: 8px ;
}
/*---滚动框背景样式--*/
&::-webkit-scrollbar-track-piece {
border-radius: 0;
}
}
// 数据块区域
&__block-area {
flex: 1;
}
// 暂无数据
&__empty {
.wrap-tree();
&-text_default {
// 水平居中
width: 100%;
text-align: center;
color: @ctree-color-input-placeholder;
}
}
// 加载中
&__loading {
.wrap-tree();
background-color: rgba(255, 255, 255, .95);
&-wrapper {
width: 100%;
text-align: center;
}
&-icon {
#ctree-loading-icon-styles();
}
}
// iframe
&__iframe {
.wrap-tree();
display: block;
border: none;
padding: 0px;
margin: 0px;
opacity: 0;
z-index: -1000;
pointer-events: none;
}
}
// Node
.@{tree-node-prefix} {
@base-square-length: 20px;
// 容器
&__wrapper {
display: flex;
flex-direction: column;
position: relative;
&.isNode {
.ctree-tree-node__node-body {
&::after {
height: 20px;
top: 18px;
left: -12px;
width: 12px;
}
}
}
&.firstLevelNode {
.ctree-tree-node__node-body {
&::before {
display: none;
}
&::after {
display: none;
}
}
}
}
// 拖拽区域
&__drop {
width: 100%;
height: 1px;
&_active {
background-color: @ctree-color-light-primary;
}
}
// 节点本体
&__node-body {
flex: 1;
display: flex;
align-items: center;
&::before {
content: "";
position: absolute;
right: auto;
border-width: 1px;
border-left: 1px dashed #b8b9bb;
bottom: 0;
height: 100%;
top: -19px;
left: -11px;
width: 1px;
}
&::after {
content: "";
position: absolute;
right: auto;
border-width: 1px;
border-top: 1px dashed #b8b9bb;
height: 20px;
top: 18px;
left: -12px;
width: 24px;
}
}
// 占位
&__square {
position: relative;
width: @base-square-length;
height: @base-square-length;
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
}
// 展开 icon
&__expand {
@icon-border-width: 5px;
// 展开图标可点击区域大小
@icon-clickable-size: 16px;
&::after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
border: @icon-border-width solid transparent;
border-left: @icon-border-width solid @ctree-color-content;
}
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
width: @icon-clickable-size;
height: @icon-clickable-size;
position: relative;
transition: transform .2s linear;
// 展开状态,顺时针旋转 90 度
&_active {
transform: rotate(90deg);
}
}
// Loading icon
&__loading-icon {
#ctree-loading-icon-styles(14px, @ctree-color-content);
}
// 复选框
&__checkbox {
@checkbox-size: 16px;
.active-color () {
border-color: @ctree-color-primary;
background-color: @ctree-color-primary;
}
box-sizing: border-box;
cursor: pointer;
width: @checkbox-size;
height: @checkbox-size;
position: absolute;
border: 1px solid;
border-color: @ctree-color-border;
border-radius: 2px;
background-color: #fff;
transition: border-color .2s ease-in-out,
background-color .2s ease-in-out,
box-shadow .2s ease-in-out;
&::after {
content: "";
display: table;
position: absolute;
box-sizing: border-box;
border: 1px solid #fff;
border-top: 0;
border-left: 0;
width: 4px;
height: 8px;
top: 2px;
left: 5px;
transform: rotate(45deg) scale(0);
transition: all .2s ease-in-out;
}
&:hover {
border-color: @ctree-color-border-disabled;
}
&:focus {
box-shadow: 0 0 0 2px @ctree-color-light-primary;
}
&_checked {
.active-color();
&::after {
width: 4px;
height: 8px;
top: 2px;
left: 5px;
transform: rotate(45deg) scale(1);
}
&:hover {
.active-color();
}
}
&_indeterminate {
.active-color();
&::after {
width: 8px;
height: 1px;
top: 6px;
left: 3px;
transform: scale(1);
}
&:hover {
.active-color();
}
}
&_disabled {
cursor: not-allowed;
background-color: #ededf1;
border-color: #d9dae0;
&:hover {
background-color: #ededf1;
border-color: #d9dae0;
}
&::after {
border-color: @ctree-color-content;
}
}
}
// 标题
&__title {
@title-height: @base-square-length + 6px;
@title-margin-left: 2px;
@title-padding-left: 5px;
color: @ctree-color-title;
cursor: pointer;
user-select: none;
display: inline-block;
// flex: 1;
// height: 36px;
// line-height: 36px;
margin-left: @title-margin-left;
padding-left: @title-padding-left;
background-color: transparent;
word-break: keep-all;
white-space: nowrap;
word-wrap: none;
&.ctree-tree-node__selected {
margin-left: 0;
padding-left: 0;
&.ctree-tree-node__title_disabled {
color: @ctree-color-disabled;
}
}
.custom-tree-node {
margin: 0;
}
&:hover:not(.ctree-tree-node__title_disabled) {
// background-color: lighten(@ctree-color-light-primary, 28%);
color: @ctree-color-primary;
}
&_selected {
.selected () {
// background-color: lighten(@ctree-color-primary, 35%);
color: @ctree-color-primary;
}
.selected();
&:hover {
.selected();
}
}
&_disabled {
cursor: not-allowed;
// color: @ctree-color-border-disabled;
}
}
}
.tree-drop_template {
.ctree-tree-node__wrapper.isNode {
.ctree-tree-node__node-body::after {
top: 14px;
left: -10px;
}
}
.ctree-tree-node__node-body {
&::after {
top: 14px;
left: -10px;
}
&::before {
top: -17px;
}
}
}
}
#ctree-tree-styles();