Skip to content

/TagFront - Tag fronts on DCR! - #7752

Merged
OllysCoding merged 45 commits into
mainfrom
olly/dcr-index-pages
Jun 26, 2023
Merged

OllysCoding merged 45 commits into
mainfrom
olly/dcr-index-pages

Conversation

@OllysCoding

@OllysCoding OllysCoding commented May 17, 2023 •

Copy link
Copy Markdown
Contributor

Adds support for tag fronts in DCR!

Completed features in this PR

  • Base types, schemas & endpoints required to support tag fronts
  • groupTrailsByDates.ts- Logic for grouping trails
  • TagFrontLayout.tsx - Full working layout for tag fronts
  • FrontPagination.tsx - Pagination logic that allows users to navigate between pages on tag fronts
  • TagFrontHeader.tsx - Header for tag fronts which can include a title, description & image if they're provided for the tag

Future work required

  • Ads & commercial code - I haven't looked into exactly how ads display on these fronts yet, this will come in a future PR
  • Support for other types of tag pages - There are many other types of tag pages, but this only supports main ones like www.theguardian.com/tone/minutebyminute & www.theguardian.com/profile/josh-halliday
  • Slow & Fast - More research is needed into the distinction between slow & fast, and how it should work

Screenshots

tone/minutebyminute
localhost_3030_TagFront_https___www theguardian com_tone_minutebyminute

profile/josh-haliday
localhost_3030_TagFront_https___www theguardian com_profile_josh-halliday

getArticleSchema,
getFrontSchema,
getNewsletterPageSchema,
getIndexPageSchema,

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.

being pedantic here but index is quite an overloaded term, maybe we could go with tagPage instead? I think this is what we call them in the business no?

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.

actually, probably better to call it a TagFront, which it is, then we'd also avoid the TagPagePage business

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Your definitely right, in the spirit of hacking speed I'm going to keep going, but will be refactoring & tidying all this code on Friday

@github-actions

github-actions Bot commented Jun 21, 2023 •

Copy link
Copy Markdown

Size Change: -10.4 kB (-2%)

Total Size: 571 kB

