diff --git a/public/js/image_selector.js b/public/js/image_selector.js index 6a8dfb5c..a07aedbb 100644 --- a/public/js/image_selector.js +++ b/public/js/image_selector.js @@ -1,4 +1,7 @@ -function ImageSelector(form, maxFileSize, container, defaultImageUrl) { +function ImageSelector(form, maxFileSize, container, { + defaultImageUrl = "", + onUpdate = (url) => {}, +} = {}) { this.form = form; this.maxFileSize = maxFileSize; this.fileInput = container.querySelector(".imginput"); @@ -11,12 +14,13 @@ function ImageSelector(form, maxFileSize, container, defaultImageUrl) { this.originalImageUrl = this.imageEl.getAttribute("data-imginput-original"); this.originalImageFilename = this.imageEl.getAttribute("data-imginput-original-filename"); this.currentImageUrl = this.originalImageUrl; - this.defaultImageUrl = defaultImageUrl || ""; + this.defaultImageUrl = defaultImageUrl; + this.onUpdate = onUpdate; this.fileInput.value = ""; this.removeImageInput.value = ""; - this.setImageUrl(this.originalImageUrl); + this.setImageUrl(this.originalImageUrl, true); this.updatePreview(); this.fileInput.addEventListener("change", function(ev) { @@ -79,7 +83,7 @@ ImageSelector.prototype.setError = function(error) { this.fileInput.reportValidity(); } -ImageSelector.prototype.setImageUrl = function(url) { +ImageSelector.prototype.setImageUrl = function(url, initial = false) { this.currentImageUrl = url; this.imageEl.src = url; if (url.length > 0) { @@ -87,6 +91,10 @@ ImageSelector.prototype.setImageUrl = function(url) { } else { this.imageEl.style.display = "none"; } + this.url = url; + if (!initial) { + this.onUpdate(url); + } }; ImageSelector.prototype.updatePreview = function(file) { diff --git a/public/style.css b/public/style.css index d64546ad..d5633d21 100644 --- a/public/style.css +++ b/public/style.css @@ -8501,6 +8501,17 @@ span.icon-rss::before { content: "\200b"; padding: var(--spacing-2) 0; } +.project-homepage-card { + width: 100%; + max-width: var(--site-width-narrow); + padding: var(--spacing-3); + background-color: var(--c-transparent-background); + --link-color: var(--color); + display: flex; + gap: var(--spacing-3); + overflow: hidden; + margin-top: -4rem; +} /* src/rawdata/scss/showcase.css */ .showcase-item .gradient { diff --git a/src/rawdata/scss/projects.css b/src/rawdata/scss/projects.css index 97fa5831..bf0e5e74 100644 --- a/src/rawdata/scss/projects.css +++ b/src/rawdata/scss/projects.css @@ -94,4 +94,17 @@ content: '\200b'; padding: var(--spacing-2) 0; } +} + +.project-homepage-card { + width: 100%; + max-width: var(--site-width-narrow); + padding: var(--spacing-3); + background-color: var(--c-transparent-background); + --link-color: var(--color); + display: flex; + gap: var(--spacing-3); + overflow: hidden; + + margin-top: -4rem; } \ No newline at end of file diff --git a/src/templates/src/include/image_selector.html b/src/templates/src/include/image_selector.html index 48ca53c4..84bbd2a4 100644 --- a/src/templates/src/include/image_selector.html +++ b/src/templates/src/include/image_selector.html @@ -7,7 +7,7 @@ {{ $filename := or (and .Asset .Asset.Filename) "" }}