Skip to content

Commit

Permalink
Use tighter types on accent image
Browse files Browse the repository at this point in the history
  • Loading branch information
abeddow91 committed Dec 18, 2024
1 parent 4d98639 commit 0495064
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ export const Card = ({
accentImage={
showAccentImage &&
media?.type === 'podcast'
? media?.podcastImage?.src
: ''
? media?.podcastImage
: undefined
}
/>
{!isUndefined(starRating) ? (
Expand Down
3 changes: 2 additions & 1 deletion dotcom-rendering/src/components/CardHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from '../lib/articleFormat';
import { getZIndex } from '../lib/getZIndex';
import { palette } from '../palette';
import { PodcastSeriesImage } from '../types/tag';

Check failure on line 40 in dotcom-rendering/src/components/CardHeadline.tsx

View workflow job for this annotation

GitHub Actions / lint / check

All imports in the declaration are only used as types. Use `import type`
import { Byline } from './Byline';
import { Kicker } from './Kicker';
import { QuoteIcon } from './QuoteIcon';
Expand All @@ -62,7 +63,7 @@ type Props = {
/** Optional override of the standard card kicker colour */
kickerColour?: string;
isBetaContainer?: boolean;
accentImage?: string;
accentImage?: PodcastSeriesImage;
};

const sublinkStyles = css`
Expand Down
5 changes: 3 additions & 2 deletions dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ArticleDesign } from '../lib/articleFormat';
import { isMediaCard } from '../lib/cardHelpers';
import { palette } from '../palette';
import type { BoostLevel } from '../types/content';
Expand Down Expand Up @@ -223,7 +224,7 @@ export const SplashCardLayout = ({
showTopBarDesktop={false}
showTopBarMobile={true}
trailTextSize={trailTextSize}
showAccentImage={true}
showAccentImage={card.format.design === ArticleDesign.Audio}
/>
</LI>
</UL>
Expand Down Expand Up @@ -335,7 +336,7 @@ export const BoostedCardLayout = ({
showTopBarDesktop={false}
showTopBarMobile={true}
liveUpdatesPosition={liveUpdatesPosition}
showAccentImage={true}
showAccentImage={card.format.design === ArticleDesign.Audio}
/>
</LI>
</UL>
Expand Down
3 changes: 2 additions & 1 deletion dotcom-rendering/src/components/FlexibleSpecial.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ArticleDesign } from '../lib/articleFormat';
import { isMediaCard } from '../lib/cardHelpers';
import type { BoostLevel } from '../types/content';
import type {
Expand Down Expand Up @@ -166,7 +167,7 @@ export const OneCardLayout = ({
showTopBarDesktop={false}
showTopBarMobile={true}
trailTextSize={trailTextSize}
showAccentImage={true}
showAccentImage={card.format.design === ArticleDesign.Audio}
/>
</LI>
</UL>
Expand Down
9 changes: 5 additions & 4 deletions dotcom-rendering/src/components/Kicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { palette } from '../palette';
import { CardPicture } from './CardPicture';
import { Island } from './Island';
import { PulsingDot } from './PulsingDot.importable';
import { PodcastSeriesImage } from '../types/tag';

Check failure on line 12 in dotcom-rendering/src/components/Kicker.tsx

View workflow job for this annotation

GitHub Actions / lint / check

All imports in the declaration are only used as types. Use `import type`

Check failure on line 12 in dotcom-rendering/src/components/Kicker.tsx

View workflow job for this annotation

GitHub Actions / lint / check

`../types/tag` import should occur before import of `./CardPicture`

type Props = {
text: string;
Expand All @@ -18,7 +19,7 @@ type Props = {
isInline?: boolean;
/** Controls the weight of the standard, non-live kicker. Defaults to regular */
fontWeight?: 'regular' | 'bold';
accentImage?: string;
accentImage?: PodcastSeriesImage;
};

const standardTextStyles = css`
Expand Down Expand Up @@ -91,7 +92,7 @@ export const Kicker = ({
: 'transparent',
}}
>
{accentImage && (
{accentImage?.src && (

Check failure on line 95 in dotcom-rendering/src/components/Kicker.tsx

View workflow job for this annotation

GitHub Actions / lint / check

Potentially falsey string in logical AND expression. Please use boolean
<div
css={[
css`
Expand All @@ -101,9 +102,9 @@ export const Kicker = ({
]}
>
<CardPicture
mainImage={accentImage}
mainImage={accentImage.src}
imageSize={'small'}
alt={'media.imageAltText'} // TODO : pass through
alt={accentImage.altText}
loading={'lazy'}
aspectRatio={'1:1'}
/>
Expand Down

0 comments on commit 0495064

Please sign in to comment.