Skip to content

Commit

Permalink
Revert "[Fairground 🎡] Redesign sublinks as grid layout (#12346)" (#1…
Browse files Browse the repository at this point in the history
…2431)

This reverts commit 531a63a.
  • Loading branch information
cemms1 committed Sep 20, 2024
1 parent 531a63a commit ae9de73
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 195 deletions.
59 changes: 12 additions & 47 deletions dotcom-rendering/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,6 @@ const StarRatingComponent = ({
</div>
);

const HorizontalDivider = () => (
<div
css={css`
${from.tablet} {
border-top: 1px solid ${themePalette('--card-border-top')};
height: 1px;
width: 50%;
${from.tablet} {
width: 100px;
}
${from.desktop} {
width: 140px;
}
margin-top: ${space[3]}px;
}
`}
/>
);

const getMedia = ({
imageUrl,
imageAltText,
Expand Down Expand Up @@ -410,7 +391,7 @@ export const Card = ({
*
*/
const decideOuterSublinks = () => {
if (!hasSublinks) return null;
if (!supportingContent) return null;
if (sublinkPosition === 'none') return null;
if (sublinkPosition === 'outer') {
return (
Expand All @@ -419,35 +400,16 @@ export const Card = ({
containerPalette={containerPalette}
alignment={supportingContentAlignment}
isDynamo={isDynamo}
fillBackground={isFlexibleContainer}
/>
);
}
return (
<Hide from={isFlexibleContainer ? 'tablet' : 'desktop'}>
<Hide from="tablet">
<SupportingContent
supportingContent={supportingContent}
containerPalette={containerPalette}
alignment={supportingContentAlignment}
isDynamo={isDynamo}
fillBackground={isFlexibleContainer}
/>
</Hide>
);
};

const decideInnerSublinks = () => {
if (!hasSublinks) return null;
if (sublinkPosition !== 'inner') return null;
return (
<Hide until={isFlexibleContainer ? 'tablet' : 'desktop'}>
<SupportingContent
supportingContent={supportingContent}
/* inner links are always vertically stacked */
alignment="vertical"
containerPalette={containerPalette}
isDynamo={isDynamo}
fillBackground={isFlexibleContainer}
/>
</Hide>
);
Expand Down Expand Up @@ -758,12 +720,6 @@ export const Card = ({
showLivePlayable={showLivePlayable}
/>
)}
{sublinkPosition === 'outer' &&
supportingContentAlignment === 'horizontal' &&
(imagePositionOnDesktop === 'right' ||
imagePositionOnDesktop === 'left') && (
<HorizontalDivider />
)}
</div>

{/* This div is needed to push this content to the bottom of the card */}
Expand All @@ -787,7 +743,16 @@ export const Card = ({
</Island>
)}

{decideInnerSublinks()}
{hasSublinks && sublinkPosition === 'inner' && (
<Hide until="tablet">
<SupportingContent
supportingContent={supportingContent}
alignment="vertical"
containerPalette={containerPalette}
isDynamo={isDynamo}
/>
</Hide>
)}
</div>
</ContentWrapper>
)}
Expand Down
3 changes: 3 additions & 0 deletions dotcom-rendering/src/components/CardHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ const sublinkStyles = css`
font-family: inherit;
font-size: inherit;
line-height: inherit;
@media (pointer: coarse) {
min-height: 44px;
}
/* This css is used to remove any underline from the kicker but still
* have it applied to the headline when the kicker is hovered */
Expand Down
13 changes: 0 additions & 13 deletions dotcom-rendering/src/components/FlexibleGeneral.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,6 @@ describe('FlexibleGeneral', () => {
]);
});

it('Should return a one card row layout if one card without boost level is provided', () => {
const cardWithoutBoostLevel = {
...standardCard,
boostLevel: undefined,
};
expect(decideCardPositions([cardWithoutBoostLevel])).toEqual([
{
layout: 'oneCard',
cards: [cardWithoutBoostLevel],
},
]);
});

it('Should return two rows of two card row layouts if four standard cards are provided', () => {
expect(
decideCardPositions([
Expand Down
35 changes: 17 additions & 18 deletions dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const decideCardPositions = (cards: DCRFrontCard[]): GroupedCards => {

return cards.reduce<GroupedCards>((acc, card) => {
// Early return if the card is boosted since it takes up a whole row
if (card.boostLevel && card.boostLevel !== 'default') {
if (card.boostLevel !== 'default') {
return [...acc, createNewRow('oneCardBoosted', card)];
}

Expand All @@ -64,22 +64,22 @@ export const decideCardPositions = (cards: DCRFrontCard[]): GroupedCards => {
}, []);
};

type BoostedSplashProperties = {
/**
* Boosting a splash card will affect the layout and style of the card. This function will determine the properties of the card based on the boost level.
*/

type boostedSplashProperties = {
headlineSize: SmallHeadlineSize;
headlineSizeOnMobile: SmallHeadlineSize;
headlineSizeOnTablet: SmallHeadlineSize;
imagePositionOnDesktop: ImagePositionType;
imagePositionOnMobile: ImagePositionType;
supportingContentAlignment: Alignment;
};

/**
* Boosting a splash card will affect the layout and style of the card. This function will determine the properties of the card based on the boost level.
*/
const decideSplashCardProperties = (
boostLevel: BoostLevel,
boostLevel: BoostLevel = 'default',
supportingContentLength: number,
): BoostedSplashProperties => {
): boostedSplashProperties => {
switch (boostLevel) {
// The default boost level is equal to no boost. It is the same as the default card layout.
case 'default':
Expand Down Expand Up @@ -147,10 +147,9 @@ export const SplashCardLayout = ({
imagePositionOnMobile,
supportingContentAlignment,
} = decideSplashCardProperties(
card.boostLevel ?? 'default',
card.supportingContent?.length ?? 0,
card.boostLevel,
card?.supportingContent?.length ?? 0,
);

return (
<UL padBottom={true}>
<LI padSides={true}>
Expand Down Expand Up @@ -180,19 +179,19 @@ export const SplashCardLayout = ({
);
};

type BoostedCardProperties = {
/**
* Boosting a splash card will affect the layout and style of the card. This function will determine the properties of the card based on the boost level.
*/

type boostedCardProperties = {
headlineSize: SmallHeadlineSize;
headlineSizeOnMobile: SmallHeadlineSize;
headlineSizeOnTablet: SmallHeadlineSize;
imageSize: ImageSizeType;
};

/**
* Boosting a standard card will affect the layout and style of the card. This function will determine the properties of the card based on the boost level.
*/
const decideCardProperties = (
boostLevel: BoostLevel = 'boost',
): BoostedCardProperties => {
): boostedCardProperties => {
switch (boostLevel) {
case 'megaboost':
return {
Expand Down Expand Up @@ -319,7 +318,7 @@ export const FlexibleGeneral = ({
imageLoading,
}: Props) => {
const splash = [...groupedTrails.splash].slice(0, 1);
const cards = [...groupedTrails.standard].slice(0, 8);
const cards = [...groupedTrails.standard].slice(0, 8); // TODO check maximum number of cards
const groupedCards = decideCardPositions(cards);

return (
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 @@ -19,7 +19,7 @@ type Props = {
absoluteServerTimes: boolean;
};

type BoostProperties = {
type boostProperties = {
headlineSize: SmallHeadlineSize;
headlineSizeOnMobile: SmallHeadlineSize;
headlineSizeOnTablet: SmallHeadlineSize;
Expand All @@ -32,9 +32,9 @@ type BoostProperties = {
* Boosting a card will affect the layout and style of the card. This function will determine the properties of the card based on the boost level.
*/
const determineCardProperties = (
boostLevel: BoostLevel,
boostLevel: BoostLevel = 'default',
supportingContentLength: number,
): BoostProperties => {
): boostProperties => {
switch (boostLevel) {
// The default boost level is equal to no boost. It is the same as the default card layout.
case 'default':
Expand All @@ -43,7 +43,7 @@ const determineCardProperties = (
headlineSizeOnMobile: 'tiny',
headlineSizeOnTablet: 'small',
imagePositionOnDesktop: 'right',
imagePositionOnMobile: 'bottom',
imagePositionOnMobile: 'top',
supportingContentAlignment:
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
};
Expand All @@ -53,7 +53,7 @@ const determineCardProperties = (
headlineSizeOnMobile: 'small',
headlineSizeOnTablet: 'medium',
imagePositionOnDesktop: 'right',
imagePositionOnMobile: 'bottom',
imagePositionOnMobile: 'top',
supportingContentAlignment:
supportingContentLength >= 3 ? 'horizontal' : 'vertical',
};
Expand All @@ -63,7 +63,7 @@ const determineCardProperties = (
headlineSizeOnMobile: 'medium',
headlineSizeOnTablet: 'medium',
imagePositionOnDesktop: 'bottom',
imagePositionOnMobile: 'bottom',
imagePositionOnMobile: 'top',
supportingContentAlignment: 'horizontal',
};
case 'gigaboost':
Expand All @@ -72,7 +72,7 @@ const determineCardProperties = (
headlineSizeOnMobile: 'large',
headlineSizeOnTablet: 'large',
imagePositionOnDesktop: 'bottom',
imagePositionOnMobile: 'bottom',
imagePositionOnMobile: 'top',
supportingContentAlignment: 'horizontal',
};
}
Expand Down Expand Up @@ -101,8 +101,8 @@ export const OneCardLayout = ({
imagePositionOnMobile,
supportingContentAlignment,
} = determineCardProperties(
card.boostLevel ?? 'default',
card.supportingContent?.length ?? 0,
card.boostLevel,
card?.supportingContent?.length ?? 0,
);
return (
<UL padBottom={true}>
Expand Down
Loading

0 comments on commit ae9de73

Please sign in to comment.