Skip to content

Commit 3bb78f7

Browse files
committed
use CSS to show/hide the correct component configuration for SponsoredContentLabel based on viewport size
1 parent 3e4cb4f commit 3bb78f7

File tree

1 file changed

+41
-6
lines changed
  • dotcom-rendering/src/components/Card

1 file changed

+41
-6
lines changed

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

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { css } from '@emotion/react';
22
import { isUndefined } from '@guardian/libs';
33
import {
4+
between,
45
from,
56
palette as sourcePalette,
67
space,
8+
until,
79
} from '@guardian/source/foundations';
810
import { Hide, Link, SvgCamera } from '@guardian/source/react-components';
911
import {
@@ -753,12 +755,45 @@ export const Card = ({
753755
: undefined;
754756

755757
return showLabsRedesign ? (
756-
<SponsoredContentLabel
757-
branding={branding}
758-
containerPalette={containerPalette}
759-
ophanComponentLink={dataAttributes?.ophanComponentLink}
760-
ophanComponentName={dataAttributes?.ophanComponentName}
761-
/>
758+
<>
759+
{/** All screen sizes apart from tablet have horizontal orientation */}
760+
<div
761+
css={css`
762+
${between.tablet.and.desktop} {
763+
display: none;
764+
}
765+
`}
766+
>
767+
<SponsoredContentLabel
768+
branding={branding}
769+
containerPalette={containerPalette}
770+
orientation="horizontal"
771+
alignment="end"
772+
ophanComponentLink={dataAttributes?.ophanComponentLink}
773+
ophanComponentName={dataAttributes?.ophanComponentName}
774+
/>
775+
</div>
776+
{/** Tablet sized screens have vertical orientation */}
777+
<div
778+
css={css`
779+
${until.tablet} {
780+
display: none;
781+
}
782+
${from.desktop} {
783+
display: none;
784+
}
785+
`}
786+
>
787+
<SponsoredContentLabel
788+
branding={branding}
789+
containerPalette={containerPalette}
790+
orientation="vertical"
791+
alignment="end"
792+
ophanComponentLink={dataAttributes?.ophanComponentLink}
793+
ophanComponentName={dataAttributes?.ophanComponentName}
794+
/>
795+
</div>
796+
</>
762797
) : (
763798
<CardBranding
764799
branding={branding}

0 commit comments

Comments
 (0)