Skip to content

Consolidate MessageBanner srcset logic and document image migration plan - #14352

Draft
vdeksne wants to merge 5 commits into
bbc:latestfrom
vdeksne:WS-63-image-shared-utility-poc
Draft

Consolidate MessageBanner srcset logic and document image migration plan#14352
vdeksne wants to merge 5 commits into
bbc:latestfrom
vdeksne:WS-63-image-shared-utility-poc

Conversation

@vdeksne

@vdeksne vdeksne commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Resolves JIRA: WS-63

Summary

This is a proof-of-concept step from the WS-63 image-component spike.

The audit confirms that StoryPromo and Promo.Image already use the modern
Image
primitive. The remaining opportunity is to consolidate the duplicated logic
that prepares image URLs, srcSet, MIME types, fallback source sets, and
responsive sizes before rendering that primitive.

As a low-risk first step, MessageBanner now reuses the existing
getSrcSets
utility rather than constructing responsive image attributes locally. This does
not change the rendered image behaviour.

The migration plan below records the audit findings, proposed target
architecture, risks, and incremental follow-up work.

Image Component Consolidation Plan

Current Architecture

1

Target Architecture

2

Proposed Delivery Order

3
  • Audit — completed and documented in
    Image-Component-Migration-Plan.mdx.
  • Define the shared API — agree responsibilities and inputs for image-preparation utilities.
  • Consolidate shared utilities — reduce duplicated iChef URL, source-set, MIME-type, and fallback logic.
  • Migrate MessageBanner — completed; it now uses getSrcSets.
  • Migrate Billboard and MaskedImage — preserve their layout and loading behaviour.
  • Review legacy dependencies — assess direct Psammead image and placeholder usage after CAF cleanup.
  • Remove unused code — only after a repository-wide usage check.
  • Investigate Next.js Image — assess iChef, responsive source-set, fallback, and AMP compatibility.

Code changes

Testing

  1. Ran npx jest src/app/components/MessageBanner/index.test.tsx.
  2. Confirmed all 11 MessageBanner unit tests pass.
  3. Confirmed the refactor preserves the existing MessageBanner image source,
    srcSet, and sizes values.

Useful Links

Copilot AI lite review requested due to automatic review settings August 31, 2026 08:05
@vdeksne
vdeksne marked this pull request as draft August 31, 2026 08:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR is a small step in the WS-63 image-component spike: it removes duplicated srcset/sizes construction from MessageBanner by reusing the existing getSrcSets utility, and adds a migration-plan document to guide follow-up consolidation work across other image consumers.

Changes:

  • Switched MessageBanner to use #app/utilities/getSrcSets instead of locally rebuilding srcSet/sizes.
  • Added a new MDX document auditing current duplication and proposing a staged migration order toward a shared image-data API.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/app/components/MessageBanner/index.tsx Replaces inline srcset/sizes math with the shared getSrcSets utility.
docs/Image-Component-Migration-Plan.mdx Documents current image-prep duplication and an incremental migration plan.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +40 to +45
const imageSrcSets = getSrcSets({
imageUrlTemplate: image,
mq,
imageWidthSmall: styles.IMAGE_WIDTH,
imageWidthLarge: styles.IMAGE_WIDTH_GROUP_3_MIN_WIDTH,
});
@vdeksne vdeksne self-assigned this Aug 31, 2026
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.

2 participants