diff --git a/dotcom-rendering/src/components/Discussion/Badges.tsx b/dotcom-rendering/src/components/Discussion/Badges.tsx index 28baf814e9b..63a5016b913 100644 --- a/dotcom-rendering/src/components/Discussion/Badges.tsx +++ b/dotcom-rendering/src/components/Discussion/Badges.tsx @@ -33,7 +33,7 @@ const staffLabel = css` color: ${themePalette('--staff-label-color')}; `; const guardianPickLabel = css` - color: ${sourcePalette.neutral[7]}; + color: ${themePalette('--pick-label-color')}; `; export const GuardianStaff = () => ( diff --git a/dotcom-rendering/src/components/Discussion/Comment.stories.tsx b/dotcom-rendering/src/components/Discussion/Comment.stories.tsx index 8d5b1d33d88..1f8df6e2e8f 100644 --- a/dotcom-rendering/src/components/Discussion/Comment.stories.tsx +++ b/dotcom-rendering/src/components/Discussion/Comment.stories.tsx @@ -1,4 +1,5 @@ import { ArticleDesign, ArticleDisplay, Pillar } from '@guardian/libs'; +import { splitTheme } from '../../../.storybook/decorators/splitThemeDecorator'; import type { CommentType, SignedInUser } from '../../types/discussion'; import { Comment } from './Comment'; @@ -139,7 +140,7 @@ const staffUser: SignedInUser = { authStatus: { kind: 'SignedInWithCookies' }, }; -const format = { +const defaultFormat = { design: ArticleDesign.Standard, display: ArticleDisplay.Standard, theme: Pillar.News, @@ -148,7 +149,6 @@ const format = { export const Root = () => ( {}} isReply={false} @@ -164,14 +164,11 @@ Root.story = { chromatic: { viewports: [1300] }, }, }; +Root.decorators = [splitTheme([defaultFormat], { orientation: 'vertical' })]; export const RootMobile = () => ( {}} isReply={false} isClosedForComments={false} @@ -187,14 +184,21 @@ RootMobile.story = { chromatic: { viewports: [375] }, }, }; +RootMobile.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Sport, + }, + ], + { orientation: 'vertical' }, + ), +]; export const ReplyComment = () => ( {}} isReply={true} @@ -210,14 +214,21 @@ ReplyComment.story = { chromatic: { viewports: [1300] }, }, }; +ReplyComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), +]; export const MobileReply = () => ( {}} isReply={true} isClosedForComments={false} @@ -233,14 +244,21 @@ MobileReply.story = { chromatic: { viewports: [375] }, }, }; +MobileReply.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Culture, + }, + ], + { orientation: 'vertical' }, + ), +]; export const LongMobileReply = () => ( {}} isReply={true} isClosedForComments={false} @@ -256,14 +274,21 @@ LongMobileReply.story = { chromatic: { viewports: [375] }, }, }; +LongMobileReply.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Culture, + }, + ], + { orientation: 'vertical' }, + ), +]; export const LongBothMobileReply = () => ( {}} isReply={true} isClosedForComments={false} @@ -279,6 +304,17 @@ LongBothMobileReply.story = { chromatic: { viewports: [375] }, }, }; +LongBothMobileReply.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Culture, + }, + ], + { orientation: 'vertical' }, + ), +]; export const PickedComment = () => ( ( ...commentData, isHighlighted: true, }} - format={format} isClosedForComments={false} setCommentBeingRepliedTo={() => {}} isReply={false} @@ -296,14 +331,21 @@ export const PickedComment = () => ( /> ); PickedComment.storyName = 'Picked Comment'; +PickedComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Culture, + }, + ], + { orientation: 'vertical' }, + ), +]; export const StaffUserComment = () => ( {}} isReply={false} @@ -313,14 +355,21 @@ export const StaffUserComment = () => ( /> ); StaffUserComment.storyName = 'Staff User Comment'; +StaffUserComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Opinion, + }, + ], + { orientation: 'vertical' }, + ), +]; export const ContributorUserComment = () => ( {}} isReply={false} @@ -330,6 +379,17 @@ export const ContributorUserComment = () => ( /> ); ContributorUserComment.storyName = 'Contributor User Comment'; +ContributorUserComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Opinion, + }, + ], + { orientation: 'vertical' }, + ), +]; export const PickedStaffUserComment = () => ( ( ...commentStaffData, isHighlighted: true, }} - format={format} isClosedForComments={false} setCommentBeingRepliedTo={() => {}} isReply={false} @@ -353,6 +412,9 @@ PickedStaffUserComment.story = { chromatic: { viewports: [1300] }, }, }; +PickedStaffUserComment.decorators = [ + splitTheme([defaultFormat], { orientation: 'vertical' }), +]; export const PickedStaffUserCommentMobile = () => ( ( ...commentStaffData, isHighlighted: true, }} - format={{ - ...format, - theme: Pillar.Sport, - }} isClosedForComments={false} setCommentBeingRepliedTo={() => {}} isReply={false} @@ -380,6 +438,17 @@ PickedStaffUserCommentMobile.story = { chromatic: { viewports: [375] }, }, }; +PickedStaffUserCommentMobile.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Sport, + }, + ], + { orientation: 'vertical' }, + ), +]; export const ContributorUserCommentDesktop = () => ( ( ...commentContributorData, isHighlighted: true, }} - format={format} isClosedForComments={false} setCommentBeingRepliedTo={() => {}} isReply={false} @@ -404,6 +472,9 @@ ContributorUserCommentDesktop.story = { chromatic: { viewports: [1300] }, }, }; +ContributorUserCommentDesktop.decorators = [ + splitTheme([defaultFormat], { orientation: 'vertical' }), +]; export const ContributorUserCommentMobile = () => ( ( ...commentContributorData, isHighlighted: true, }} - format={{ - ...format, - theme: Pillar.Sport, - }} isClosedForComments={false} setCommentBeingRepliedTo={() => {}} isReply={false} @@ -431,14 +498,21 @@ ContributorUserCommentMobile.story = { chromatic: { viewports: [375] }, }, }; +ContributorUserCommentMobile.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Sport, + }, + ], + { orientation: 'vertical' }, + ), +]; export const LoggedInAsModerator = () => ( {}} user={staffUser} @@ -449,14 +523,21 @@ export const LoggedInAsModerator = () => ( /> ); LoggedInAsModerator.storyName = 'Logged in as moderator'; +LoggedInAsModerator.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), +]; export const LoggedInAsUser = () => ( {}} user={user} @@ -467,14 +548,21 @@ export const LoggedInAsUser = () => ( /> ); LoggedInAsUser.storyName = 'Logged in as normal user'; +LoggedInAsUser.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), +]; export const BlockedComment = () => ( {}} isReply={false} @@ -484,14 +572,21 @@ export const BlockedComment = () => ( /> ); BlockedComment.storyName = 'Blocked comment'; +BlockedComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Culture, + }, + ], + { orientation: 'vertical' }, + ), +]; export const MutedComment = () => ( {}} isReply={false} @@ -501,11 +596,21 @@ export const MutedComment = () => ( /> ); MutedComment.storyName = 'Muted comment'; +MutedComment.decorators = [ + splitTheme( + [ + { + ...defaultFormat, + theme: Pillar.Sport, + }, + ], + { orientation: 'vertical' }, + ), +]; export const ClosedForComments = () => ( {}} isReply={false} @@ -521,3 +626,6 @@ ClosedForComments.story = { chromatic: { viewports: [1300] }, }, }; +ClosedForComments.decorators = [ + splitTheme([defaultFormat], { orientation: 'vertical' }), +]; diff --git a/dotcom-rendering/src/components/Discussion/Comment.tsx b/dotcom-rendering/src/components/Discussion/Comment.tsx index df3401b3a2c..3e4f6446657 100644 --- a/dotcom-rendering/src/components/Discussion/Comment.tsx +++ b/dotcom-rendering/src/components/Discussion/Comment.tsx @@ -9,9 +9,9 @@ import { } from '@guardian/source-foundations'; import { Button, Link, SvgIndent } from '@guardian/source-react-components'; import { useState } from 'react'; -import { decidePalette } from '../../lib/decidePalette'; import { pickComment, unPickComment } from '../../lib/discussionApi'; import { createAuthenticationEventParams } from '../../lib/identity-component-event'; +import { palette as schemedPalette } from '../../palette'; import type { CommentType, SignedInUser } from '../../types/discussion'; import { AbuseReportForm } from './AbuseReportForm'; import { Avatar } from './Avatar'; @@ -24,7 +24,6 @@ import { Timestamp } from './Timestamp'; type Props = { user?: SignedInUser; comment: CommentType; - format: ArticleFormat; isClosedForComments: boolean; setCommentBeingRepliedTo: (commentBeingRepliedTo?: CommentType) => void; isReply: boolean; @@ -35,13 +34,13 @@ type Props = { onRecommend?: (commentId: number) => Promise; }; -const commentControlsLink = (format: ArticleFormat) => css` +const commentControlsLink = css` margin-top: -2px; a { ${textSans.small({ fontWeight: 'bold' })} margin-right: ${space[2]}px; - color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; /* We do not want underline to be applied to SVG therefore we override the styles and apply them to the nested @@ -50,10 +49,9 @@ const commentControlsLink = (format: ArticleFormat) => css` text-decoration: none; text-decoration-color: none; span { - color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; text-decoration: underline; - text-decoration-color: ${decidePalette(format) - .discussionGeneric}; + text-decoration-color: ${schemedPalette('--discussion-colour')}; } } } @@ -109,7 +107,7 @@ const blockedCommentStyles = css` // to override a tag styles from dangerouslySetInnerHTML const commentLinkStyling = css` a { - color: ${sourcePalette.brand[500]}; + color: ${schemedPalette('--discussion-link')}; text-decoration: none; :hover { text-decoration: underline; @@ -139,13 +137,13 @@ const avatarMargin = css` } `; -const colourStyles = (format: ArticleFormat) => css` +const colourStyles = css` a { - color: ${decidePalette(format).discussionGeneric}; - text-decoration-color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; + text-decoration-color: ${schemedPalette('--discussion-colour')}; :hover { - color: ${decidePalette(format).discussionGeneric}; - text-decoration-color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; + text-decoration-color: ${schemedPalette('--discussion-colour')}; } } `; @@ -225,9 +223,9 @@ const cssReplyToWrapper = css` } `; -const buttonLinkPillarBaseStyles = (format: ArticleFormat) => css` +const buttonLinkPillarBaseStyles = css` button { - color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; background-color: transparent; height: 18px; min-height: 18px; @@ -236,7 +234,7 @@ const buttonLinkPillarBaseStyles = (format: ArticleFormat) => css` :hover { text-decoration: underline; - text-decoration-color: ${decidePalette(format).discussionGeneric}; + text-decoration-color: ${schemedPalette('--discussion-colour')}; } } `; @@ -294,7 +292,6 @@ const Space = ({ amount }: { amount: 1 | 2 | 3 | 4 | 5 | 6 | 9 | 12 | 24 }) => ( export const Comment = ({ comment, - format, isClosedForComments, setCommentBeingRepliedTo, user, @@ -400,7 +397,7 @@ export const Comment = ({
( ( ); defaultStory.storyName = 'default'; defaultStory.decorators = [ - lightDecorator([ - { - ...format, - theme: Pillar.Lifestyle, - }, - ]), + splitTheme( + [ + { + ...format, + theme: Pillar.Sport, + }, + ], + { orientation: 'vertical' }, + ), ]; export const threadedComment = () => ( ( ); threadedComment.storyName = 'threaded'; threadedComment.decorators = [ - lightDecorator([ - { - ...format, - theme: Pillar.Lifestyle, - }, - ]), + splitTheme( + [ + { + ...format, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), ]; export const threadedCommentWithShowMore = () => ( ( ); threadedCommentWithShowMore.storyName = 'threaded with show more button'; threadedCommentWithShowMore.decorators = [ - lightDecorator([ - { - ...format, - theme: Pillar.Lifestyle, - }, - ]), + splitTheme( + [ + { + ...format, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), ]; export const threadedCommentWithLongUsernames = () => ( ( ); threadedCommentWithLongUsernames.storyName = 'threaded with long usernames'; threadedCommentWithLongUsernames.decorators = [ - lightDecorator([ - { - ...format, - theme: Pillar.Lifestyle, - }, - ]), + splitTheme( + [ + { + ...format, + theme: Pillar.Lifestyle, + }, + ], + { orientation: 'vertical' }, + ), ]; export const threadedCommentWithLongUsernamesMobile = () => ( { it('Post a comment to a root comment', async () => { const newCommentText = 'A brand new comment'; @@ -65,7 +58,6 @@ describe('CommentContainer', () => { { { { css` export const CommentContainer = ({ comment, - format, isClosedForComments, user, shortUrl, @@ -124,7 +122,6 @@ export const CommentContainer = ({
( - + ); Default.storyName = 'default'; +Default.decorators = [splitTheme([defaultFormat])]; export const SingleLinePreview = () => (
@@ -75,6 +76,7 @@ export const SingleLinePreview = () => (
); SingleLinePreview.storyName = 'Single line'; +SingleLinePreview.decorators = [splitTheme([defaultFormat])]; export const SingleBlockPreview = () => (
@@ -89,6 +91,7 @@ export const SingleBlockPreview = () => (
); SingleBlockPreview.storyName = 'Single Block'; +SingleBlockPreview.decorators = [splitTheme([defaultFormat])]; export const MultiBlockPreview = () => (
@@ -103,3 +106,4 @@ export const MultiBlockPreview = () => (
); MultiBlockPreview.storyName = 'Multi Block'; +MultiBlockPreview.decorators = [splitTheme([defaultFormat])]; diff --git a/dotcom-rendering/src/components/Discussion/CommentReplyPreview.tsx b/dotcom-rendering/src/components/Discussion/CommentReplyPreview.tsx index 2f77359796a..a4d8d8c6b43 100644 --- a/dotcom-rendering/src/components/Discussion/CommentReplyPreview.tsx +++ b/dotcom-rendering/src/components/Discussion/CommentReplyPreview.tsx @@ -2,17 +2,15 @@ import { css } from '@emotion/react'; import { palette as sourcePalette, space, - text, textSans, } from '@guardian/source-foundations'; import { Button, SvgIndent } from '@guardian/source-react-components'; import { useState } from 'react'; -import { decidePalette } from '../../lib/decidePalette'; +import { palette as schemedPalette } from '../../palette'; import type { CommentType } from '../../types/discussion'; import { Row } from './Row'; type Props = { - format: ArticleFormat; commentBeingRepliedTo: CommentType; }; @@ -44,13 +42,13 @@ const replyPreviewHeaderStyle = css` `; const arrowSize = 15; -const bg = sourcePalette.neutral[93]; + const previewStyle = css` padding-top: ${space[3]}px; padding-bottom: ${space[3]}px; padding-left: ${space[5]}px; padding-right: ${space[5]}px; - background-color: ${bg}; + background-color: ${schemedPalette('--top-pick-background')}; margin-top: ${arrowSize}px; margin-bottom: ${arrowSize + 5}px; position: relative; @@ -59,7 +57,8 @@ const previewStyle = css` :before { content: ''; position: absolute; - border-left: ${arrowSize}px solid ${bg}; + border-left: ${arrowSize}px solid + ${schemedPalette('--top-pick-background')}; border-top: ${arrowSize}px solid transparent; top: -${arrowSize - 1}px; margin-left: ${space[9]}px; @@ -75,12 +74,12 @@ const commentStyles = css` `; const blueLink = css` - color: ${text.anchorPrimary}; + color: ${schemedPalette('--discussion-link')}; `; -const buttonLinkPillarBaseStyles = (format: ArticleFormat) => css` +const buttonLinkPillarBaseStyles = css` button { - color: ${decidePalette(format).discussionGeneric}; + color: ${schemedPalette('--discussion-colour')}; background-color: transparent; height: 18px; min-height: 18px; @@ -89,7 +88,7 @@ const buttonLinkPillarBaseStyles = (format: ArticleFormat) => css` :hover { text-decoration: underline; - text-decoration-color: ${decidePalette(format).discussionGeneric}; + text-decoration-color: ${schemedPalette('--discussion-colour')}; } } `; @@ -110,10 +109,7 @@ const buttonLinkBaseStyles = css` } `; -export const CommentReplyPreview = ({ - format, - commentBeingRepliedTo, -}: Props) => { +export const CommentReplyPreview = ({ commentBeingRepliedTo }: Props) => { const [displayReplyComment, setDisplayReplyComment] = useState(false); return ( @@ -129,7 +125,7 @@ export const CommentReplyPreview = ({
(
); LoggedOutHiddenPicks.storyName = 'when logged out, unexpanded and with picks'; +LoggedOutHiddenPicks.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Culture, + }, + ]), +]; export const InitialPage = () => (
(
); InitialPage.storyName = 'with initial page set to 3'; +InitialPage.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Lifestyle, + }, + ]), +]; export const Overrides = () => (
(
); Overrides.storyName = 'with page size overridden to 50'; +Overrides.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Opinion, + }, + ]), +]; export const LoggedInHiddenNoPicks = () => (
( ); LoggedInHiddenNoPicks.storyName = 'when logged in, with no picks and not expanded'; +LoggedInHiddenNoPicks.decorators = [splitTheme([format])]; export const LoggedIn = () => (
(
); LoggedIn.storyName = 'when logged in and expanded'; +LoggedIn.decorators = [lightDecorator([format])]; export const LoggedInShortDiscussion = () => (
(
); LoggedInShortDiscussion.storyName = 'when logged in but only two comments made'; +LoggedInShortDiscussion.decorators = [splitTheme([format])]; export const LoggedOutHiddenNoPicks = () => (
( ); LoggedOutHiddenNoPicks.storyName = 'when logged out, with no picks and not expanded'; +LoggedOutHiddenNoPicks.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Sport, + }, + ]), +]; export const Closed = () => (
(
); Closed.storyName = 'Logged in but closed for comments'; +Closed.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Lifestyle, + }, + ]), +]; export const NoComments = () => (
(
); NoComments.storyName = 'when no comments have been made'; +NoComments.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Culture, + }, + ]), +]; export const LegacyDiscussion = () => (
(
); LegacyDiscussion.storyName = "a legacy discussion that doesn't allow threading"; +LegacyDiscussion.decorators = [ + splitTheme([ + { + ...format, + theme: Pillar.Culture, + }, + ]), +]; diff --git a/dotcom-rendering/src/components/Discussion/Comments.tsx b/dotcom-rendering/src/components/Discussion/Comments.tsx index 6ed3362ed61..7fa4d8a56bd 100644 --- a/dotcom-rendering/src/components/Discussion/Comments.tsx +++ b/dotcom-rendering/src/components/Discussion/Comments.tsx @@ -419,7 +419,6 @@ export const Comments = ({
  • sourcePalette.brand[800]; const staffLabelLight: PaletteFunction = () => sourcePalette.brand[400]; const staffLabelDark: PaletteFunction = () => sourcePalette.brand[600]; +const staffPickLight: PaletteFunction = () => sourcePalette.neutral[7]; +const staffPickDark: PaletteFunction = () => sourcePalette.neutral[97]; + const recommendationCountLight: PaletteFunction = () => sourcePalette.neutral[97]; const recommendationCountDark: PaletteFunction = () => @@ -4342,7 +4345,7 @@ const discussionDark: PaletteFunction = ({ theme }) => { }; const discussionLinkLight: PaletteFunction = () => sourcePalette.brand[500]; -const discussionLinkDark: PaletteFunction = () => sourcePalette.neutral[100]; +const discussionLinkDark: PaletteFunction = () => sourcePalette.brand[800]; const discussionPrimaryButtonBackground: PaletteFunction = ({ theme }) => { switch (theme) { @@ -5094,6 +5097,10 @@ const paletteColours = { light: staffLabelLight, dark: staffLabelDark, }, + '--pick-label-color': { + light: staffPickLight, + dark: staffPickDark, + }, '--recommendation-count': { light: recommendationCountLight, dark: recommendationCountDark,