Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for fixed/small/slow-IV container type #4767

Merged
merged 2 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { breakpoints } from '@guardian/source-foundations';
import { ContainerLayout } from './ContainerLayout';
import { FixedSmallSlowIV } from './FixedSmallSlowIV';

import { trails } from '../../../fixtures/manual/trails';

export default {
component: FixedSmallSlowIV,
title: 'Components/FixedSmallSlowIV',
parameters: {
chromatic: {
viewports: [
breakpoints.mobile,
Copy link
Member Author

@AshCorr AshCorr Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're planning on adding all these breakpoints for every type of container we probably need to find a way to give chromatic some kind of focus so that it only checks files that could have changed.

This might be some help? https://www.chromatic.com/docs/turbosnap

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're planning on adding all these breakpoints for every type of container we probably need to find a way to give chromatic some kind of focus so that it only checks files that could have changed.

This might be some help? https://www.chromatic.com/docs/turbosnap

Interesting. It's hard to say if this is a good option for us or not, I think the write up at the link you gave (thanks) is fairly accurate in being hesitant but if this does work the way we want it to then it could be a big win

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised #4768 for this, tried to explain the incompatibility the way I understand it in this PR

breakpoints.mobileMedium,
breakpoints.mobileLandscape,
breakpoints.phablet,
breakpoints.tablet,
breakpoints.desktop,
breakpoints.leftCol,
breakpoints.wide,
],
},
},
};

export const Default = () => (
<ContainerLayout
title="FixedSmallSlowIV"
showTopBorder={true}
sideBorders={true}
padContent={false}
centralBorder="partial"
>
<FixedSmallSlowIV trails={trails} />
</ContainerLayout>
);
Default.story = { name: 'FixedSmallSlowIV' };
57 changes: 57 additions & 0 deletions dotcom-rendering/src/web/components/FixedSmallSlowIV.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ArticleDesign } from '@guardian/libs';
import { Card } from './Card/Card';
import { LI } from './Card/components/LI';
import { UL } from './Card/components/UL';

type Props = {
trails: TrailType[];
};

export const FixedSmallSlowIV = ({ trails }: Props) => {
const slicedTrails = trails.slice(0, 4);

return (
<UL direction="row">
{slicedTrails.map((trail, index) => {
return (
<LI
percentage="25%"
AshCorr marked this conversation as resolved.
Show resolved Hide resolved
padSides={true}
showDivider={index > 0}
padBottomOnMobile={true}
>
<Card
linkTo={trail.url}
format={trail.format}
headlineText={trail.headline}
trailText={trail.trailText}
headlineSize="medium"
byline={trail.byline}
showByline={trail.showByline}
showQuotes={
trail.format.design === ArticleDesign.Comment ||
trail.format.design === ArticleDesign.Letter
}
webPublicationDate={trail.webPublicationDate}
kickerText={trail.kickerText}
showPulsingDot={
trail.format.design === ArticleDesign.LiveBlog
}
showSlash={true}
showClock={false}
imageUrl={trail.image}
imagePosition="top"
imagePositionOnMobile="left"
imageSize="medium"
mediaType={trail.mediaType}
mediaDuration={trail.mediaDuration}
commentCount={trail.commentCount}
starRating={trail.starRating}
branding={trail.branding}
/>
</LI>
);
})}
</UL>
);
};
3 changes: 3 additions & 0 deletions dotcom-rendering/src/web/lib/DecideContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DynamicFast } from '../components/DynamicFast';
import { DynamicSlow } from '../components/DynamicSlow';
import { FixedLargeSlowXIV } from '../components/FixedLargeSlowXIV';
import { FixedSmallSlowIV } from '../components/FixedSmallSlowIV';

type Props = {
trails: DCRFrontCard[];
Expand All @@ -15,6 +16,8 @@ export const DecideContainer = ({ trails, containerType }: Props) => {
return <DynamicSlow trails={trails} />;
case 'fixed/large/slow-XIV':
return <FixedLargeSlowXIV trails={trails} />;
case 'fixed/small/slow-IV':
return <FixedSmallSlowIV trails={trails} />;
default:
return <p>{containerType} is not yet supported</p>;
}
Expand Down