Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition switcher banner #11763

Merged
merged 15 commits into from
Jul 10, 2024
Merged

Conversation

domlander
Copy link
Contributor

@domlander domlander commented Jun 28, 2024

Closes #11671

What does this change?

Displays a banner which allows users to switch to their preferred or default network front. It is only displayed when the user is viewing any other network front.

The banner is sticky to the top of the page as the user scrolls and can be dismissed by clicking the X button.

A user can indicate a preference for an edition by using the dropdown in the top-right on desktop pages and selecting their preferred edition. This stores a cookie GU_EDITION that remembers their edition preference. If the user hasn't indicated a preference for an edition, their default edition will be decided in Fastly by their geolocation, which is likely to be the edition that is most relevant to them.

For example, a user that has selected the UK as their preferred edition and visits the US network front, /us, will be shown this banner. Similarly, a user that does not have this cookie but lives in the UK will also be shown this banner when visiting /us, or /au, /europe or /international.

The banner will show up every time the user goes to a network front different to their edition.

The subnav (with white background) and straight lines beneath it are not rendered when the banner is displayed. This is because the banner needs to be sticky over the main content and having the banner above the subnav isn't technically possible without updating the HTML of the page. This would undoubtedly affect other teams. For example, we don't want to risk interrupting the behaviour of the top-above-nav ad slot.

You can opt out of seeing the banner by visiting https://www.theguardian.com/uk?editionSwitcherBanner=hide. This will set a cookie that will hide the banner. Note that there may be a flash of content as the banner is rendered server-side. To remove this cookie, visit https://www.theguardian.com/uk?editionSwitcherBanner=unhide. I chose "unhide" rather than "show", as the latter may mislead users to think that it forces the banner to show, which it does not.

Tracking:

  • Component: data-component="edition-switcher-banner"
  • "View the ... homepage link: data-link-name="edition-switcher-banner close-banner"
  • Close button: data-link-name="edition-switcher-banner switch-edition"

Why?

We want to give users the option to go back to their default front if they've ended up on a different network front by accident (or been sent there incorrectly by a search engine).

This banner provides a visual indication to a user that has arrived on a different network front to their own, that there may be a network front with content more relevant to them.

Screenshots

UK edition on /uk UK edition on /us
mobile mobile-before mobile-after
tablet tablet-before tablet-after
desktop desktop-before desktop-after

 Screen recordings

Screen.Recording.2024-06-28.at.14.51.32.mov
Screen.Recording.2024-06-28.at.14.52.35.mov

Copy link

github-actions bot commented Jun 28, 2024

Size Change: +14.1 kB (+1.62%)

Total Size: 881 kB

