Skip to content

Commit 8f10440

Browse files
authored
Merge pull request #13655 from guardian/doml/refactor/card-wrapper-top-bar
Refactor card wrapper top bar
2 parents c5bdedf + d5151de commit 8f10440

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

dotcom-rendering/src/components/Card/Card.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,7 @@ export const WithAFiveFourAspectRatio = () => {
14921492
</>
14931493
);
14941494
};
1495+
14951496
export const WithNoGap = () => {
14961497
return (
14971498
<>
@@ -1505,6 +1506,8 @@ export const WithNoGap = () => {
15051506
{...basicCardProps}
15061507
imagePositionOnDesktop="left"
15071508
isOnwardContent={true}
1509+
showTopBarDesktop={false}
1510+
showTopBarMobile={false}
15081511
format={{
15091512
display: ArticleDisplay.Standard,
15101513
design: ArticleDesign.Standard,
@@ -1629,6 +1632,8 @@ export const WithNoVerticalGap = () => {
16291632
<Card
16301633
{...basicCardProps}
16311634
isOnwardContent={true}
1635+
showTopBarDesktop={false}
1636+
showTopBarMobile={false}
16321637
imagePositionOnDesktop="bottom"
16331638
format={{
16341639
display: ArticleDisplay.Standard,

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ export const Card = ({
407407
index = 0,
408408
isFlexSplash,
409409
showTopBarDesktop = true,
410-
showTopBarMobile = false,
410+
showTopBarMobile = true,
411411
trailTextSize,
412412
showKickerImage = false,
413413
}: Props) => {
@@ -750,10 +750,10 @@ export const Card = ({
750750
return (
751751
<CardWrapper
752752
format={format}
753-
showTopBarDesktop={!isOnwardContent && showTopBarDesktop}
753+
showTopBarDesktop={showTopBarDesktop}
754754
showTopBarMobile={showTopBarMobile}
755-
containerPalette={containerPalette}
756755
isOnwardContent={isOnwardContent}
756+
containerPalette={containerPalette}
757757
>
758758
<CardLink
759759
linkTo={linkTo}

dotcom-rendering/src/components/Card/components/CardWrapper.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { css } from '@emotion/react';
2-
import { space, until } from '@guardian/source/foundations';
2+
import { from, space, until } from '@guardian/source/foundations';
33
import type { ArticleFormat } from '../../../lib/articleFormat';
44
import { palette } from '../../../palette';
55
import type { DCRContainerPalette } from '../../../types/front';
@@ -9,10 +9,10 @@ import { FormatBoundary } from '../../FormatBoundary';
99
type Props = {
1010
children: React.ReactNode;
1111
format: ArticleFormat;
12+
showTopBarDesktop: boolean;
13+
showTopBarMobile: boolean;
14+
isOnwardContent: boolean;
1215
containerPalette?: DCRContainerPalette;
13-
showTopBarDesktop?: boolean;
14-
showTopBarMobile?: boolean;
15-
isOnwardContent?: boolean;
1616
};
1717

1818
const baseCardStyles = css`
@@ -78,7 +78,9 @@ const mobileTopBarStyles = css`
7878
}
7979
`;
8080
const desktopTopBarStyles = css`
81-
${topBarStyles}
81+
${from.tablet} {
82+
${topBarStyles}
83+
}
8284
`;
8385

8486
const onwardContentStyles = css`
@@ -93,10 +95,10 @@ const onwardContentStyles = css`
9395
export const CardWrapper = ({
9496
children,
9597
format,
98+
showTopBarDesktop,
99+
showTopBarMobile,
100+
isOnwardContent,
96101
containerPalette,
97-
showTopBarDesktop = true,
98-
showTopBarMobile = false,
99-
isOnwardContent = false,
100102
}: Props) => {
101103
return (
102104
<FormatBoundary format={format}>

dotcom-rendering/src/components/Carousel.importable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ const CarouselCard = ({
548548
starRating={starRating}
549549
index={index}
550550
showTopBarDesktop={!isOnwardContent}
551-
showTopBarMobile={false}
551+
showTopBarMobile={!isOnwardContent}
552552
/>
553553
</LI>
554554
);

0 commit comments

Comments
 (0)