Skip to content

Commit 3a912c2

Browse files
committed
feat: highlight control.
1 parent 8745092 commit 3a912c2

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

src/components/Tree/index.vue

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<template>
22
<div
3-
:class="{
4-
'vjs-tree': true,
5-
'is-mouseover': isMouseover,
6-
'has-selectable-control': showSelectController
7-
}"
8-
@mouseover.stop="handleMouseover"
9-
@mouseout.stop="handleMouseout"
3+
class="vjs-tree"
104
>
115
<tree-node
126
v-for="(item) in flatData"
@@ -98,11 +92,6 @@
9892
type: Function,
9993
default: () => true
10094
},
101-
// highlight current node when mouseover
102-
highlightMouseoverNode: {
103-
type: Boolean,
104-
default: false
105-
},
10695
// highlight current node when checked
10796
highlightSelectedNode: {
10897
type: Boolean,
@@ -121,7 +110,6 @@
121110
},
122111
data () {
123112
return {
124-
isMouseover: false,
125113
hiddenPaths: jsonFlatten(this.data, this.path).reduce((acc, item) => {
126114
if ((item.type === 'objectStart' || item.type === 'arrayStart') && item.level === this.deep) {
127115
return {
@@ -217,15 +205,6 @@
217205
this.$emit('click', path, content)
218206
},
219207
220-
handleMouseover () {
221-
// 可选择的树|普通展示树, 都支持mouseover
222-
this.highlightMouseoverNode && (this.isMouseover = true)
223-
},
224-
225-
handleMouseout () {
226-
this.highlightMouseoverNode && (this.isMouseover = false)
227-
},
228-
229208
onBracketsClick (collapsed, path) {
230209
if (collapsed) {
231210
this.hiddenPaths = {

src/components/Tree/styles.less

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,4 @@
33
.@{css-prefix}-tree {
44
font-family: "Monaco", "Menlo", "Consolas", "Bitstream Vera Sans Mono", monospace;
55
font-size: 14px;
6-
7-
&.has-selectable-control {
8-
margin-left: @selectabl-span;
9-
}
10-
11-
&.is-mouseover {
12-
background-color: @highlight-bg-color;
13-
}
14-
15-
&.is-highlight-selected {
16-
background-color: darken(@highlight-bg-color, 5%);
17-
}
186
}

src/components/TreeNode/index.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22
<div
3-
class="vjs-tree__node"
3+
:class="{
4+
'vjs-tree__node': true,
5+
'is-highlight': highlightSelectedNode && checked
6+
}"
47
@click="onTreeNodeClick"
58
>
69
<template v-if="showSelectController && selectable && node.type !== 'objectEnd' && node.type !== 'arrayEnd'">
@@ -103,11 +106,6 @@
103106
type: Function,
104107
default: () => true
105108
},
106-
// highlight current node when mouseover
107-
highlightMouseoverNode: {
108-
type: Boolean,
109-
default: false
110-
},
111109
// highlight current node when checked
112110
highlightSelectedNode: {
113111
type: Boolean,

src/components/TreeNode/styles.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
display: flex;
99
position: relative;
1010

11+
&.is-highlight,
12+
&:hover {
13+
background-color: @highlight-bg-color;
14+
}
15+
1116
.@{css-prefix}-tree__indent {
1217
flex: 0 0 1em;
1318

0 commit comments

Comments
 (0)