Filename Size Change
dotcom-rendering/dist/HeaderTopBar-importable.client.web.********************.js 7.49 kB +414 B (+5.85%) 🔍
dotcom-rendering/dist/index.client.web.********************.js 46 kB +105 B (+0.23%)
dotcom-rendering/dist/3113.client.web.********************.js 4.51 kB +4.51 kB (new file) 🆕
dotcom-rendering/dist/EditionSwitcherBanner-importable.client.web.********************.js 3.46 kB +3.46 kB (new file) 🆕
dotcom-rendering/dist/FrontSubNav-importable.client.web.********************.js 5.3 kB +5.3 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
dotcom-rendering/dist/1094.client.web.********************.js 6.01 kB +12 B (+0.2%)
dotcom-rendering/dist/1225.client.web.********************.js 785 B 0 B
dotcom-rendering/dist/1299.client.web.********************.js 937 B 0 B
dotcom-rendering/dist/1445.client.web.********************.js 18.1 kB 0 B
dotcom-rendering/dist/1543.client.web.********************.js 3.28 kB 0 B
dotcom-rendering/dist/1692.client.web.********************.js 3.13 kB 0 B
dotcom-rendering/dist/1762.client.web.********************.js 3.39 kB 0 B
dotcom-rendering/dist/1889.client.web.********************.js 3.63 kB 0 B
dotcom-rendering/dist/2170.client.web.********************.js 6.78 kB +11 B (+0.16%)
dotcom-rendering/dist/2207.client.web.********************.js 2.98 kB 0 B
dotcom-rendering/dist/226.client.web.********************.js 3.93 kB 0 B
dotcom-rendering/dist/2264.client.web.********************.js 2.66 kB 0 B
dotcom-rendering/dist/2342.client.web.********************.js 1.01 kB 0 B
dotcom-rendering/dist/2344.client.web.********************.js 3.37 kB 0 B
dotcom-rendering/dist/2373.client.web.********************.js 11.5 kB 0 B
dotcom-rendering/dist/2471.client.web.********************.js 723 B 0 B
dotcom-rendering/dist/2638.client.web.********************.js 3.37 kB 0 B
dotcom-rendering/dist/2692.client.web.********************.js 2.9 kB 0 B
dotcom-rendering/dist/2778.client.web.********************.js 858 B 0 B
dotcom-rendering/dist/2780.client.web.********************.js 6.42 kB 0 B
dotcom-rendering/dist/2920.client.web.********************.js 523 B 0 B
dotcom-rendering/dist/3000.client.web.********************.js 895 B 0 B
dotcom-rendering/dist/3114.client.web.********************.js 663 B 0 B
dotcom-rendering/dist/3118.client.web.********************.js 499 B 0 B
dotcom-rendering/dist/312.client.web.********************.js 2.93 kB 0 B
dotcom-rendering/dist/3255.client.web.********************.js 809 B 0 B
dotcom-rendering/dist/3336.client.web.********************.js 785 B 0 B
dotcom-rendering/dist/336.client.web.********************.js 13.4 kB 0 B
dotcom-rendering/dist/3371.client.web.********************.js 3.28 kB 0 B
dotcom-rendering/dist/3431.client.web.********************.js 5.53 kB 0 B
dotcom-rendering/dist/3494.client.web.********************.js 834 B 0 B
dotcom-rendering/dist/3523.client.web.********************.js 3.35 kB 0 B
dotcom-rendering/dist/3642.client.web.********************.js 791 B 0 B
dotcom-rendering/dist/3689.client.web.********************.js 4.3 kB 0 B
dotcom-rendering/dist/3787.client.web.********************.js 5.49 kB 0 B
dotcom-rendering/dist/3922.client.web.********************.js 731 B 0 B
dotcom-rendering/dist/393.client.web.********************.js 5.91 kB 0 B
dotcom-rendering/dist/3932.client.web.********************.js 790 B 0 B
dotcom-rendering/dist/4103.client.web.********************.js 22.6 kB 0 B
dotcom-rendering/dist/4129.client.web.********************.js 4.43 kB 0 B
dotcom-rendering/dist/424.client.web.********************.js 757 B 0 B
dotcom-rendering/dist/4442.client.web.********************.js 833 B 0 B
dotcom-rendering/dist/4639.client.web.********************.js 3 kB 0 B
dotcom-rendering/dist/4652.client.web.********************.js 3.59 kB 0 B
dotcom-rendering/dist/4666.client.web.********************.js 9.24 kB 0 B
dotcom-rendering/dist/4673.client.web.********************.js 731 B 0 B
dotcom-rendering/dist/4807.client.web.********************.js 4.3 kB 0 B
dotcom-rendering/dist/4811.client.web.********************.js 1.01 kB 0 B
dotcom-rendering/dist/5044.client.web.********************.js 811 B 0 B
dotcom-rendering/dist/5077.client.web.********************.js 441 B 0 B
dotcom-rendering/dist/5084.client.web.********************.js 759 B 0 B
dotcom-rendering/dist/5127.client.web.********************.js 4.39 kB 0 B
dotcom-rendering/dist/5247.client.web.********************.js 2.86 kB 0 B
dotcom-rendering/dist/5308.client.web.********************.js 2.69 kB 0 B
dotcom-rendering/dist/5353.client.web.********************.js 11.8 kB 0 B
dotcom-rendering/dist/5536.client.web.********************.js 3.89 kB 0 B
dotcom-rendering/dist/565.client.web.********************.js 675 B 0 B
dotcom-rendering/dist/5750.client.web.********************.js 3.21 kB 0 B
dotcom-rendering/dist/5817.client.web.********************.js 922 B 0 B
dotcom-rendering/dist/6002.client.web.********************.js 3.09 kB 0 B
dotcom-rendering/dist/606.client.web.********************.js 3.53 kB 0 B
dotcom-rendering/dist/6093.client.web.********************.js 758 B 0 B
dotcom-rendering/dist/6167.client.web.********************.js 646 B 0 B
dotcom-rendering/dist/6351.client.web.********************.js 5.42 kB +40 B (+0.74%)
dotcom-rendering/dist/662.client.web.********************.js 2.67 kB 0 B
dotcom-rendering/dist/6640.client.web.********************.js 913 B 0 B
dotcom-rendering/dist/6793.client.web.********************.js 5.71 kB 0 B
dotcom-rendering/dist/6843.client.web.********************.js 7.29 kB 0 B
dotcom-rendering/dist/6908.client.web.********************.js 3.48 kB 0 B
dotcom-rendering/dist/6921.client.web.********************.js 2.99 kB 0 B
dotcom-rendering/dist/7062.client.web.********************.js 2.29 kB 0 B
dotcom-rendering/dist/7116.client.web.********************.js 23 kB 0 B
dotcom-rendering/dist/7196.client.web.********************.js 895 B 0 B
dotcom-rendering/dist/72.client.web.********************.js 966 B 0 B
dotcom-rendering/dist/7208.client.web.********************.js 2.41 kB 0 B
dotcom-rendering/dist/7265.client.web.********************.js 3.21 kB 0 B
dotcom-rendering/dist/7387.client.web.********************.js 961 B 0 B
dotcom-rendering/dist/7544.client.web.********************.js 3.06 kB -2 B (-0.07%)
dotcom-rendering/dist/7660.client.web.********************.js 3.67 kB 0 B
dotcom-rendering/dist/7697.client.web.********************.js 620 B 0 B
dotcom-rendering/dist/7723.client.web.********************.js 925 B 0 B
dotcom-rendering/dist/8134.client.web.********************.js 601 B 0 B
dotcom-rendering/dist/8179.client.web.********************.js 834 B 0 B
dotcom-rendering/dist/8279.client.web.********************.js 43.1 kB 0 B
dotcom-rendering/dist/8363.client.web.********************.js 3.67 kB 0 B
dotcom-rendering/dist/8463.client.web.********************.js 156 B 0 B
dotcom-rendering/dist/8565.client.web.********************.js 653 B 0 B
dotcom-rendering/dist/8569.client.web.********************.js 3.58 kB 0 B
dotcom-rendering/dist/8791.client.web.********************.js 1.01 kB 0 B
dotcom-rendering/dist/8839.client.web.********************.js 3.37 kB 0 B
dotcom-rendering/dist/889.client.web.********************.js 860 B 0 B
dotcom-rendering/dist/8907.client.web.********************.js 792 B 0 B
dotcom-rendering/dist/9060.client.web.********************.js 886 B 0 B
dotcom-rendering/dist/9225.client.web.********************.js 583 B 0 B
dotcom-rendering/dist/9247.client.web.********************.js 3.83 kB 0 B
dotcom-rendering/dist/9287.client.web.********************.js 2.42 kB 0 B
dotcom-rendering/dist/9396.client.web.********************.js 691 B 0 B
dotcom-rendering/dist/9430.client.web.********************.js 510 B 0 B
dotcom-rendering/dist/9447.client.web.********************.js 3.06 kB 0 B
dotcom-rendering/dist/9604.client.web.********************.js 528 B 0 B
dotcom-rendering/dist/9789.client.web.********************.js 924 B 0 B
dotcom-rendering/dist/9826.client.web.********************.js 3.42 kB 0 B
dotcom-rendering/dist/9936.client.web.********************.js 1.84 kB 0 B
dotcom-rendering/dist/Accessibility-importable.client.web.********************.js 5.79 kB 0 B
dotcom-rendering/dist/AdBlockAsk-importable.client.web.********************.js 2.85 kB 0 B
dotcom-rendering/dist/AdPortals-importable.client.web.********************.js 3.84 kB 0 B
dotcom-rendering/dist/AlreadyVisited-importable.client.web.********************.js 425 B 0 B
dotcom-rendering/dist/AppsEpic-importable.client.web.********************.js 3.54 kB 0 B
dotcom-rendering/dist/AppsFooter-importable.client.web.********************.js 3.64 kB 0 B
dotcom-rendering/dist/AppsLightboxImage-importable.client.web.********************.js 3.03 kB 0 B
dotcom-rendering/dist/AppsLightboxImageStore-importable.client.web.********************.js 2.47 kB 0 B
dotcom-rendering/dist/AudioAtomWrapper-importable.client.web.********************.js 3.58 kB 0 B
dotcom-rendering/dist/AustralianTerritorySwitcher-importable.client.web.********************.js 2.57 kB 0 B
dotcom-rendering/dist/Branding-importable.client.web.********************.js 3.08 kB 0 B
dotcom-rendering/dist/braze-web-sdk-core.client.web.********************.js 37.2 kB 0 B
dotcom-rendering/dist/BrazeMessaging-importable.client.web.********************.js 1.9 kB 0 B
dotcom-rendering/dist/CalloutBlockComponent-importable.client.web.********************.js 6.73 kB 0 B
dotcom-rendering/dist/CalloutEmbedBlockComponent-importable.client.web.********************.js 5.75 kB 0 B
dotcom-rendering/dist/CardCommentCount-importable.client.web.********************.js 4.91 kB 0 B
dotcom-rendering/dist/Carousel-importable.client.web.********************.js 1.17 kB 0 B
dotcom-rendering/dist/CarouselForNewsletters-importable.client.web.********************.js 6.64 kB +11 B (+0.17%)
dotcom-rendering/dist/ChartAtom-importable.client.web.********************.js 539 B 0 B
dotcom-rendering/dist/CommentCount-importable.client.web.********************.js 3.26 kB 0 B
dotcom-rendering/dist/DiscussionApps-importable.client.web.********************.js 1.81 kB 0 B
dotcom-rendering/dist/DiscussionMeta-importable.client.web.********************.js 3.08 kB 0 B
dotcom-rendering/dist/DiscussionWeb-importable.client.web.********************.js 1.67 kB 0 B
dotcom-rendering/dist/DocumentBlockComponent-importable.client.web.********************.js 3.55 kB 0 B
dotcom-rendering/dist/EmbedBlockComponent-importable.client.web.********************.js 4.1 kB 0 B
dotcom-rendering/dist/EnhancePinnedPost-importable.client.web.********************.js 2.02 kB 0 B
dotcom-rendering/dist/FetchOnwardsData-importable.client.web.********************.js 3.4 kB 0 B
dotcom-rendering/dist/FilterKeyEventsToggle-importable.client.web.********************.js 5.21 kB 0 B
dotcom-rendering/dist/FocusStyles-importable.client.web.********************.js 622 B 0 B
dotcom-rendering/dist/FollowWrapper-importable.client.web.********************.js 837 B 0 B
dotcom-rendering/dist/FooterLabel-importable.client.web.********************.js 346 B 0 B
dotcom-rendering/dist/frameworks.client.web.********************.js 20.7 kB 0 B
dotcom-rendering/dist/GetCricketScoreboard-importable.client.web.********************.js 4.56 kB +30 B (+0.66%)
dotcom-rendering/dist/GetMatchNav-importable.client.web.********************.js 11.5 kB +11 B (+0.1%)
dotcom-rendering/dist/GetMatchStats-importable.client.web.********************.js 7.9 kB +12 B (+0.15%)
dotcom-rendering/dist/GetMatchTabs-importable.client.web.********************.js 2.64 kB 0 B
dotcom-rendering/dist/guardian-braze-components-banner.client.web.********************.js 16.7 kB 0 B
dotcom-rendering/dist/guardian-braze-components-end-of-article.client.web.********************.js 11.2 kB 0 B
dotcom-rendering/dist/GuideAtomWrapper-importable.client.web.********************.js 3.02 kB 0 B
dotcom-rendering/dist/InstagramBlockComponent-importable.client.web.********************.js 3.64 kB 0 B
dotcom-rendering/dist/InteractiveAtomMessenger-importable.client.web.********************.js 851 B 0 B
dotcom-rendering/dist/InteractiveBlockComponent-importable.client.web.********************.js 6.3 kB 0 B
dotcom-rendering/dist/InteractiveContentsBlockComponent-importable.client.web.********************.js 4.69 kB +12 B (+0.26%)
dotcom-rendering/dist/InteractiveSupportButton-importable.client.web.********************.js 3.47 kB 0 B
dotcom-rendering/dist/KeyEventsCarousel-importable.client.web.********************.js 4.93 kB +31 B (+0.63%)
dotcom-rendering/dist/KnowledgeQuizAtom-importable.client.web.********************.js 3.5 kB 0 B
dotcom-rendering/dist/LatestLinks-importable.client.web.********************.js 4.85 kB 0 B
dotcom-rendering/dist/LightboxHash-importable.client.web.********************.js 435 B 0 B
dotcom-rendering/dist/LightboxLayout-importable.client.web.********************.js 6.47 kB +12 B (+0.19%)
dotcom-rendering/dist/LiveBlogEpic-importable.client.web.********************.js 3.7 kB 0 B
dotcom-rendering/dist/Liveness-importable.client.web.********************.js 4.97 kB 0 B
dotcom-rendering/dist/ManyNewsletterSignUp-importable.client.web.********************.js 7.79 kB +28 B (+0.36%)
dotcom-rendering/dist/MapEmbedBlockComponent-importable.client.web.********************.js 5.76 kB 0 B
dotcom-rendering/dist/Metrics-importable.client.web.********************.js 2.96 kB 0 B
dotcom-rendering/dist/MostViewedFooter-importable.client.web.********************.js 5.94 kB 0 B
dotcom-rendering/dist/MostViewedFooterData-importable.client.web.********************.js 8.52 kB 0 B
dotcom-rendering/dist/MostViewedRightWithAd-importable.client.web.********************.js 5.14 kB 0 B
dotcom-rendering/dist/OnwardsUpper-importable.client.web.********************.js 6.62 kB 0 B
dotcom-rendering/dist/PersonalityQuizAtom-importable.client.web.********************.js 3.63 kB 0 B
dotcom-rendering/dist/ProfileAtom-importable.client.web.********************.js 2.8 kB 0 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.client.web.********************.js 3.04 kB 0 B
dotcom-rendering/dist/PulsingDot-importable.client.web.********************.js 749 B 0 B
dotcom-rendering/dist/QandaAtom-importable.client.web.********************.js 2.8 kB 0 B
dotcom-rendering/dist/ReaderRevenueDev-importable.client.web.********************.js 469 B 0 B
dotcom-rendering/dist/readerRevenueDevUtils.client.web.********************.js 1.92 kB 0 B
dotcom-rendering/dist/ReaderRevenueLinks-importable.client.web.********************.js 6.37 kB 0 B
dotcom-rendering/dist/RelativeTime-importable.client.web.********************.js 2.51 kB +33 B (+1.33%)
dotcom-rendering/dist/RichLinkComponent-importable.client.web.********************.js 4.8 kB 0 B
dotcom-rendering/dist/SecureSignup-importable.client.web.********************.js 4.17 kB 0 B
dotcom-rendering/dist/SendAMessage-importable.client.web.********************.js 4.42 kB 0 B
dotcom-rendering/dist/SendTargetingParams-importable.client.web.********************.js 2.15 kB 0 B
dotcom-rendering/dist/sentry.client.web.********************.js 764 B 0 B
dotcom-rendering/dist/SetABTests-importable.client.web.********************.js 3.81 kB 0 B
dotcom-rendering/dist/SetAdTargeting-importable.client.web.********************.js 484 B 0 B
dotcom-rendering/dist/ShareButton-importable.client.web.********************.js 1.53 kB 0 B
dotcom-rendering/dist/shimport.client.web.********************.js 2.8 kB 0 B
dotcom-rendering/dist/ShowHideContainers-importable.client.web.********************.js 713 B 0 B
dotcom-rendering/dist/ShowMore-importable.client.web.********************.js 4.04 kB 0 B
dotcom-rendering/dist/SignInGateMain.client.web.********************.js 3.9 kB 0 B
dotcom-rendering/dist/SignInGateMainCheckoutComplete.client.web.********************.js 3.93 kB 0 B
dotcom-rendering/dist/SignInGateSelector-importable.client.web.********************.js 5.78 kB 0 B
dotcom-rendering/dist/SlotBodyEnd-importable.client.web.********************.js 4.15 kB 0 B
dotcom-rendering/dist/SpotifyBlockComponent-importable.client.web.********************.js 5.61 kB 0 B
dotcom-rendering/dist/StickyBottomBanner-importable.client.web.********************.js 6.03 kB +10 B (+0.17%)
dotcom-rendering/dist/StickyLiveblogAskWrapper-importable.client.web.********************.js 9.31 kB 0 B
dotcom-rendering/dist/SubNav-importable.client.web.********************.js 3.37 kB +1 B (+0.03%)
dotcom-rendering/dist/SupportTheG-importable.client.web.********************.js 6.49 kB 0 B
dotcom-rendering/dist/TableOfContents-importable.client.web.********************.js 3.2 kB 0 B
dotcom-rendering/dist/TimelineAtom-importable.client.web.********************.js 3.23 kB 0 B
dotcom-rendering/dist/TopBar-importable.client.web.********************.js 5.03 kB 0 B
dotcom-rendering/dist/TopBarSupport-importable.client.web.********************.js 2.76 kB 0 B
dotcom-rendering/dist/TweetBlockComponent-importable.client.web.********************.js 1.02 kB 0 B
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.client.web.********************.js 3.65 kB 0 B
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.client.web.********************.js 5.77 kB 0 B
dotcom-rendering/dist/VineBlockComponent-importable.client.web.********************.js 3.49 kB 0 B
dotcom-rendering/dist/WeatherWrapper-importable.client.web.********************.js 5.54 kB +27 B (+0.49%)
dotcom-rendering/dist/YoutubeBlockComponent-importable.client.web.********************.js 3.3 kB 0 B

