11import { css } from '@emotion/react' ;
22import {
3+ between ,
4+ from ,
35 space ,
46 textSansBold12 ,
57 visuallyHidden ,
@@ -18,6 +20,8 @@ type SponsoredContentLabelProps = {
1820 containerPalette ?: DCRContainerPalette ;
1921 ophanComponentLink ?: string ;
2022 ophanComponentName ?: string ;
23+ isLabs ?: boolean ;
24+ isAdvertisingPartner ?: boolean ;
2125} ;
2226
2327const logoImageStyle = css `
@@ -65,6 +69,36 @@ const linkStyles = css`
6569 justify- content: center;
6670` ;
6771
72+ const badgeLink = css `
73+ text- decor ation: none;
74+ ` ;
75+
76+ const imageStyles = css `
77+ dis play: block;
78+ width: auto ;
79+ max- width: 100%;
80+ object- fit: contain;
81+ ` ;
82+
83+ const frontsSectionBadgeSizingStyles = css `
84+ height: auto ;
85+ width: 120px;
86+
87+ ${ from . tablet } {
88+ width: 140px;
89+ }
90+
91+ ${ from . leftCol } {
92+ width: 200px;
93+ }
94+ ` ;
95+
96+ const imageAdvertisingPartnerStyles = css `
97+ ${ between . leftCol . and . wide } {
98+ max- width: 130px;
99+ }
100+ ` ;
101+
68102/**
69103 * Component used to display "paid for" label alonside the sponsor logo
70104 * for a particular set of branding
@@ -79,64 +113,90 @@ export const SponsoredContentLabel = ({
79113 containerPalette,
80114 ophanComponentLink,
81115 ophanComponentName,
116+ isLabs = false ,
117+ isAdvertisingPartner = false ,
82118} : SponsoredContentLabelProps ) => {
83119 const { darkModeAvailable } = useConfig ( ) ;
84120 const logo = decideBrandingLogo ( branding , containerPalette ) ;
85121
86- return (
87- < div
88- css = { [
89- wrapperStyles ,
90- orientation === 'vertical'
91- ? verticalStyles [ alignment ]
92- : horizontalStyles ,
93- ] }
94- >
95- < div css = { labelStyles } > { logo . label } </ div >
96- < span
97- css = { css `
98- ${ visuallyHidden } ;
99- ` }
122+ if ( isLabs ) {
123+ return (
124+ < div
125+ css = { [
126+ wrapperStyles ,
127+ orientation === 'vertical'
128+ ? verticalStyles [ alignment ]
129+ : horizontalStyles ,
130+ ] }
100131 >
101- { branding . sponsorName
102- ? `This content was paid for by ${ branding . sponsorName } and produced by the Guardian Labs team.`
103- : 'This content has been paid for by an advertiser and produced by the Guardian Labs team.' }
104- </ span >
105- < a
106- css = { linkStyles }
107- href = { logo . link }
108- data-sponsor = { branding . sponsorName . toLowerCase ( ) }
109- rel = "nofollow"
110- aria-label = { `Visit the ${ branding . sponsorName } website` }
111- data-testid = "branding-logo"
112- data-component = { ophanComponentName }
113- data-link-name = { ophanComponentLink }
114- className = "branding-logo"
115- >
116- < picture >
117- { darkModeAvailable && branding . logoForDarkBackground && (
118- < source
119- width = {
120- branding . logoForDarkBackground . dimensions . width
121- }
122- height = {
123- branding . logoForDarkBackground . dimensions . height
124- }
125- srcSet = { encodeURI (
126- branding . logoForDarkBackground . src ,
132+ < div css = { labelStyles } > { logo . label } </ div >
133+
134+ < span
135+ css = { css `
136+ ${ visuallyHidden } ;
137+ ` }
138+ >
139+ { branding . sponsorName
140+ ? `This content was paid for by ${ branding . sponsorName } and produced by the Guardian Labs team.`
141+ : 'This content has been paid for by an advertiser and produced by the Guardian Labs team.' }
142+ </ span >
143+ < a
144+ css = { linkStyles }
145+ href = { logo . link }
146+ data-sponsor = { branding . sponsorName . toLowerCase ( ) }
147+ rel = "nofollow"
148+ aria-label = { `Visit the ${ branding . sponsorName } website` }
149+ data-testid = "branding-logo"
150+ data-component = { ophanComponentName }
151+ data-link-name = { ophanComponentLink }
152+ className = "branding-logo"
153+ >
154+ < picture >
155+ { darkModeAvailable &&
156+ branding . logoForDarkBackground && (
157+ < source
158+ width = {
159+ branding . logoForDarkBackground
160+ . dimensions . width
161+ }
162+ height = {
163+ branding . logoForDarkBackground
164+ . dimensions . height
165+ }
166+ srcSet = { encodeURI (
167+ branding . logoForDarkBackground . src ,
168+ ) }
169+ media = { '(prefers-color-scheme: dark)' }
170+ />
127171 ) }
128- media = { '(prefers-color-scheme: dark)' }
172+ < img
173+ css = { logoImageStyle }
174+ src = { logo . src }
175+ alt = { branding . sponsorName }
176+ width = { logo . dimensions . width }
177+ height = { logo . dimensions . height }
129178 />
130- ) }
131- < img
132- css = { logoImageStyle }
133- src = { logo . src }
134- alt = { branding . sponsorName }
135- width = { logo . dimensions . width }
136- height = { logo . dimensions . height }
137- />
138- </ picture >
139- </ a >
140- </ div >
179+ </ picture >
180+ </ a >
181+ </ div >
182+ ) ;
183+ }
184+ return (
185+ < a
186+ href = { logo . link }
187+ data-link-name = { ophanComponentLink }
188+ data-component = { ophanComponentName }
189+ css = { badgeLink }
190+ >
191+ < img
192+ css = { [
193+ imageStyles ,
194+ frontsSectionBadgeSizingStyles ,
195+ isAdvertisingPartner && imageAdvertisingPartnerStyles ,
196+ ] }
197+ src = { logo . src }
198+ alt = { '' }
199+ />
200+ </ a >
141201 ) ;
142202} ;
0 commit comments