Filename Size Change
dotcom-rendering/dist/7184.modern.********************.js 0 B -10.7 kB (removed) 🏆
dotcom-rendering/dist/HeaderTopBar-importable.modern.********************.js 10.5 kB +142 B (+1%)
ℹ️ View Unchanged
Filename Size Change
dotcom-rendering/dist/1238.modern.********************.js 3.07 kB 0 B
dotcom-rendering/dist/1813.modern.********************.js 6.52 kB 0 B
dotcom-rendering/dist/2006.modern.********************.js 3.84 kB 0 B
dotcom-rendering/dist/2243.modern.********************.js 3.08 kB 0 B
dotcom-rendering/dist/2854.modern.********************.js 3.3 kB 0 B
dotcom-rendering/dist/3250.modern.********************.js 3.56 kB 0 B
dotcom-rendering/dist/3398.modern.********************.js 20 kB 0 B
dotcom-rendering/dist/3577.modern.********************.js 4.51 kB 0 B
dotcom-rendering/dist/3911.modern.********************.js 3.16 kB 0 B
dotcom-rendering/dist/3993.modern.********************.js 6.21 kB 0 B
dotcom-rendering/dist/4331.modern.********************.js 3.36 kB 0 B
dotcom-rendering/dist/5153.modern.********************.js 2.28 kB 0 B
dotcom-rendering/dist/516.modern.********************.js 17.5 kB 0 B
dotcom-rendering/dist/5182.modern.********************.js 3.9 kB 0 B
dotcom-rendering/dist/5237.modern.********************.js 2.44 kB 0 B
dotcom-rendering/dist/6297.modern.********************.js 21.3 kB 0 B
dotcom-rendering/dist/6633.modern.********************.js 3.22 kB 0 B
dotcom-rendering/dist/6814.modern.********************.js 5.4 kB -18 B (0%)
dotcom-rendering/dist/6939.modern.********************.js 5.36 kB 0 B
dotcom-rendering/dist/7392.modern.********************.js 2.49 kB 0 B
dotcom-rendering/dist/7844.modern.********************.js 4.8 kB 0 B
dotcom-rendering/dist/7872.modern.********************.js 1.89 kB 0 B
dotcom-rendering/dist/8012.modern.********************.js 4.66 kB 0 B
dotcom-rendering/dist/8326.modern.********************.js 2.58 kB +25 B (+1%)
dotcom-rendering/dist/8452.modern.********************.js 4.28 kB 0 B
dotcom-rendering/dist/8780.modern.********************.js 3.16 kB 0 B
dotcom-rendering/dist/8888.modern.********************.js 2.75 kB 0 B
dotcom-rendering/dist/9463.modern.********************.js 543 B 0 B
dotcom-rendering/dist/9470.modern.********************.js 28.8 kB 0 B
dotcom-rendering/dist/9500.modern.********************.js 10.8 kB 0 B
dotcom-rendering/dist/9571.modern.********************.js 3.91 kB 0 B
dotcom-rendering/dist/9861.modern.********************.js 3.5 kB 0 B
dotcom-rendering/dist/9874.modern.********************.js 5.06 kB 0 B
dotcom-rendering/dist/AlreadyVisited-importable.modern.********************.js 410 B 0 B
dotcom-rendering/dist/AnimatePulsingDots-importable.modern.********************.js 389 B 0 B
dotcom-rendering/dist/atomIframe.modern.********************.js 516 B 0 B
dotcom-rendering/dist/AudioAtomWrapper-importable.modern.********************.js 463 B 0 B
dotcom-rendering/dist/AustralianTerritorySwitcher-importable.modern.********************.js 1.14 kB 0 B
dotcom-rendering/dist/Branding-importable.modern.********************.js 2.18 kB 0 B
dotcom-rendering/dist/braze-web-sdk-core.modern.********************.js 36.9 kB 0 B
dotcom-rendering/dist/BrazeMessaging-importable.modern.********************.js 5.24 kB 0 B
dotcom-rendering/dist/CalloutBlockComponent-importable.modern.********************.js 6.46 kB 0 B
dotcom-rendering/dist/CalloutEmbedBlockComponent-importable.modern.********************.js 6.59 kB 0 B
dotcom-rendering/dist/Carousel-importable.modern.********************.js 5.28 kB +9 B (0%)
dotcom-rendering/dist/ChartAtomWrapper-importable.modern.********************.js 474 B 0 B
dotcom-rendering/dist/CommentCount-importable.modern.********************.js 2.77 kB 0 B
dotcom-rendering/dist/discussion.modern.********************.js 393 B 0 B
dotcom-rendering/dist/DiscussionContainer-importable.modern.********************.js 4.29 kB 0 B
dotcom-rendering/dist/DiscussionMeta-importable.modern.********************.js 3.35 kB 0 B
dotcom-rendering/dist/DocumentBlockComponent-importable.modern.********************.js 2.72 kB 0 B
dotcom-rendering/dist/EmbedBlockComponent-importable.modern.********************.js 3.25 kB 0 B
dotcom-rendering/dist/embedIframe.modern.********************.js 520 B 0 B
dotcom-rendering/dist/EnhancePinnedPost-importable.modern.********************.js 1.93 kB 0 B
dotcom-rendering/dist/FetchCommentCounts-importable.modern.********************.js 2.97 kB 0 B
dotcom-rendering/dist/FetchOnwardsData-importable.modern.********************.js 2.01 kB +90 B (+5%) 🔍
dotcom-rendering/dist/FilterKeyEventsToggle-importable.modern.********************.js 3.41 kB 0 B
dotcom-rendering/dist/FocusStyles-importable.modern.********************.js 511 B 0 B
dotcom-rendering/dist/frameworks.modern.********************.js 20.5 kB 0 B
dotcom-rendering/dist/GetCricketScoreboard-importable.modern.********************.js 3.36 kB 0 B
dotcom-rendering/dist/GetMatchNav-importable.modern.********************.js 11.4 kB 0 B
dotcom-rendering/dist/GetMatchStats-importable.modern.********************.js 6.32 kB 0 B
dotcom-rendering/dist/GetMatchTabs-importable.modern.********************.js 2.42 kB 0 B
dotcom-rendering/dist/guardian-braze-components-banner.modern.********************.js 13.3 kB 0 B
dotcom-rendering/dist/guardian-braze-components-end-of-article.modern.********************.js 10.3 kB 0 B
dotcom-rendering/dist/GuideAtomWrapper-importable.modern.********************.js 476 B 0 B
dotcom-rendering/dist/index.modern.********************.js 33.3 kB +2 B (0%)
dotcom-rendering/dist/InstagramBlockComponent-importable.modern.********************.js 2.79 kB 0 B
dotcom-rendering/dist/InteractiveBlockComponent-importable.modern.********************.js 5.8 kB 0 B
dotcom-rendering/dist/InteractiveContentsBlockComponent-importable.modern.********************.js 4.09 kB 0 B
dotcom-rendering/dist/InteractiveSupportButton-importable.modern.********************.js 3.82 kB 0 B
dotcom-rendering/dist/KeyEventsCarousel-importable.modern.********************.js 2.21 kB 0 B
dotcom-rendering/dist/KnowledgeQuizAtomWrapper-importable.modern.********************.js 481 B 0 B
dotcom-rendering/dist/LatestLinks-importable.modern.********************.js 1.85 kB 0 B
dotcom-rendering/dist/LiveBlogEpic-importable.modern.********************.js 5.08 kB 0 B
dotcom-rendering/dist/Liveness-importable.modern.********************.js 5.52 kB 0 B
dotcom-rendering/dist/ManyNewsletterSignUp-importable.modern.********************.js 5.64 kB 0 B
dotcom-rendering/dist/MapEmbedBlockComponent-importable.modern.********************.js 5.32 kB 0 B
dotcom-rendering/dist/Metrics-importable.modern.********************.js 2.46 kB 0 B
dotcom-rendering/dist/MostViewedFooter-importable.modern.********************.js 5.35 kB 0 B
dotcom-rendering/dist/MostViewedFooterData-importable.modern.********************.js 7.55 kB 0 B
dotcom-rendering/dist/MostViewedRightWrapper-importable.modern.********************.js 3.78 kB 0 B
dotcom-rendering/dist/newsletterEmbedIframe.modern.********************.js 621 B 0 B
dotcom-rendering/dist/OnwardsUpper-importable.modern.********************.js 3.9 kB +99 B (+3%)
dotcom-rendering/dist/PersonalityQuizAtomWrapper-importable.modern.********************.js 483 B 0 B
dotcom-rendering/dist/ProfileAtomWrapper-importable.modern.********************.js 478 B 0 B
dotcom-rendering/dist/QandaAtomWrapper-importable.modern.********************.js 475 B 0 B
dotcom-rendering/dist/ReaderRevenueDev-importable.modern.********************.js 461 B 0 B
dotcom-rendering/dist/readerRevenueDevUtils.modern.********************.js 2.71 kB 0 B
dotcom-rendering/dist/ReaderRevenueLinks-importable.modern.********************.js 5.57 kB 0 B
dotcom-rendering/dist/RecipeMultiplier-importable.modern.********************.js 3.23 kB 0 B
dotcom-rendering/dist/relativeTime.modern.********************.js 976 B 0 B
dotcom-rendering/dist/RichLinkComponent-importable.modern.********************.js 5.05 kB 0 B
dotcom-rendering/dist/SecureSignupIframe-importable.modern.********************.js 2.54 kB 0 B
dotcom-rendering/dist/SendAMessage-importable.modern.********************.js 4.37 kB 0 B
dotcom-rendering/dist/sentry.modern.********************.js 766 B 0 B
dotcom-rendering/dist/SetABTests-importable.modern.********************.js 3.88 kB 0 B
dotcom-rendering/dist/ShareCount-importable.modern.********************.js 2.91 kB 0 B
dotcom-rendering/dist/shimport.modern.********************.js 2.78 kB 0 B
dotcom-rendering/dist/ShowHideContainers-importable.modern.********************.js 719 B 0 B
dotcom-rendering/dist/ShowMore-importable.modern.********************.js 5.08 kB 0 B
dotcom-rendering/dist/SignInGateMain.modern.********************.js 2.93 kB 0 B
dotcom-rendering/dist/SignInGateMainCheckoutComplete.modern.********************.js 3.84 kB 0 B
dotcom-rendering/dist/SignInGateSelector-importable.modern.********************.js 3.68 kB 0 B
dotcom-rendering/dist/SlotBodyEnd-importable.modern.********************.js 2.86 kB 0 B
dotcom-rendering/dist/Snow-importable.modern.********************.js 4.26 kB 0 B
dotcom-rendering/dist/SpotifyBlockComponent-importable.modern.********************.js 5.17 kB 0 B
dotcom-rendering/dist/StickyBottomBanner-importable.modern.********************.js 3.95 kB 0 B
dotcom-rendering/dist/SubNav-importable.modern.********************.js 2.34 kB 0 B
dotcom-rendering/dist/SupportTheG-importable.modern.********************.js 5.68 kB 0 B
dotcom-rendering/dist/TableOfContents-importable.modern.********************.js 3.08 kB 0 B
dotcom-rendering/dist/TimelineAtomWrapper-importable.modern.********************.js 476 B 0 B
dotcom-rendering/dist/TopRightAdSlot-importable.modern.********************.js 631 B 0 B
dotcom-rendering/dist/TweetBlockComponent-importable.modern.********************.js 1 kB 0 B
dotcom-rendering/dist/UnsafeEmbedBlockComponent-importable.modern.********************.js 2.8 kB 0 B
dotcom-rendering/dist/VideoFacebookBlockComponent-importable.modern.********************.js 5.33 kB 0 B
dotcom-rendering/dist/VineBlockComponent-importable.modern.********************.js 2.64 kB 0 B
dotcom-rendering/dist/YoutubeBlockComponent-importable.modern.********************.js 4.05 kB 0 B

