Skip to content

Commit

Permalink
Add progress bar for viewed files (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
caponetto authored Jan 21, 2023
1 parent 0b103b2 commit 379d216
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/extension/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const buildSkeleton = (webviewUri: vscode.Uri) => `
<div id="${SkeletonElementIds.DiffContainer}"></div>
<footer>
<span id="${SkeletonElementIds.ViewedIndicator}"></span>
<div id="${SkeletonElementIds.ViewedProgressContainer}">
<div id="${SkeletonElementIds.ViewedProgress}"></div>
</div>
<label id="${SkeletonElementIds.MarkAllViewedContainer}">
<input id="${SkeletonElementIds.MarkAllViewedCheckbox}" type="checkbox" name="mark-all-as-viewed">
Mark all as viewed
Expand Down
2 changes: 2 additions & 0 deletions src/shared/css/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ export enum SkeletonElementIds {
MarkAllViewedContainer = "mark-all-viewed-container",
MarkAllViewedCheckbox = "mark-all-viewed-checkbox",
ViewedIndicator = "viewed-indicator",
ViewedProgressContainer = "viewed-progress-container",
ViewedProgress = "viewed-progress",
}
20 changes: 18 additions & 2 deletions src/webview/css/static/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ body * {

body footer {
position: sticky;
bottom: 2px;
bottom: 0px;
padding: 6px 8px 4px 8px;
border-top: 1px solid #eee;
margin-top: auto;
display: flex;
flex-direction: row;
align-items: baseline;
align-items: center;
justify-content: flex-end;
background-color: white !important;
z-index: 1;
Expand All @@ -33,6 +33,22 @@ body footer {
margin-right: 8px;
}

#viewed-progress-container {
height: 12px;
width: 128px;
margin-right: 8px;
border-radius: 3px;
background: lightgray;
}

#viewed-progress {
height: 100%;
width: 0;
border-radius: 3px;
background: #1f6fea;
transition: width 0.4s ease;
}

#mark-all-viewed-container {
user-select: none;
display: flex;
Expand Down
6 changes: 6 additions & 0 deletions src/webview/message/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export class MessageToWebviewHandlerImpl implements MessageToWebviewHandler {
const viewedCount = this.getViewedCount();
indicator.textContent = `${viewedCount} / ${allCount} files viewed`;

const viewedProgressBar = document.getElementById(SkeletonElementIds.ViewedProgress);
if (viewedProgressBar) {
const progressPercentage = Math.round((viewedCount / allCount) * 100);
viewedProgressBar.style.width = `${progressPercentage}%`;
}

const markAllViewedCheckbox = document.getElementById(SkeletonElementIds.MarkAllViewedCheckbox) as HTMLInputElement;
if (!markAllViewedCheckbox) {
return;
Expand Down

0 comments on commit 379d216

Please sign in to comment.