Skip to content

Commit f0d27ea

Browse files
authored
Merge pull request #11 from hansu/4-adjust-column-width-also-when-the-table-header-is-not-displayed
4 adjust column width also when the table header is not displayed
2 parents 12e0336 + cfd6817 commit f0d27ea

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

src/gitGraphView.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ export class GitGraphView extends Disposable {
736736
<div id="commitTable"></div>
737737
</div>
738738
<div id="footer"></div>
739-
<div id="scrollShadow"></div>
740739
</div>
741740
<script nonce="${nonce}">var initialState = ${JSON.stringify(initialState)}, globalState = ${JSON.stringify(globalState)}, workspaceState = ${JSON.stringify(workspaceState)};</script>
742741
<script nonce="${nonce}" src="${this.getMediaUri('out.min.js')}"></script>

web/main.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class GitGraphView {
5656
private readonly footerElem: HTMLElement;
5757
private readonly showRemoteBranchesElem: HTMLInputElement;
5858
private readonly refreshBtnElem: HTMLElement;
59-
private readonly scrollShadowElem: HTMLElement;
6059

6160
constructor(viewElem: HTMLElement, prevState: WebViewState | null) {
6261
this.gitRepos = initialState.repos;
@@ -78,7 +77,6 @@ class GitGraphView {
7877
this.tableElem = document.getElementById('commitTable')!;
7978
this.tableColHeadersElem = document.getElementById('tableColHeaders')!;
8079
this.footerElem = document.getElementById('footer')!;
81-
this.scrollShadowElem = <HTMLInputElement>document.getElementById('scrollShadow')!;
8280

8381
viewElem.focus();
8482

@@ -855,8 +853,7 @@ class GitGraphView {
855853
markdown: this.config.markdown
856854
});
857855

858-
const stickyClassAttr = this.config.stickyHeader ? ' class="sticky"' : '';
859-
let html = '<tr id="tableColHeaders"' + stickyClassAttr + '><th id="tableHeaderGraphCol" class="tableColHeader" data-col="0">Graph</th><th class="tableColHeader" data-col="1">Description</th>' +
856+
let html = '<tr id="tableColHeaders"><th id="tableHeaderGraphCol" class="tableColHeader" data-col="0">Graph</th><th class="tableColHeader" data-col="1">Description</th>' +
860857
(colVisibility.date ? '<th class="tableColHeader dateCol" data-col="2">Date</th>' : '') +
861858
(colVisibility.author ? '<th class="tableColHeader authorCol" data-col="3">Author</th>' : '') +
862859
(colVisibility.commit ? '<th class="tableColHeader" data-col="4">Commit</th>' : '') +
@@ -904,11 +901,16 @@ class GitGraphView {
904901
: '';
905902

906903
html += '<tr class="commit' + (commit.hash === currentHash ? ' current' : '') + (mutedCommits[i] ? ' mute' : '') + '"' + (commit.hash !== UNCOMMITTED ? '' : ' id="uncommittedChanges"') + ' data-id="' + i + '" data-color="' + vertexColours[i] + '">' +
907-
(this.config.referenceLabels.branchLabelsAlignedToGraph ? '<td>' + (refBranches !== '' ? '<span style="margin-left:' + (widthsAtVertices[i] - 4) + 'px"' + refBranches.substring(5) : '') + '</td><td><span class="description">' + commitDot : '<td></td><td><span class="description">' + commitDot + refBranches) + (this.config.referenceLabels.tagLabelsOnRight ? message + refTags : refTags + message) + '</span></td>' +
908-
(colVisibility.date ? '<td class="dateCol text" title="' + date.title + '">' + date.formatted + '</td>' : '') +
909-
(colVisibility.author ? '<td class="authorCol text" title="' + escapeHtml(commit.author + ' <' + commit.email + '>') + '">' + (this.config.fetchAvatars ? '<span class="avatar" data-email="' + escapeHtml(commit.email) + '">' + (typeof this.avatars[commit.email] === 'string' ? '<img class="avatarImg" src="' + this.avatars[commit.email] + '">' : '') + '</span>' : '') + escapeHtml(commit.author) + '</td>' : '') +
910-
(colVisibility.commit ? '<td class="text" title="' + escapeHtml(commit.hash) + '">' + abbrevCommit(commit.hash) + '</td>' : '') +
904+
(this.config.referenceLabels.branchLabelsAlignedToGraph ? '<td>' + getResizeColHtml(0) + (refBranches !== '' ? '<span style="margin-left:' + (widthsAtVertices[i] - 4) + 'px"' + refBranches.substring(5) : '') + '</td><td>' + getResizeColHtml(1) + '<span class="description">' + commitDot : '<td>' + getResizeColHtml(0) + '</td><td>' + getResizeColHtml(1) + '<span class="description">' + commitDot + refBranches) + (this.config.referenceLabels.tagLabelsOnRight ? message + refTags : refTags + message) + '</span></td>' +
905+
(colVisibility.date ? '<td class="dateCol text" title="' + date.title + '">' + getResizeColHtml(2) + date.formatted + '</td>' : '') +
906+
(colVisibility.author ? '<td class="authorCol text" title="' + escapeHtml(commit.author + ' <' + commit.email + '>') + '">' + getResizeColHtml(3) + (this.config.fetchAvatars ? '<span class="avatar" data-email="' + escapeHtml(commit.email) + '">' + (typeof this.avatars[commit.email] === 'string' ? '<img class="avatarImg" src="' + this.avatars[commit.email] + '">' : '') + '</span>' : '') + escapeHtml(commit.author) + '</td>' : '') +
907+
(colVisibility.commit ? '<td class="text" title="' + escapeHtml(commit.hash) + '">' + getResizeColHtml(4) + abbrevCommit(commit.hash) + '</td>' : '') +
911908
'</tr>';
909+
910+
911+
}
912+
function getResizeColHtml(col:number) {
913+
return (col > 0 ? '<span class="resizeCol left" data-col="' + (col - 1) + '"></span>' : '') + (col < 4 ? '<span class="resizeCol right" data-col="' + col + '"></span>' : '');
912914
}
913915
this.tableElem.innerHTML = '<table>' + html + '</table>';
914916
this.footerElem.innerHTML = this.moreCommitsAvailable ? '<div id="loadMoreCommitsBtn" class="roundedBtn">Load More Commits</div>' : '';
@@ -1987,16 +1989,6 @@ class GitGraphView {
19871989
if (!this.tableColHeadersElem) {
19881990
return;
19891991
}
1990-
1991-
const controlsHeight = this.controlsElem.offsetHeight;
1992-
const controlsWidth = this.controlsElem.offsetWidth;
1993-
const tableColHeadersHeight = this.tableColHeadersElem.offsetHeight;
1994-
const bottomBorderWidth = 1;
1995-
const shadowYPos = controlsHeight + tableColHeadersHeight + bottomBorderWidth;
1996-
1997-
this.tableColHeadersElem.style.top = `${controlsHeight}px`;
1998-
this.scrollShadowElem.style.top = `${shadowYPos}px`;
1999-
this.scrollShadowElem.style.width = `${controlsWidth}px`;
20001992
}
20011993

20021994

@@ -2064,12 +2056,10 @@ class GitGraphView {
20642056

20652057
private observeViewScroll() {
20662058
let active = this.viewElem.scrollTop > 0, timeout: NodeJS.Timer | null = null;
2067-
this.scrollShadowElem.className = active ? CLASS_ACTIVE : '';
20682059
this.viewElem.addEventListener('scroll', () => {
20692060
const scrollTop = this.viewElem.scrollTop;
20702061
if (active !== scrollTop > 0) {
20712062
active = scrollTop > 0;
2072-
this.scrollShadowElem.className = active ? CLASS_ACTIVE : '';
20732063
}
20742064

20752065
if (this.config.loadMoreCommitsAutomatically && this.moreCommitsAvailable && !this.currentRepoRefreshState.inProgress) {

web/styles/main.css

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ code{
6969
cursor:col-resize;
7070
}
7171

72-
#scrollShadow.active{
73-
position:fixed;
74-
top:0;
75-
left:0;
76-
right:0;
77-
height:6px;
78-
box-shadow: inset 0 6px 6px -6px var(--vscode-scrollbar-shadow);
79-
z-index:11;
80-
pointer-events:none;
81-
}
82-
83-
8472
/* Commit Graph */
8573

8674
#commitGraph{
@@ -295,12 +283,22 @@ code{
295283
}
296284
.resizeCol.left{
297285
left:0;
298-
border-left:1px solid rgba(128,128,128,0.25);
299286
}
300287
.resizeCol.right{
301288
right:0;
302289
}
303290

291+
table { border-collapse: collapse; }
292+
.commit>td, #tableColHeaders>th {
293+
border-right: solid 1px rgba(128,128,128,0.25);
294+
}
295+
.commit>td{
296+
position:relative;
297+
}
298+
#tableColHeaders>th:last-child, .commit>td:last-child {
299+
border-right: none;
300+
}
301+
304302

305303
/* Commit Details View */
306304

0 commit comments

Comments
 (0)