compressed-size-action

@mxdvl mxdvl 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.

Impressive!

Grouping with JS Map is very powerful and may simplify some of your grouping logic

EDIT: There’s an upcoming Array.prototype.group feature that will make grouping easier!

Comment thread dotcom-rendering/scripts/json-schema/check-schema.js Outdated
Comment thread dotcom-rendering/src/components/TagFrontHeader.tsx
Comment thread dotcom-rendering/src/model/groupTrailsByDates.ts Outdated
Comment thread dotcom-rendering/src/model/groupTrailsByDates.ts
Comment thread dotcom-rendering/scripts/json-schema/check-schema.js Outdated
Comment thread dotcom-rendering/src/components/DecideContainerByTrails.tsx
Comment thread dotcom-rendering/src/components/FrontPagination.tsx Outdated
Comment thread dotcom-rendering/src/components/FrontPagination.tsx Outdated
Comment thread dotcom-rendering/src/components/TagFrontHeader.tsx Outdated
Comment thread dotcom-rendering/src/components/TagFrontHeader.tsx
return fallback;
};

export const Sources = ({ sources }: { sources: ImageSource[] }) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not in the scope of this PR, but we could really do with a "generic" picture element 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was definitely thinking of this, I think it should be pretty easy to put together!

Comment thread dotcom-rendering/src/components/TagFrontPage.tsx Outdated
children: Array.from(node.childNodes).map(buildElementTree),
});
default:
return jsx(node.tagName.toLowerCase(), {

@DanielCliftonGuardian DanielCliftonGuardian Jun 22, 2023 •

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.

In order to use this we want to be pretty sure that we won't receive a tag that doesn't accept children. I.e none of these elements https://developer.mozilla.org/en-US/docs/Glossary/Void_element Otherwise this will break the page. So it could be safer to handle tags explicitly and return null if an unexpected tag is received.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I'm pretty sure we wont see any of these other elements, but I'll take a look at raising another PR in the future to refactor all this code to be more heavily re-used & avoid any potential errors like this!

Comment thread dotcom-rendering/src/components/FrontPagination.tsx Outdated
Comment thread dotcom-rendering/src/layouts/TagFrontLayout.tsx Outdated
Comment thread dotcom-rendering/src/model/extractTrendingTopics.ts
Comment thread dotcom-rendering/src/model/groupTrailsByDates.ts
Comment thread dotcom-rendering/src/model/slowOrFastByTrails.ts Outdated

@mxdvl mxdvl 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.

Amazing!

Left tiny comments below that are in no way blockers.

Comment thread dotcom-rendering/src/components/FrontPagination.tsx
Comment thread dotcom-rendering/src/components/FrontPagination.tsx Outdated
Comment on lines +141 to +143
// If there is a gap of more than 1 number between this entry and the last one
const shouldPrefixDots =
page > 1 && pageRange[index - 1] !== page - 1;

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.

Not sure if this is helpful in this case, but distance between two numbers can also be obtained by calculating the absolute value of the difference between them: Math.abs(page - pageRange[index - 1]) > 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In this case I don't think it does make a difference, but definitely helpful to know!

@OllysCoding
OllysCoding merged commit 7799fe9 into main Jun 26, 2023
@OllysCoding
OllysCoding deleted the olly/dcr-index-pages branch June 26, 2023 07:52
@mxdvl

mxdvl commented Jun 26, 2023 •

Copy link
Copy Markdown
Contributor

There are some visual small changes to the titles of tone title–has a line to the right–and the container titles–larger and bolder font.

Frontend DCR
f dcr

Comment on lines +169 to +172
trailsByDay.map(({ day, trails: dayTrails }) => ({
day,
trails: dayTrails,
})),

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.

I think this map does nothing 😉

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

Labels

dotcom-rendering run_chromatic Runs chromatic when label is applied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants