Skip to content

Commit

Permalink
feat: add a loading animation to the osv iframe (#1661)
Browse files Browse the repository at this point in the history
Added a spinner indicating iframe is loading. Fixes #1524 


https://github.com/user-attachments/assets/b690e802-33ed-4f10-9f1e-389e132b1df0

Signed-off-by: Weizhou Ren <willzhou0305@gmail.com>
  • Loading branch information
WeizhouRen authored Feb 25, 2025
1 parent 91f56a9 commit ad06fee
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
8 changes: 8 additions & 0 deletions internal/output/html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ function openVulnInNewTab(inputString) {
newTab.id = inputString; // Set the ID to the input string
newTab.className = "tab osv-tab"; // Set the class name

// Create a spinner indicating loading status
const spinner = document.createElement("div");
spinner.className = "iframe-spinner";

// Create the iframe element.
const iframe = document.createElement("iframe");
iframe.src = osvURL;
iframe.onload = () => {
newTab.removeChild(spinner);
};

// Create a new tab button
const newTabButton = document.createElement("div");
Expand Down Expand Up @@ -93,6 +100,7 @@ function openVulnInNewTab(inputString) {
newTabButton.appendChild(closeIcon);

// Add the iframe to the new tab div.
newTab.appendChild(spinner);
newTab.appendChild(iframe);
// Add the iframe to the container.
tabs.appendChild(newTab);
Expand Down
28 changes: 27 additions & 1 deletion internal/output/html/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,28 @@ header {
color: #fff;
}

.osv-tab {
position: relative;
}

.osv-tab iframe {
width: 100%;
min-height: 1000px;
border: none;
background-color: #000;
}

.iframe-spinner {
position: absolute;
inset: 0;
margin: auto;
width: 48px;
height: 48px;
border: 5px solid #fff;
border-bottom-color: transparent;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}

#vuln-tab {
Expand Down Expand Up @@ -631,3 +648,12 @@ div.title {
#license-summary-details {
margin-left: 30px;
}

@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

0 comments on commit ad06fee

Please sign in to comment.