From 4cbca527ee90aa9f2b97ed71572fb69e64b22216 Mon Sep 17 00:00:00 2001 From: Emmanuel Enwenede Date: Mon, 1 Nov 2021 13:40:48 +0000 Subject: [PATCH 01/13] added back to top link to liveBlogPost --- .../x-live-blog-post/src/LiveBlogPost.jsx | 38 ++++++++++++++++++- .../x-live-blog-post/src/LiveBlogPost.scss | 23 +++++++++-- .../x-live-blog-post/src/ShareButtons.jsx | 15 +++++--- .../src/__tests__/LiveBlogPost.test.jsx | 22 +++++++++++ .../x-live-blog-post/storybook/index.jsx | 3 +- 5 files changed, 88 insertions(+), 13 deletions(-) diff --git a/components/x-live-blog-post/src/LiveBlogPost.jsx b/components/x-live-blog-post/src/LiveBlogPost.jsx index 709a822a1..dbdfde1a7 100644 --- a/components/x-live-blog-post/src/LiveBlogPost.jsx +++ b/components/x-live-blog-post/src/LiveBlogPost.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/no-static-element-interactions */ import { h } from '@financial-times/x-engine' import ShareButtons from './ShareButtons' import Timestamp from './Timestamp' @@ -17,11 +18,29 @@ const LiveBlogPost = (props) => { articleUrl, showShareButtons = false, byline, - ad + ad, + backToTop, + topRef } = props const showBreakingNewsLabel = standout.breakingNews || isBreakingNews + let backToTopProps = {} + + if (backToTop) { + backToTopProps = { + ...backToTopProps, + onClick: backToTop + } + } + + if (topRef) { + backToTopProps = { + ...backToTopProps, + href: topRef + } + } + return (
{ className={`${styles['live-blog-post__body']} n-content-body article--body`} dangerouslySetInnerHTML={{ __html: bodyHTML || content }} /> - {showShareButtons && } +
+ {showShareButtons && } + {(Boolean(backToTop) || Boolean(topRef)) && ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events + + Back to top + + )} +
+ {ad}
) diff --git a/components/x-live-blog-post/src/LiveBlogPost.scss b/components/x-live-blog-post/src/LiveBlogPost.scss index ca983ef58..803bf986e 100644 --- a/components/x-live-blog-post/src/LiveBlogPost.scss +++ b/components/x-live-blog-post/src/LiveBlogPost.scss @@ -54,10 +54,6 @@ padding-top: oSpacingByName('s1'); } -.live-blog-post__share-buttons { - margin-top: oSpacingByName('s6'); -} - .live-blog-post__breaking-news { @include oTypographySans($scale: -2); color: oColorsByName('crimson'); @@ -74,3 +70,22 @@ border-radius: 50%; background-color: oColorsByName('crimson'); } + +.live-blog-post__bottom-controls { + display: flex; + justify-content: space-between; + align-items: center; + flex-wrap: wrap; + margin-top: oSpacingByName('s6'); +} + +.live-blog-post__bottom-controls .back-to-top { + @include oTypographySans($scale: 1); + color: oColorsByName('teal'); + text-decoration: underline; + margin-left: auto; +} + +.live-blog-post__bottom-controls .back-to-top:hover { + cursor: pointer; +} diff --git a/components/x-live-blog-post/src/ShareButtons.jsx b/components/x-live-blog-post/src/ShareButtons.jsx index 0ed3ad888..9c6f3abce 100644 --- a/components/x-live-blog-post/src/ShareButtons.jsx +++ b/components/x-live-blog-post/src/ShareButtons.jsx @@ -1,5 +1,4 @@ import { h } from '@financial-times/x-engine' -import styles from './LiveBlogPost.scss' export default ({ postId, articleUrl, title }) => { const shareUrl = articleUrl ? new URL(articleUrl) : null @@ -18,18 +17,20 @@ export default ({ postId, articleUrl, title }) => { )}&title=${encodeURIComponent(title)}&source=Financial+Times` return ( -
+
+ className="o-share o-share--small" + >