Skip to content
Open
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
6 changes: 6 additions & 0 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export type Props = {
headlinePosition?: 'inner' | 'outer';
starRatingSize?: RatingSizeType;
contentSpacing?: 'small' | 'large';
allowHeadlineToBreakWords?: boolean;
};

const waveformWrapper = (
Expand Down Expand Up @@ -410,6 +411,7 @@ export const Card = ({
starRatingSize = 'small',
articleMedia,
contentSpacing,
allowHeadlineToBreakWords,
}: Props) => {
const ab = useAB();
const isInLoopClickTestControl = Boolean(
Expand Down Expand Up @@ -857,6 +859,7 @@ export const Card = ({
byline={byline}
showByline={showByline}
isExternalLink={isExternalLink}
allowHeadlineToBreakWords={allowHeadlineToBreakWords}
/>
{!isUndefined(starRating) && (
<StarRating rating={starRating} size={starRatingSize} />
Expand Down Expand Up @@ -1157,6 +1160,9 @@ export const Card = ({
? media.podcastImage
: undefined
}
allowHeadlineToBreakWords={
allowHeadlineToBreakWords
}
/>

{!isUndefined(starRating) && (
Expand Down
14 changes: 14 additions & 0 deletions dotcom-rendering/src/components/CardHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type Props = {
kickerColour?: string;
quoteColour?: string;
kickerImage?: PodcastSeriesImage;
allowHeadlineToBreakWords?: boolean;
};

const sublinkStyles = css`
Expand Down Expand Up @@ -218,6 +219,15 @@ const defaultFontSizes: ResponsiveFontSize = {
mobile: 'xxsmall',
};

const allowWordBreakStyles = css`
@supports (overflow-wrap: anywhere) {
overflow-wrap: anywhere;
}
@supports not (overflow-wrap: anywhere) {
word-wrap: break-word;
}
`;

export const CardHeadline = ({
headlineText,
format,
Expand All @@ -234,6 +244,7 @@ export const CardHeadline = ({
kickerColour = palette('--card-kicker-text'),
quoteColour = palette('--card-quote-icon'),
kickerImage,
allowHeadlineToBreakWords = false,
}: Props) => {
// The link is only applied directly to the headline if it is a sublink
const isSublink = !!linkTo;
Expand All @@ -247,6 +258,9 @@ export const CardHeadline = ({
isSublink ? 'card-sublink-headline' : 'card-headline'
}`}
css={[
allowHeadlineToBreakWords
? allowWordBreakStyles
: undefined,
isSublink
? css`
${textSans14}
Expand Down
1 change: 1 addition & 0 deletions dotcom-rendering/src/components/Carousel.island.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ const CarouselCard = ({
showTopBarMobile={!isOnwardContent}
aspectRatio="5:4"
contentSpacing="small"
allowHeadlineToBreakWords={true}
/>
</LI>
);
Expand Down
Loading