Extracted some pages to their own assembly and finished the artifact display page code

This commit is contained in:
Vincent Allen
2025-10-08 13:08:12 -04:00
parent fd0e6290fe
commit 02c2660b09
626 changed files with 39989 additions and 1553 deletions

View File

@@ -0,0 +1,12 @@
function downloadFileFromBytes(fileName, mimeType, bytesBase64) {
const link = document.createElement('a');
link.href = `data:${mimeType};base64,${bytesBase64}`;
link.download = fileName;
// This is required for Firefox
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}

View File

@@ -0,0 +1,48 @@
function centerImageAndGetHeight(containerElement) {
const imageElement = containerElement.querySelector('img');
return new Promise((resolve, reject) => {
if (!imageElement) {
return reject("Image element not found.");
}
const successHandler = () => {
// Find the carousel's main element
const carouselViewport = imageElement.closest('.mud-carousel');
if (!carouselViewport) {
// Failsafe if not in a carousel, just return height
resolve(imageElement.clientHeight);
return;
}
// Get the displayed widths
const parentWidth = carouselViewport.clientWidth;
const imageWidth = imageElement.clientWidth;
// Calculate the padding needed to center the image
const paddingLeft = Math.max(0, (parentWidth - imageWidth) / 2);
// Apply the padding directly to the image
imageElement.style.paddingLeft = `${paddingLeft}px`;
// Resolve with the measured height for the parent component
resolve(imageElement.clientHeight);
removeListeners();
};
const errorHandler = () => reject("Could not load image.");
const removeListeners = () => {
imageElement.removeEventListener("load", successHandler);
imageElement.removeEventListener("error", errorHandler);
};
// If the image is already loaded (from cache), trigger the handler manually
if (imageElement.complete && imageElement.naturalHeight > 0) {
successHandler();
} else {
imageElement.addEventListener("load", successHandler);
imageElement.addEventListener("error", errorHandler);
}
});
}