Skip to content

(feat) Img component - #39214

Open
hestonhoffman wants to merge 16 commits into
jen.gilbert/astro-basefrom
heston/feat-img-component
Open

(feat) Img component#39214
hestonhoffman wants to merge 16 commits into
jen.gilbert/astro-basefrom
heston/feat-img-component

Conversation

@hestonhoffman

@hestonhoffman hestonhoffman commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Adds Img component with support for images and videos.

  • ImgVideo is a child of Img
  • Images use CDN links instead of loading from repo. Local dev + staging use the staging URL. Prod uses prod.
  • Added a lightbox to replicate behavior on Hugo.
  • Added a plaintext twin that renders an img tag with the prod src, caption, and alt text. For inline images, it drops the tag. I decided to just grab the prod source for the image here instead of rendering the path for each environment. I don't think we gain much from rendering the local path in local etc.
  • I removed image properties that appear to be dead in Hugo (href, target, wide, img_param, pop_param, figure_class, and figure_style).
  • I replaced the style prop with widthPercent and added a validation error that prevents writers from using widthPercent with height/width.

🟢 All tests pass
🟢 You can preview this using preview or dev now, since they use the same image URLs.

@hestonhoffman
hestonhoffman changed the base branch from master to jen.gilbert/astro-base August 14, 2026 23:39
@hestonhoffman hestonhoffman added the WORK IN PROGRESS No review needed, it's a wip ;) label Aug 14, 2026
@datadog-prod-us1-3

This comment has been minimized.

@hestonhoffman hestonhoffman changed the title Heston/feat img component (feat) Img component Aug 17, 2026
@hestonhoffman
hestonhoffman marked this pull request as ready for review August 17, 2026 18:00
@hestonhoffman
hestonhoffman requested a review from a team as a code owner August 17, 2026 18:00
@hestonhoffman hestonhoffman removed the WORK IN PROGRESS No review needed, it's a wip ;) label Aug 17, 2026
@estherk15 estherk15 self-assigned this Aug 17, 2026
Comment thread astro/src/components/Img/plaintext/Img.ts
Comment thread astro/src/components/Img/plaintext/tests/unit.test.ts
Comment thread astro/src/components/Img/plaintext/Img.ts Outdated
Comment thread astro/src/components/Img/ImgController.module.css Outdated
Comment thread astro/src/components/Img/ImgController.module.css Outdated
Comment thread astro/src/components/Img/ImgController.module.css Outdated
Comment thread astro/src/components/Img/Img.astro Outdated
Comment thread astro/src/components/Img/ImgController.tsx Outdated
hestonhoffman and others added 12 commits August 20, 2026 20:41
Pulls the width/height/widthPercent trio, previously duplicated across
Img.astro, ImgController, and ImgVideo, into a single SizingProps type
in imgTypes.ts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds --hugo-img-border-gray and --hugo-lightbox-spinner-track tokens
for the Img component's previously hardcoded border and spinner-track
colors, and reuses the existing --color-text-inverse token for the
lightbox caption text.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Lightbox now owns its trigger link and takes plain children, replacing
the render-prop API. This lets ImgController build the image once and
conditionally wrap it, removing the duplicated PopupImage call sites,
the redundant popup prop, and the no-op click handler.

Also drops --hugo-lightbox-spinner-active in favor of the existing
--color-text-inverse token.
The class had no CSS rule in any module, so cl() emitted a static class
with no hashed counterpart. Hugo's img shortcode renders a bare
figcaption too.
SizingProps was the only `extends` on a component prop type in the
codebase. Every other component (StepperController, CollapseContentController,
ApiSchemaTableNav, and the .astro components) declares its own flat prop
interface and shares only domain types such as HeadingLevel and SchemaField.

The inheritance also under-described the overlap: ImgControllerProps
extended SizingProps but hand-declared alt, caption, inline, and popup,
which come from ImgTagProps too. Reading the type suggested those fields
were unrelated to the tag props when they are forwarded unchanged.

ImgController and ImgVideo now declare their props flat, and PictureImage
gets a named PictureImageProps instead of an inline intersection. ImgTagProps
stays in imgTypes.ts as the one genuine cross-boundary contract, shared with
the plaintext twin.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The dropped-attribute list restated what the Pick already expresses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
const needsLightbox = !inline && popup;
---

{

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're back to a ternary here, but I felt it was necessary because it allowed me to conditionally hydrate the lightbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants