Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
81ef109
Rename existing starRating component to starRatingDeprecated so its e…
abeddow91 Dec 18, 2025
9672d42
Add a StarRating component with updated sizing and colours
abeddow91 Dec 18, 2025
e36fb29
Add a medium star rating size and update schemas
abeddow91 Dec 18, 2025
51da83b
Add variable padding to star ratings
abeddow91 Dec 18, 2025
d421aa1
Move block component colours into their own style object so they can …
abeddow91 Dec 18, 2025
1dd4b91
Conditionally render star rating in feature cards
abeddow91 Dec 18, 2025
9690404
Conditionally render star rating in card
abeddow91 Dec 18, 2025
c492113
Conditionally render star rating on cards in scrollables
abeddow91 Dec 18, 2025
1e04e10
Conditionally render star rating on cards in flexibles
abeddow91 Dec 18, 2025
95402da
Conditionally render star rating on cards in highlights
abeddow91 Dec 18, 2025
9a93acb
don't test on older containers as they're being deprecated
abeddow91 Dec 18, 2025
e461317
Conditionally render in articles
abeddow91 Dec 18, 2025
f5f3e25
Use dynamic sizing in card component
abeddow91 Dec 18, 2025
e5de4b3
Update padding in headline to reduce mobile bottom padding fro 28 to 20
abeddow91 Dec 18, 2025
b3561d4
Use dynamic sizing on feature cards for stars
abeddow91 Dec 18, 2025
237bcfc
Update star rating sizes for flexible containers
abeddow91 Dec 18, 2025
ee77e97
Make sure to use abtest not switch!
abeddow91 Dec 18, 2025
8a62e63
Conditionally render block component with background colours if user …
abeddow91 Dec 18, 2025
662bade
Conditionally render rich link if user is in variant
abeddow91 Dec 18, 2025
fd32eef
Conditionally render star rating on image block component if user is …
abeddow91 Dec 18, 2025
ed22394
fix linting
abeddow91 Dec 18, 2025
af17717
Make variant optional
abeddow91 Dec 18, 2025
1679a5e
Add missing variants
abeddow91 Dec 18, 2025
ddcd7b5
Add star rating dark theme param for switching to a darker palette fo…
abeddow91 Dec 18, 2025
41a9ca9
Fix linting
abeddow91 Dec 18, 2025
5136ca6
Use guardian space values where possible
abeddow91 Dec 18, 2025
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
45 changes: 40 additions & 5 deletions dotcom-rendering/src/components/ArticleHeadline.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { css } from '@emotion/react';
import { isUndefined } from '@guardian/libs';
import {
between,
from,
Expand Down Expand Up @@ -28,10 +29,12 @@ import {
} from '../lib/articleFormat';
import { getZIndex } from '../lib/getZIndex';
import { palette as themePalette } from '../palette';
import type { StarRating as Rating } from '../types/content';
import type { TagType } from '../types/tag';
import { AgeWarning } from './AgeWarning';
import { DesignTag } from './DesignTag';
import { HeadlineByline } from './HeadlineByline';
import { StarRating } from './StarRating/StarRating';

type Props = {
headlineString: string;
Expand All @@ -41,6 +44,8 @@ type Props = {
webPublicationDateDeprecated: string;
hasAvatar?: boolean;
isMatch?: boolean;
starRating?: Rating;
isInStarRatingVariant?: boolean;
};

const topPadding = css`
Expand Down Expand Up @@ -121,15 +126,13 @@ const headlineFont = (format: ArticleFormat) => {
if (format.design === ArticleDesign.Gallery) {
return css`
${decideMobileHeadlineFont(format)}

${from.desktop} {
${decideHeadlineFont(format)}
}
`;
}
return css`
${decideMobileHeadlineFont(format)}

${from.tablet} {
${decideHeadlineFont(format)}
}
Expand All @@ -138,6 +141,7 @@ const headlineFont = (format: ArticleFormat) => {

const invertedFontLineHeight = css`
line-height: 2.1875rem;

${from.tablet} {
line-height: 2.625rem;
}
Expand All @@ -146,6 +150,7 @@ const invertedFontLineHeight = css`
const labsFont = css`
${textSansBold28};
line-height: 2rem;

${from.tablet} {
${textSansBold34};
line-height: 2.375rem;
Expand All @@ -155,6 +160,7 @@ const labsFont = css`
const labsGalleryFont = css`
${textSansBold34};
line-height: 2.1875rem;

${from.desktop} {
${textSansBold34};
font-size: 50px;
Expand All @@ -166,6 +172,7 @@ const jumboLabsFont = css`
${textSansBold34};
font-size: 3.125rem;
line-height: 3.5rem;

${until.desktop} {
${textSansBold34};
line-height: 2.375rem;
Expand Down Expand Up @@ -203,12 +210,15 @@ const immersiveStyles = css`
min-height: 112px;
padding-bottom: ${space[6]}px;
padding-left: ${space[1]}px;

${from.mobileLandscape} {
padding-left: ${space[3]}px;
}

${from.tablet} {
padding-left: ${space[1]}px;
}

margin-right: ${space[5]}px;
`;

Expand Down Expand Up @@ -242,12 +252,15 @@ const immersiveWrapper = css`
Make sure we vertically align the headline font with the body font
*/
margin-left: 6px;

${from.tablet} {
margin-left: 16px;
}

${from.leftCol} {
margin-left: 25px;
}

/*
We need this grow to ensure the headline fills the main content column
*/
Expand All @@ -257,6 +270,7 @@ const immersiveWrapper = css`
box that extends the black background to the right
*/
z-index: ${getZIndex('articleHeadline')};

${until.mobileLandscape} {
margin-right: 40px;
}
Expand Down Expand Up @@ -352,6 +366,7 @@ const decideBottomPadding = ({
if (format.display === ArticleDisplay.Showcase) {
return css`
padding-bottom: ${space[1]}px;

${from.tablet} {
padding-bottom: ${space[6]}px;
}
Expand All @@ -364,7 +379,8 @@ const decideBottomPadding = ({
case ArticleDesign.Review: {
if (format.display === ArticleDisplay.Showcase) {
return css`
padding-bottom: 28px;
padding-bottom: ${space[5]}px;

${from.tablet} {
padding-bottom: ${space[6]}px;
}
Expand All @@ -383,7 +399,8 @@ const decideBottomPadding = ({
return hasAvatar
? ''
: css`
padding-bottom: 28px;
padding-bottom: ${space[5]}px;

${from.tablet} {
padding-bottom: ${space[9]}px;
}
Expand All @@ -396,7 +413,7 @@ const decideBottomPadding = ({
const galleryStyles = css`
${grid.between('grid-start', 'centre-column-end')}

grid-row: 7/9;
grid-row: 7 / 9;
position: relative;

${from.tablet} {
Expand All @@ -413,6 +430,8 @@ export const ArticleHeadline = ({
webPublicationDateDeprecated,
hasAvatar,
isMatch,
starRating,
isInStarRatingVariant,
}: Props) => {
switch (format.display) {
case ArticleDisplay.Immersive: {
Expand Down Expand Up @@ -496,6 +515,14 @@ export const ArticleHeadline = ({
{headlineString}
</span>
</h1>
{!isUndefined(starRating) &&
isInStarRatingVariant && (
<StarRating
rating={starRating}
paddingSize={'large'}
size={'large'}
/>
)}
</WithAgeWarning>
);
}
Expand Down Expand Up @@ -572,6 +599,14 @@ export const ArticleHeadline = ({
>
{headlineString}
</h1>
{!isUndefined(starRating) &&
isInStarRatingVariant && (
<StarRating
rating={starRating}
paddingSize={'medium'}
size={'large'}
/>
)}
</WithAgeWarning>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions dotcom-rendering/src/components/Caption.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Pillar,
} from '../lib/articleFormat';
import { Caption } from './Caption';
import { StarRating } from './StarRating/StarRating';
import { StarRatingDeprecated } from './StarRating/StarRatingDeprecated';

const meta = {
component: Caption,
Expand Down Expand Up @@ -191,7 +191,7 @@ export const WhenOverlaidWithStars = {
color: ${palette.neutral[7]};
`}
>
<StarRating rating={3} size="large" />
<StarRatingDeprecated rating={3} size="large" />
</div>
</>
),
Expand Down
46 changes: 32 additions & 14 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { DISCUSSION_ID_DATA_ATTRIBUTE } from '../../lib/useCommentCount';
import { BETA_CONTAINERS } from '../../model/enhanceCollections';
import { palette } from '../../palette';
import type { Branding } from '../../types/branding';
import type { StarRating as Rating } from '../../types/content';
import type { StarRating as Rating, RatingSizeType } from '../../types/content';
import type {
AspectRatio,
DCRContainerPalette,
Expand Down Expand Up @@ -50,6 +50,7 @@ import { SlideshowCarousel } from '../SlideshowCarousel.importable';
import { Snap } from '../Snap';
import { SnapCssSandbox } from '../SnapCssSandbox';
import { StarRating } from '../StarRating/StarRating';
import { StarRatingDeprecated } from '../StarRating/StarRatingDeprecated';
import type { Alignment } from '../SupportingContent';
import { SupportingContent } from '../SupportingContent';
import { SvgMediaControlsPlay } from '../SvgMediaControlsPlay';
Expand Down Expand Up @@ -163,6 +164,8 @@ export type Props = {
/** Determines if the headline should be positioned within the content or outside the content */
headlinePosition?: 'inner' | 'outer';
enableHls?: boolean;
isInStarRatingVariant?: boolean;
starRatingSize?: RatingSizeType;
};

const starWrapper = (cardHasImage: boolean) => css`
Expand All @@ -184,7 +187,7 @@ const StarRatingComponent = ({
cardHasImage: boolean;
}) => (
<div css={starWrapper(cardHasImage)}>
<StarRating rating={rating} size="small" />
<StarRatingDeprecated rating={rating} size="small" />
</div>
);

Expand Down Expand Up @@ -421,6 +424,8 @@ export const Card = ({
headlinePosition = 'inner',
subtitleSize = 'small',
enableHls = false,
isInStarRatingVariant,
starRatingSize = 'small',
}: Props) => {
const hasSublinks = supportingContent && supportingContent.length > 0;
const sublinkPosition = decideSublinkPosition(
Expand Down Expand Up @@ -908,12 +913,18 @@ export const Card = ({
showByline={showByline}
isExternalLink={isExternalLink}
/>
{!isUndefined(starRating) ? (
<StarRatingComponent
rating={starRating}
cardHasImage={!!image}
/>
) : null}
{!isUndefined(starRating) &&
(isInStarRatingVariant ? (
<StarRating
rating={starRating}
size={starRatingSize}
/>
) : (
<StarRatingComponent
rating={starRating}
cardHasImage={!!image}
/>
))}
</div>
)}

Expand Down Expand Up @@ -1237,12 +1248,19 @@ export const Card = ({
: undefined
}
/>
{!isUndefined(starRating) ? (
<StarRatingComponent
rating={starRating}
cardHasImage={!!image}
/>
) : null}

{!isUndefined(starRating) &&
(isInStarRatingVariant ? (
<StarRating
rating={starRating}
size={starRatingSize}
/>
) : (
<StarRatingComponent
rating={starRating}
cardHasImage={!!image}
/>
))}
</HeadlineWrapper>
)}

Expand Down
8 changes: 8 additions & 0 deletions dotcom-rendering/src/components/Carousel.importable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Props = {
discussionApiUrl: string;
serverTime?: number;
renderingTarget: RenderingTarget;
isInStarRatingVariant?: boolean;
};

type ArticleProps = Props & {
Expand Down Expand Up @@ -464,6 +465,7 @@ type CarouselCardProps = {
onwardsSource?: OnwardsSource;
containerType?: DCRContainerType;
starRating?: StarRating;
isInStarRatingVariant?: boolean;
};

const CarouselCard = ({
Expand All @@ -486,6 +488,7 @@ const CarouselCard = ({
serverTime,
starRating,
index,
isInStarRatingVariant,
}: CarouselCardProps) => {
const cardImagePosition = isOnwardContent ? 'bottom' : 'top';

Expand Down Expand Up @@ -533,6 +536,7 @@ const CarouselCard = ({
showTopBarDesktop={!isOnwardContent}
showTopBarMobile={!isOnwardContent}
aspectRatio={'5:4'}
isInStarRatingVariant={isInStarRatingVariant}
/>
</LI>
);
Expand Down Expand Up @@ -753,6 +757,7 @@ export const Carousel = ({
isOnwardContent = true,
serverTime,
renderingTarget,
isInStarRatingVariant,
...props
}: ArticleProps | FrontProps) => {
const carouselRef = useRef<HTMLUListElement>(null);
Expand Down Expand Up @@ -990,6 +995,9 @@ export const Carousel = ({
discussionApiUrl={discussionApiUrl}
isOnwardContent={isOnwardContent}
starRating={starRating}
isInStarRatingVariant={
isInStarRatingVariant
}
/>
);
})}
Expand Down
Loading
Loading