Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotcom-rendering/src/client/inline1SdcListener.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Inline1Props } from '@guardian/support-dotcom-components/dist/shared/types/props/inline1';
import { act, screen, waitFor } from '@testing-library/react';
import {
props as inline1Props,
supportProps as inline1Props,
newsletterProps,
} from '../components/marketing/inline1/utils/storybook';
import type { Config } from '../types/configContext';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css } from '@emotion/react';
import type { Meta, StoryObj } from '@storybook/react-webpack5';
import lzstring from 'lz-string';
import { SupporterRevenue } from './SupporterRevenue';
import { props } from './utils/storybook';
import { supportProps } from './utils/storybook';

const style = css`
max-width: 620px;
Expand All @@ -14,7 +14,7 @@ type Props = WithJsonProps<React.ComponentProps<typeof SupporterRevenue>>;
const meta: Meta<Props> = {
component: SupporterRevenue,
title: 'Components/marketing/inline1/SupporterRevenue',
args: props,
args: supportProps,
render: ({ json, ...args }) => {
const jsonProps = json
? JSON.parse(lzstring.decompressFromEncodedURIComponent(json))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { useEffect } from 'react';
import sanitize from 'sanitize-html';
import { useIsInView } from '../../../lib/useIsInView';
import type { ReactComponent } from '../lib/ReactComponent';
import type { ImageAttrs } from '../shared/ResponsiveImage';
import { ResponsiveImage } from '../shared/ResponsiveImage';
import { recordInline1View } from './utils/viewCount';

const outerContainerStyles = css`
Expand Down Expand Up @@ -68,6 +70,7 @@ const bodyStyles = css`
${textSans15};
${from.tablet} {
grid-area: body;
margin-bottom: 28px;
}
`;

Expand Down Expand Up @@ -95,16 +98,23 @@ const ctaButtonStyles = css`
const imageWrapperStyles = css`
display: flex;
align-items: flex-end;
height: 144px;
${from.tablet} {
grid-area: image;
}
`;

const imageStyles = css`
height: 131px;
width: 164px;
object-fit: cover;
img {
object-fit: cover;
height: 126px;
width: 157px;
}

${until.tablet} {
img {
width: 210px;
}
}
`;

// This is used to sanitize the HTML for the title
Expand Down Expand Up @@ -133,6 +143,34 @@ export const SupporterRevenue: ReactComponent<Inline1Props> = ({
const image = variant.message.image;
const cta = variant.message.primaryCta;

const images: ImageAttrs[] = [];
const baseImage = {
url: image?.desktopUrl ?? '',
media: '',
alt: image?.altText ?? '',
};

if (image) {
if (image.mobileUrl !== undefined && image.mobileUrl.length > 0) {
images.push({
url: image.mobileUrl,
media: '(max-width: 739px)',
});
}
if (image.tabletUrl !== undefined && image.tabletUrl.length > 0) {
images.push({
url: image.tabletUrl,
media: '(max-width: 979px)',
});
}
if (image.desktopUrl !== undefined && image.desktopUrl.length > 0) {
images.push({
url: image.desktopUrl,
media: '',
});
}
}

return (
<section
css={outerContainerStyles}
Expand All @@ -145,11 +183,11 @@ export const SupporterRevenue: ReactComponent<Inline1Props> = ({
</div>
{image && (
<div css={imageWrapperStyles}>
<img
src={image.desktopUrl}
css={imageStyles}
alt={image.altText}
/>
<ResponsiveImage
cssOverrides={imageStyles}
images={images}
baseImage={baseImage}
></ResponsiveImage>
</div>
)}
<h2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import type { Inline1Variant } from '@guardian/support-dotcom-components/dist/shared/types';
import type { Inline1Props } from '@guardian/support-dotcom-components/dist/shared/types/props/inline1';

const variant = {
name: 'Inline1SupportMessage',
const supportVariant = {
name: 'CONTROL',
message: {
type: 'Inline1SupportMessage' as const,
heading: 'Two-line headline for the primary messaging ',
body: 'Lorem ipsum dolor sit amet consectetur adipiscing elit non autem quo est ullamco laboris consequat duis sunt et.',
heading: 'Headline - 48 characters, including spaces and punctuation.',
body: 'Lorem ipsum dolor sit amet. Supporting copy should be 136 characters, including spaces and punctuation.',
primaryCta: {
baseUrl: '#',
text: 'Primary md',
text: 'Try Feast app',
baseUrl:
'https://www.theguardian.com/info/2025/jan/02/feast-the-app-to-avoid-boring-cooking',
},
image: {
mainUrl:
'https://uploads.guim.co.uk/2025/06/12/not_for_sale_bg_scaled.svg',
mobileUrl:
'https://uploads.guim.co.uk/2025/06/12/not_for_sale_bg_scaled.svg',
'https://i.guim.co.uk/img/media/d5fd46298bb30b3f4779a625df0a1c1054431474/68_428_3058_3819/master/3058.jpg?width=210&dpr=2&s=none',
tabletUrl:
'https://uploads.guim.co.uk/2025/06/12/not_for_sale_bg_scaled.svg',
'https://i.guim.co.uk/img/media/d5fd46298bb30b3f4779a625df0a1c1054431474/68_428_3058_3819/master/3058.jpg?width=157&dpr=2&s=none',
desktopUrl:
'https://uploads.guim.co.uk/2025/06/12/not_for_sale_bg_scaled.svg',
altText: 'Optional img',
'https://i.guim.co.uk/img/media/d5fd46298bb30b3f4779a625df0a1c1054431474/68_428_3058_3819/master/3058.jpg?width=157&dpr=2&s=none',
altText: 'Feast app download',
},
},
};
Expand Down Expand Up @@ -51,8 +50,8 @@ export const tracking = {
referrerUrl: '',
};

export const props: Inline1Props = {
variant,
export const supportProps: Inline1Props = {
variant: supportVariant,
tracking,
};

Expand Down
Loading