compressed-size-action

@domlander domlander changed the title Doml/edition switcher banner with islands Edition switcher banner Jun 28, 2024
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Jun 28, 2024
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jun 28, 2024
currentPillarTitle?: string;
};

export const FrontSubNav = ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved into its own component so we can use the useEditionSwitcherBanner hook. The <Subnav /> was already in an island; this does move the straight lines into the island too.

@domlander domlander force-pushed the doml/edition-switcher-banner-with-islands branch from 75ebced to 244d0a7 Compare June 28, 2024 17:23
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Jul 1, 2024
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jul 1, 2024
@domlander domlander marked this pull request as ready for review July 1, 2024 09:02
@domlander domlander requested a review from a team as a code owner July 1, 2024 09:02
Copy link

github-actions bot commented Jul 1, 2024

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@ashishpuliyel
Copy link
Member

I chose "unhide" rather than "show", as the latter may mislead users to think that it forces the banner to show, which it does not.

Very neat and smart!

Copy link
Contributor

@mxdvl mxdvl left a comment

Choose a reason for hiding this comment

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

Excellent work!

Left a few notes, but nothing blocking. I think we can abstract away SWR as the cross island mechanism for a cleaner API from a single custom hook.


const getBannerValueFromQueryParams = () => {
const queryParams = new URLSearchParams(window.location.search);
return queryParams.get('editionSwitcherBanner');
Copy link
Member

Choose a reason for hiding this comment

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

Could making this param lowercase mean less chance for mistakes? It seems to be what we have favoured in the past in Frontend:

https://github.com/guardian/frontend/blob/a6884771da35cfd63a9032400bbd59b89aef0a03/common/app/dev/DevParametersHttpRequestHandler.scala#L67

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see lowercase, camelCase, underscores AND hyphens in that list!

With quite long words, I worry it won't be very readable in lowercase. Also, the only examples in that file with over 10 characters use either camelCase, underscores or hyphens.

Copy link
Member

Choose a reason for hiding this comment

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

Sigh. I thought the commercial param names were fairly consistent but it's a shame there is a mix of conventions.

Happy to leave it to you though unless you fancy edition-switcher-banner

As an aside the received wisdom appears to be to use hyphens for word separators in URLs:
https://developers.google.com/search/docs/crawling-indexing/url-structure
https://blog.codinghorror.com/of-spaces-underscores-and-dashes/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK interesting. If we're inconsistent then I think going with what Google recommend is probably a good idea. I'll update to edition-switcher-banner.

dotcom-rendering/src/types/front.ts Outdated Show resolved Hide resolved
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Jul 2, 2024
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jul 2, 2024
Copy link
Contributor

@mxdvl mxdvl left a comment

Choose a reason for hiding this comment

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

Take me to the UK homepage!

dotcom-rendering/src/lib/useUserPreferredEdition.ts Outdated Show resolved Hide resolved
@domlander domlander force-pushed the doml/edition-switcher-banner-with-islands branch from 7fd84ba to fcb1a25 Compare July 2, 2024 16:08
@domlander domlander added the run_chromatic Runs chromatic when label is applied label Jul 2, 2024
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Jul 2, 2024
@domlander domlander merged commit b4b8144 into main Jul 10, 2024
34 checks passed
@domlander domlander deleted the doml/edition-switcher-banner-with-islands branch July 10, 2024 14:42
@prout-bot
Copy link

Seen on PROD (merged by @domlander 10 minutes and 32 seconds ago) Please check your changes!

@rtyley
Copy link
Member

rtyley commented Jul 18, 2024

Just to note that I've experienced a bug with this banner this morning on Chrome on my Android phone? It seems to be unduly persistent on https://www.theguardian.com/uk - I'm London-based, and use the UK edition, but every time I dismiss the "You are viewing the UK homepage" banner and reload the network front, it reappears:

screen-20240718-073607.mp4

At one point in this video, I click on an article and then the News tab to get back to the network front- but it takes me to the US edition network front?! When I select the UK Edition, the banner is gone - until I remove the campaign code to make the url just https://www.theguardian.com/uk - at which point it appears again. Perhaps this is a Fastly bug?

Update: as of 7:50am, the banner is no longer showing on my phone, guess the problem has cleared itself?

@domlander
Copy link
Contributor Author

Just to note that I've experienced a bug with this banner this morning on Chrome on my Android phone? It seems to be unduly persistent on https://www.theguardian.com/uk - I'm London-based, and use the UK edition, but every time I dismiss the "You are viewing the UK homepage" banner and reload the network front, it reappears:

At one point in this video, I click on an article and then the News tab to get back to the network front- but it takes me to the US edition network front?! When I select the UK Edition, the banner is gone - until I remove the campaign code to make the url just https://www.theguardian.com/uk - at which point it appears again. Perhaps this is a Fastly bug?

I think what you're seeing here is mostly expected behaviour. Clicking the X does not stop the banner from reappearing the next time you go to a network front that doesn't match your preferred edition.

I'll explain what I think is going on at each stage of the video. Please mention if there is any point where I have misunderstood.

0:00 - 0:11
Refreshing the page on /uk whilst using the US edition will result in the banner appearing every time you reload the page. I think you might be using the US edition here as the temperature in the weather widget is in Fahrenheit.

0:16 - 0:22
On the /us front whilst using the US edition, you don't see the banner, as expected.

0:26 - 0:32
Switching edition to the UK then refreshing the page, you don't see the banner, as expected.

0:35 - 0:42
Manually editing the URL to remove ?INTCMP=CE_UK from /uk, you then see the banner. This is not expected and I can reproduce with this method. This might be the result of caching since the banner is rendered server-side. However, refreshing the page does not result in the banner being displayed, so I think we OK from a user perspective, since they are unlikely to manually edit the URL to go to the same page.

@rtyley
Copy link
Member

rtyley commented Jul 18, 2024

I think you might be using the US edition here as the temperature in the weather widget is in Fahrenheit.

Ah, good point! So it was user error on my part- I thought my edition preference was set to UK, but it was actually US, so the messaging makes sense. Thank you for doing the detective work to figure that out, and explain it so clearly!

For my particular form of confusion, a better message would be something like "You're viewing the UK homepage, but your default is set to the US homepage" - better for me, but definitely more verbose and might prompt different questions from other users like "How do I set my default?".

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

Successfully merging this pull request may close these issues.

Implement new edition switcher
6 participants