Skip to content

Commit

Permalink
Tighten types
Browse files Browse the repository at this point in the history
  • Loading branch information
abeddow91 committed Dec 19, 2024
1 parent f187bb7 commit 2989b14
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dotcom-rendering/src/components/CardHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from '../lib/articleFormat';
import { getZIndex } from '../lib/getZIndex';
import { palette } from '../palette';
import { PodcastSeriesImage } from '../types/tag';
import type { PodcastSeriesImage } from '../types/tag';
import { Byline } from './Byline';
import { Kicker } from './Kicker';
import { QuoteIcon } from './QuoteIcon';
Expand Down
14 changes: 7 additions & 7 deletions dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type BoostedSplashProperties = {
const decideSplashCardProperties = (
boostLevel: BoostLevel,
supportingContentLength: number,
isMediaCard: boolean,
isAMediaCard: boolean,
): BoostedSplashProperties => {
switch (boostLevel) {
// boostedfont sizing
Expand All @@ -101,7 +101,7 @@ const decideSplashCardProperties = (
mobile: 'medium',
},
imagePositionOnDesktop: 'right',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'large',
supportingContentAlignment:
supportingContentLength >= 4 ? 'horizontal' : 'vertical',
Expand All @@ -116,7 +116,7 @@ const decideSplashCardProperties = (
mobile: 'large',
},
imagePositionOnDesktop: 'right',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment:
supportingContentLength >= 4 ? 'horizontal' : 'vertical',
Expand All @@ -130,8 +130,8 @@ const decideSplashCardProperties = (
tablet: 'xlarge',
mobile: 'xlarge',
},
imagePositionOnDesktop: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnDesktop: isAMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment: 'horizontal',
liveUpdatesAlignment: 'horizontal',
Expand All @@ -144,8 +144,8 @@ const decideSplashCardProperties = (
tablet: 'xlarge',
mobile: 'xxlarge',
},
imagePositionOnDesktop: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnDesktop: isAMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment: 'horizontal',
liveUpdatesAlignment: 'horizontal',
Expand Down
18 changes: 9 additions & 9 deletions dotcom-rendering/src/components/FlexibleSpecial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type BoostProperties = {
const determineCardProperties = (
boostLevel: BoostLevel,
supportingContentLength: number,
isMediaCard: boolean,
isAMediaCard: boolean,
): BoostProperties => {
switch (boostLevel) {
// The default boost level is equal to no boost. It is the same as the default card layout.
Expand All @@ -56,7 +56,7 @@ const determineCardProperties = (
mobile: 'medium',
},
imagePositionOnDesktop: 'right',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'large',
supportingContentAlignment:
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
Expand All @@ -72,7 +72,7 @@ const determineCardProperties = (
mobile: 'large',
},
imagePositionOnDesktop: 'right',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment:
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
Expand All @@ -86,8 +86,8 @@ const determineCardProperties = (
tablet: 'xlarge',
mobile: 'xlarge',
},
imagePositionOnDesktop: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnDesktop: isAMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment: 'horizontal',
liveUpdatesAlignment: 'horizontal',
Expand All @@ -100,8 +100,8 @@ const determineCardProperties = (
tablet: 'xxlarge',
mobile: 'xxlarge',
},
imagePositionOnDesktop: isMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isMediaCard ? 'top' : 'bottom',
imagePositionOnDesktop: isAMediaCard ? 'top' : 'bottom',
imagePositionOnMobile: isAMediaCard ? 'top' : 'bottom',
imageSize: 'jumbo',
supportingContentAlignment: 'horizontal',
liveUpdatesAlignment: 'horizontal',
Expand Down Expand Up @@ -177,9 +177,9 @@ export const OneCardLayout = ({

const getImagePosition = (
hasTwoOrFewerCards: boolean,
isMediaCard: boolean,
isAMediaCard: boolean,
) => {
if (isMediaCard && !hasTwoOrFewerCards) return 'top';
if (isAMediaCard && !hasTwoOrFewerCards) return 'top';
if (hasTwoOrFewerCards) return 'left';
return 'bottom';
};
Expand Down
5 changes: 3 additions & 2 deletions dotcom-rendering/src/components/Kicker.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { css } from '@emotion/react';
import { isUndefined } from '@guardian/libs';
import {
space,
textSans15,
textSansBold14,
textSansBold15,
} from '@guardian/source/foundations';
import { palette } from '../palette';
import type { PodcastSeriesImage } from '../types/tag';
import { CardPicture } from './CardPicture';
import { Island } from './Island';
import { PulsingDot } from './PulsingDot.importable';
import { PodcastSeriesImage } from '../types/tag';

type Props = {
text: string;
Expand Down Expand Up @@ -92,7 +93,7 @@ export const Kicker = ({
: 'transparent',
}}
>
{accentImage?.src && (
{!isUndefined(accentImage?.src) && (
<div
css={[
css`
Expand Down

0 comments on commit 2989b14

Please sign in to comment.