Make the hero Moon image configurable (src/alt), backwards-compatible #20
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/configurable-moon-image"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #5.
Problem
The Hero Editor's Moon element — a dedicated, first-class element core to the project's identity — always rendered a hardcoded image at
/assets/img/hero-moon.png. Onlysizeandglowwere configurable; the image itself could not be changed.Solution
Make only the Moon's image source configurable, without changing anything else about the element. The Moon remains its own element type (not replaced with a generic image element, not merged into another type). Adds optional
srcandaltprops alongside the existingsize/glow:Implementation details
Two files, no unrelated changes:
client/src/components/HeroElement.jsx— themoonrender case now usesprops.srcwhen present and falls back to the default/assets/img/hero-moon.pngwhen absent.altcomes fromprops.alt(default'', same as the previous hardcoded value). The size/glow/animation styling is byte-for-byte unchanged.client/src/routes/admin/views/HeroEditor.jsx(MoonPanel) — adds an image upload control, an alt text field, and a "Use default" reset, while keeping the size/glow sliders exactly as before. The upload reuses the existing shared admin upload workflow (api.admin.upload, the same call the Image and Background panels use) — no second upload path, no duplicated upload logic. A successful upload simply setsprops.src; "Use default" clears it back to the fallback.No new element type, no
newElementchange (a fresh Moon starts with nosrcand renders the default until an image is chosen).Backwards compatibility
Fully preserved, zero migration:
size/glowand nosrchit the fallback and render exactly as today.altdefaults to''— identical to the previous hardcodedalt="".hero_layout/hero_layout_draftvalues are read and written unchanged.Testing
npm run build(client) succeeds.src→<img src="/assets/img/hero-moon.png" alt="">(fallback, unchanged behavior).src→<img src="/assets/img/uomysticmoon-main-hero.png" alt="Custom Moon">(chosen image).MoonPanelreuses the already-provenapi.admin.uploadpath (same as the Image/Background panels); the build confirms the JSX compiles.Acceptance criteria
src) render identically to current behavior, no migrationsrcrender the chosen imageFollow-up: upload warning threshold
The editor showed a soft "over 1 MB may slow the page" confirm before uploads — a client-side nudge only (the server hard-limits at 8 MB), and 1 MB nagged on normal hero images. Raised to 5 MB and consolidated the threshold + message into a single
tooLargeToUpload()helper shared by the background, moon, and image upload paths.