WS-2635 [SPIKE] Understand technical approach for switching onward journey layouts by referrer on article pages#14131
Draft
LilyL0u wants to merge 7 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves JIRA: https://bbc.atlassian.net/browse/WS-2635
Implements reordering of OJ components based on user referrer type, only on mobile (as this will be difficult on desktop with the secondary column). Desktop layout stays how it was before. There is a centralised config which is used to store the order we want for each referrer. This can easily be changed when we want so is good for flexibility.
Config-Driven Architecture:
mobileReferrerComponentOrder.ts — Centralised config
Defines three referrer types: 'direct', 'search', 'social'
Maps each to a component order (7 reorderable components)
useMobileReferrerOrder.ts — React hook
SSR-safe (checks onClient() before accessing window)
Detects mobile via window.matchMedia((max-width: 62.9375rem))
Reads referrer with fallback to 'direct'
Supports debug mode via ?debugReferrer=search URL param for manual testing
Returns OJComponentKey[] on mobile, null on desktop
[ArticlePage.tsx]
Imports hook and component order type
Calls useMobileReferrerOrder() to get mobile order (or null on desktop)
Creates component map: mobileOJComponents with all 7 reorderable OJ components
Desktop rendering: {!mobileOJOrder && ...} gates show original components in original positions
Mobile rendering: {mobileOJOrder && ...} renders reordered components in referrer-specific order
Uses Fragment in map loop to avoid wrapper divs (mobile performance)
[ArticlePage.styles.ts]
Adds mobileOJContainer style with display: 'none' on desktop (GROUP_4_MIN_WIDTH)
Direct | mostRead → topicDiscovery → relatedContent → pvCarousel → featuredArticles → topStories → locationBasedOJ
Search | relatedContent → topicDiscovery → mostRead → pvCarousel → topStories → featuredArticles → locationBasedOJ
Social | mostRead → topicDiscovery → topStories → featuredArticles → relatedContent → locationBasedOJ → pvCarousel
This order can be changed. It was based off the document https://www.dropbox.com/scl/fi/w9oy1xb27cmlv437910ki/Experiment-Brief-v2-reorder-OJs-based-on-referrer.paper?rlkey=rf0brkjaa846lwal7d79stetr&dl=0 with a few assumptions, but the specifics don't matter for the spike.
No-CSS Fallback:
Inline style display: mobileOJOrder ? 'block' : 'none' ensures correct visibility even if CSS fails to load, while Emotion CSS handles media query logic in normal operation.
No-JavaScript Fallback:
Hook's onClient() check prevents errors on server. Returns null, triggering desktop layout rendering.
Manual Testing
Use the debug URL parameter to test different referrer orders without visiting from actual search/social:
e.g http://localhost:7081/mundo/articles/c0myz4m74lwo?renderer_env=live&debugReferrer=social
Omit the param or visit normally to use actual referrer.
Summary
A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.
Code changes
Testing
Useful Links