Skip to content

Commit

Permalink
Merge branch 'main' into e2e/add-audio-player
Browse files Browse the repository at this point in the history
  • Loading branch information
sndrs authored Oct 22, 2024
2 parents 95f5374 + d7c47a2 commit 555ae58
Show file tree
Hide file tree
Showing 14 changed files with 483 additions and 150 deletions.
38 changes: 20 additions & 18 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ import type {
ImageSizeType,
} from './components/ImageWrapper';
import { ImageWrapper } from './components/ImageWrapper';
import {
type TrailTextSize,
TrailTextWrapper,
} from './components/TrailTextWrapper';
import { TrailText, type TrailTextSize } from './components/TrailText';

export type Position = 'inner' | 'outer' | 'none';

Expand Down Expand Up @@ -443,6 +440,20 @@ export const Card = ({
showLivePlayable,
});

const hideTrailTextUntil = () => {
if (isFlexibleContainer) {
return undefined;
} else if (
imageSize === 'large' &&
imagePositionOnDesktop === 'right' &&
media?.type !== 'avatar'
) {
return 'desktop';
} else {
return 'tablet';
}
};

/** Determines the gap of between card components based on card properties */
const getGapSize = (): GapSize => {
if (isOnwardContent) return 'none';
Expand Down Expand Up @@ -779,24 +790,15 @@ export const Card = ({
)}

{!!trailText && (
<TrailTextWrapper
imagePositionOnDesktop={
imagePositionOnDesktop
}
imageSize={imageSize}
imageType={media?.type}
shouldHide={isFlexSplash ? false : true}
<TrailText
trailText={trailText}
trailTextColour={trailTextColour}
trailTextSize={trailTextSize}
padTop={headlinePosition === 'inner'}
>
<div
dangerouslySetInnerHTML={{
__html: trailText,
}}
/>
</TrailTextWrapper>
hideUntil={hideTrailTextUntil()}
/>
)}

{!showCommentFooter && (
<CardFooter
format={format}
Expand Down
71 changes: 71 additions & 0 deletions dotcom-rendering/src/components/Card/components/TrailText.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { css } from '@emotion/react';
import {
from,
space,
textSans14,
textSans17,
} from '@guardian/source/foundations';
import { Hide } from '@guardian/source/react-components';
import { palette } from '../../../palette';

export type TrailTextSize = 'regular' | 'large';

type Props = {
trailText: string;
trailTextSize?: TrailTextSize;
/** Optionally overrides the trail text colour */
trailTextColour?: string;
/** Controls visibility of trail text on various breakpoints */
hideUntil?: 'tablet' | 'desktop';
/** Adds padding to the top of the trail text */
padTop: boolean;
};

const trailTextStyles = css`
display: flex;
flex-direction: column;
padding-bottom: ${space[2]}px;
`;

const topPadding = css`
padding-top: ${space[2]}px;
`;

const fontStyles = (trailTextSize: TrailTextSize) => css`
${textSans14}
${from.desktop} {
${trailTextSize === 'large' && textSans17}
}
strong {
font-weight: bold;
}
`;

export const TrailText = ({
trailText: text,
trailTextSize = 'regular',
trailTextColour = palette('--card-trail-text'),
hideUntil,
padTop,
}: Props) => {
const trailText = (
<div
css={[
trailTextStyles,
css`
color: ${trailTextColour};
`,
fontStyles(trailTextSize),
padTop && topPadding,
]}
dangerouslySetInnerHTML={{
__html: text,
}}
/>
);
return hideUntil ? (
<Hide until={hideUntil}>{trailText}</Hide>
) : (
<>{trailText}</>
);
};
106 changes: 0 additions & 106 deletions dotcom-rendering/src/components/Card/components/TrailTextWrapper.tsx

This file was deleted.

8 changes: 7 additions & 1 deletion dotcom-rendering/src/components/Elements.amp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ export const isAmpSupported = ({
if (!hasAmpInteractiveTag) return false;
}

if (tags.some((tag) => tag.id === 'type/video')) {
if (
tags.some(
(tag) =>
tag.id === 'type/video' ||
tag.id === 'thefilter/series/the-filter',
)
) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ImageSizeType,
} from './Card/components/ImageWrapper';
import { LI } from './Card/components/LI';
import type { TrailTextSize } from './Card/components/TrailTextWrapper';
import type { TrailTextSize } from './Card/components/TrailText';
import { UL } from './Card/components/UL';
import type { Loading } from './CardPicture';
import { FrontCard } from './FrontCard';
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/src/components/FlexibleSpecial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
ImageSizeType,
} from './Card/components/ImageWrapper';
import { LI } from './Card/components/LI';
import type { TrailTextSize } from './Card/components/TrailTextWrapper';
import type { TrailTextSize } from './Card/components/TrailText';
import { UL } from './Card/components/UL';
import type { Loading } from './CardPicture';
import { FrontCard } from './FrontCard';
Expand Down
22 changes: 22 additions & 0 deletions dotcom-rendering/src/components/UsEoy2024.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Meta, StoryObj } from '@storybook/react';
import { UsEoy2024 } from './UsEoy2024Wrapper.importable';

const meta = {
title: 'Components/UsEoy2024',
component: UsEoy2024,
} satisfies Meta<typeof UsEoy2024>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default = {
args: {
tickerData: {
total: 1000000,
goal: 2000000,
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
submitTrackingEvent: () => {},
},
} satisfies Story;
Loading

0 comments on commit 555ae58

Please sign in to comment.