1
1
<template >
2
- <div v-show =" show" :title =" item.name" >
3
- <!-- title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
4
- <div class =" item" :class =" [item.isFile ? 'filewrapper gt-p-1 gt-ac' : '', store.selectedItem === '#diff-' + item.file?.NameHash ? 'selected' : '']" >
5
- <!-- Files -->
6
- <SvgIcon
7
- v-if =" item.isFile"
8
- name =" octicon-file"
9
- class =" svg-icon file"
10
- />
11
- <a
12
- v-if =" item.isFile"
13
- :class =" ['file gt-ellipsis', {'viewed': item.file.IsViewed}]"
14
- :href =" item.isFile ? '#diff-' + item.file.NameHash : ''"
15
- >{{ item.name }}</a >
16
- <SvgIcon
17
- v-if =" item.isFile"
18
- :name =" getIconForDiffType(item.file.Type)"
19
- :class =" ['svg-icon', getIconForDiffType(item.file.Type), 'status']"
20
- />
2
+ <!-- title instead of tooltip above as the tooltip needs too much work with the current methods, i.e. not being loaded or staying open for "too long"-->
3
+ <a
4
+ v-if =" item.isFile" class =" item-file"
5
+ :class =" {'selected': store.selectedItem === '#diff-' + item.file.NameHash, 'viewed': item.file.IsViewed}"
6
+ :title =" item.name" :href =" '#diff-' + item.file.NameHash"
7
+ >
8
+ <!-- file -->
9
+ <SvgIcon name =" octicon-file" />
10
+ <span class =" gt-ellipsis gt-f1" >{{ item.name }}</span >
11
+ <SvgIcon :name =" getIconForDiffType(item.file.Type).name" :class =" getIconForDiffType(item.file.Type).classes" />
12
+ </a >
13
+ <div v-else class =" item-directory" :title =" item.name" @click.stop =" collapsed = !collapsed" >
14
+ <!-- directory -->
15
+ <SvgIcon :name =" collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'" />
16
+ <SvgIcon class =" text primary" name =" octicon-file-directory-fill" />
17
+ <span class =" gt-ellipsis" >{{ item.name }}</span >
18
+ </div >
21
19
22
- <!-- Directories -->
23
- <div v-if =" !item.isFile" class =" directory gt-p-1 gt-ac" @click.stop =" handleClick(item.isFile)" >
24
- <SvgIcon
25
- class =" svg-icon"
26
- :name =" collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"
27
- />
28
- <SvgIcon
29
- class =" svg-icon directory"
30
- name =" octicon-file-directory-fill"
31
- />
32
- <span class =" gt-ellipsis" >{{ item.name }}</span >
33
- </div >
34
- <div v-show =" !collapsed" >
35
- <DiffFileTreeItem v-for =" childItem in item.children" :key =" childItem.name" :item =" childItem" class =" list" />
36
- </div >
37
- </div >
20
+ <div v-if =" item.children?.length" v-show =" !collapsed" class =" sub-items" >
21
+ <DiffFileTreeItem v-for =" childItem in item.children" :key =" childItem.name" :item =" childItem" />
38
22
</div >
39
23
</template >
40
24
@@ -49,30 +33,19 @@ export default {
49
33
type: Object ,
50
34
required: true
51
35
},
52
- show: {
53
- type: Boolean ,
54
- required: false ,
55
- default: true
56
- },
57
36
},
58
37
data : () => ({
59
38
store: diffTreeStore (),
60
39
collapsed: false ,
61
40
}),
62
41
methods: {
63
- handleClick (itemIsFile ) {
64
- if (itemIsFile) {
65
- return ;
66
- }
67
- this .collapsed = ! this .collapsed ;
68
- },
69
42
getIconForDiffType (pType ) {
70
43
const diffTypes = {
71
- 1 : ' octicon-diff-added' ,
72
- 2 : ' octicon-diff-modified' ,
73
- 3 : ' octicon-diff-removed' ,
74
- 4 : ' octicon-diff-renamed' ,
75
- 5 : ' octicon-diff-modified ' , // there is no octicon for copied, so modified should be ok
44
+ 1 : {name : ' octicon-diff-added' , classes : [ ' text ' , ' green ' ]} ,
45
+ 2 : {name : ' octicon-diff-modified' , classes : [ ' text ' , ' yellow ' ]} ,
46
+ 3 : {name : ' octicon-diff-removed' , classes : [ ' text ' , ' red ' ]} ,
47
+ 4 : {name : ' octicon-diff-renamed' , classes : [ ' text ' , ' teal ' ]} ,
48
+ 5 : {name : ' octicon-diff-renamed ' , classes : [ ' text ' , ' green ' ]}, // there is no octicon for copied, so renamed should be ok
76
49
};
77
50
return diffTypes[pType];
78
51
},
@@ -81,75 +54,42 @@ export default {
81
54
</script >
82
55
83
56
<style scoped>
84
- .svg-icon.status {
85
- float : right ;
86
- }
87
-
88
- .svg-icon.file {
89
- color : var (--color-secondary-dark-7 );
90
- }
91
-
92
- .svg-icon.directory {
93
- color : var (--color-primary );
94
- }
95
-
96
- .svg-icon.octicon-diff-modified {
97
- color : var (--color-yellow );
98
- }
99
-
100
- .svg-icon.octicon-diff-added {
101
- color : var (--color-green );
102
- }
103
-
104
- .svg-icon.octicon-diff-removed {
105
- color : var (--color-red );
57
+ a , a :hover {
58
+ text-decoration : none ;
59
+ color : var (--color-text );
106
60
}
107
61
108
- .svg-icon.octicon-diff-renamed {
109
- color : var ( --color-teal ) ;
62
+ .sub-items {
63
+ padding-left : 9 px ;
110
64
}
111
65
112
- .item.filewrapper {
113
- display : grid !important ;
114
- grid-template-columns : 20px 7fr 1fr ;
115
- padding-left : 18px !important ;
66
+ .item-file {
67
+ margin-left : 20px ;
116
68
}
117
69
118
- .item.filewrapper :hover , div .directory :hover {
119
- color : var (--color-text );
120
- background : var (--color-hover );
121
- border-radius : 4px ;
122
- }
123
-
124
- .item.filewrapper.selected {
70
+ .item-file.selected {
125
71
color : var (--color-text );
126
72
background : var (--color-active );
127
73
border-radius : 4px ;
128
74
}
129
75
130
- div .directory {
131
- display : grid ;
132
- grid-template-columns : 18px 20px auto ;
133
- user-select : none ;
134
- cursor : pointer ;
135
- }
136
-
137
- div .list {
138
- padding-bottom : 0 !important ;
139
- padding-top : inherit !important ;
76
+ .item-file.viewed {
77
+ color : var (--color-text-light-3 );
140
78
}
141
79
142
- a {
143
- text-decoration : none ;
144
- color : var (--color-text );
80
+ .item-file ,
81
+ .item-directory {
82
+ display : flex ;
83
+ align-items : center ;
84
+ gap : 0.25em ;
85
+ padding : 2px ;
145
86
}
146
87
147
- a :hover {
148
- text-decoration : none ;
88
+ .item-file :hover ,
89
+ .item-directory :hover {
149
90
color : var (--color-text );
150
- }
151
-
152
- a .file.viewed {
153
- color : var (--color-text-light-3 );
91
+ background : var (--color-hover );
92
+ border-radius : 4px ;
93
+ cursor : pointer ;
154
94
}
155
95
</style >
0 commit comments