Skip to content

Commit 3c623cb

Browse files
authored
Merge pull request #14549 from guardian/feat/sponsored-content-label
Add Sponsored Content Label
2 parents acd3b99 + 6ab0642 commit 3c623cb

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { Meta } from '@storybook/react';
2+
import { SponsoredContentLabel } from './SponsoredContentLabel';
3+
4+
const meta: Meta<typeof SponsoredContentLabel> = {
5+
component: SponsoredContentLabel,
6+
title: 'Components/SponsoredContentLabel',
7+
parameters: {
8+
layout: 'centered',
9+
chromatic: {
10+
disable: true,
11+
},
12+
},
13+
args: {
14+
href: '#',
15+
imageSrc:
16+
'https://static.theguardian.com/commercial/sponsor/22/Aug/2025/52dc0276-c2d9-405c-a686-2577c12914d4-ecover_pos_280.png',
17+
ophanComponentName: 'example',
18+
},
19+
};
20+
21+
export default meta;
22+
23+
export const HorizontalOrientation = {
24+
args: {
25+
orientation: 'horizontal',
26+
},
27+
};
28+
29+
export const VerticalOrientation = {
30+
args: {
31+
orientation: 'vertical',
32+
},
33+
};
34+
35+
export const VerticalRightAlignment = {
36+
args: {
37+
alignment: 'end',
38+
orientation: 'vertical',
39+
},
40+
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { css } from '@emotion/react';
2+
import { space, textSansBold12 } from '@guardian/source/foundations';
3+
import { palette } from '../palette';
4+
import type { DCRBadgeType } from '../types/badge';
5+
import { Badge } from './Badge';
6+
7+
type SponsoredContentLabelProps = DCRBadgeType & {
8+
alignment?: 'start' | 'end';
9+
ophanComponentName: string;
10+
orientation?: 'horizontal' | 'vertical';
11+
};
12+
13+
const paidForByStyles = css`
14+
${textSansBold12};
15+
color: ${palette('--labs-header-label-text')};
16+
margin-top: ${space[3]}px;
17+
margin-bottom: ${space[1]}px;
18+
`;
19+
20+
const wrapperStyles = css`
21+
display: flex;
22+
gap: ${space[2]}px;
23+
`;
24+
25+
const horizontalStyles = css`
26+
align-items: center;
27+
`;
28+
29+
const verticalStyles = {
30+
start: css`
31+
flex-direction: column;
32+
`,
33+
end: css`
34+
align-items: end;
35+
flex-direction: column;
36+
`,
37+
};
38+
39+
export const SponsoredContentLabel = ({
40+
alignment = 'start',
41+
imageSrc,
42+
href,
43+
ophanComponentName,
44+
orientation = 'horizontal',
45+
}: SponsoredContentLabelProps) => {
46+
return (
47+
<div
48+
css={[
49+
wrapperStyles,
50+
orientation === 'vertical'
51+
? verticalStyles[alignment]
52+
: horizontalStyles,
53+
]}
54+
>
55+
<div css={paidForByStyles}>Paid for by</div>
56+
<Badge
57+
href={href}
58+
imageSrc={imageSrc}
59+
isInLabsSection={true}
60+
ophanComponentLink={`labs-logo | ${ophanComponentName}`}
61+
ophanComponentName={`labs-logo-${ophanComponentName}`}
62+
/>
63+
</div>
64+
);
65+
};

0 commit comments

Comments
 (0)