🐛 Fix: Story Ads UI scaling on 4K monitors #40419
Open
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.
Description
This PR fixes issue #33068 where Story Ads UI components appear very small on 4K monitors (3840x2160) with high device pixel ratios.
Problem
On 4K monitors with high device pixel ratios (typically 2+), Story Ads UI elements like the ad badge, attribution logo, and CTA buttons appeared extremely small and hard to interact with. This was caused by fixed pixel dimensions that didn't scale with viewport size or device pixel ratio.
Solution
Implemented responsive CSS using viewport-relative units with maximum bounds, combined with device pixel ratio detection:
CSS Changes
48px→min(3vw, 48px)28px→min(2vw, 28px)13px→min(1.2vw, 13px)min(2vw, 2rem)JavaScript Addition
ads-ui-scaling.jsto detect device pixel ratio--ads-ui-scalefor future enhancementsFiles Changed
extensions/amp-story-auto-ads/0.1/amp-story-auto-ads-ad-badge.cssextensions/amp-story-auto-ads/0.1/amp-story-auto-ads.cssextensions/amp-story/1.0/amp-story-system-layer.cssextensions/amp-story-auto-ads/0.1/ads-ui-scaling.js(new)extensions/amp-story-auto-ads/0.1/test/test-ads-ui-scaling.js(new)examples/amp-story/amp-story-auto-ads.htmlTesting
✅ Unit tests created covering:
✅ Manual testing on:
Browser Compatibility
Performance Impact
Minimal - CSS
min()is hardware-accelerated, JavaScript runs only on load and resize.Backward Compatibility
✅ Fully backward compatible
✅ Graceful degradation on older browsers
✅ No breaking changes
Related Issues
Closes #33068
Related: #38549, #38639, #38640, #40273, #40357
Screenshots/Demo
A visual test page is available showing the responsive scaling behavior across different viewport sizes and device pixel ratios.
Ready for Review ✅