Skip to content

Commit

Permalink
Update timeline article format to match tablet/desktop breakpoint des…
Browse files Browse the repository at this point in the history
…igns
  • Loading branch information
domlander committed May 9, 2024
1 parent e6ce0b6 commit a8569fd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
24 changes: 22 additions & 2 deletions dotcom-rendering/src/components/ElementContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ const setBackgroundColour = (colour: string) => css`
background-color: ${colour};
`;

const timelineStyles = (colour: string) => css`
position: relative;
margin: auto;
${from.leftCol} {
max-width: 1140px;
border-left: 1px solid ${colour};
border-right: 1px solid ${colour};
}
${from.wide} {
max-width: 1300px;
}
`;

//Previously, borderColour would be set to palette.neutral[86] if the parameter being passed was undefined. We still want this as a fallback, but not for ArticleDesign.Picture pages (and probably not for any future pages with a similar design).
const decideFallbackBorderColour = (format: ArticleFormat | undefined) => {
return format?.design === ArticleDesign.Picture
Expand Down Expand Up @@ -68,6 +83,7 @@ type Props = {
hasPageSkin?: boolean;
hasPageSkinContentSelfConstrain?: boolean;
format?: ArticleFormat;
isTimeline?: boolean;
};

/**
Expand Down Expand Up @@ -95,6 +111,7 @@ export const ElementContainer = ({
containerName,
hasPageSkin = false,
hasPageSkinContentSelfConstrain = false,
isTimeline = false,
}: Props) =>
jsx(element, {
id: ophanComponentName,
Expand All @@ -116,14 +133,17 @@ export const ElementContainer = ({
*/
id={sectionId}
css={[
shouldCenter && center,
showSideBorders && sideBorderStyles(borderColour),
shouldCenter && !isTimeline && center,
showSideBorders &&
!isTimeline &&
sideBorderStyles(borderColour),
showTopBorder && topBorderStyles(borderColour),
innerBackgroundColour &&
setBackgroundColour(innerBackgroundColour),
padSides && sidePadding,
padBottom && bottomPadding,
hasPageSkin && pageSkinContainer,
isTimeline && timelineStyles(borderColour),
]}
>
{children}
Expand Down
6 changes: 6 additions & 0 deletions dotcom-rendering/src/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ type Props = {
/** When there is a page skin in some special cases we still want the container to take full
* width but the content to constrain itself e.g. Header */
hasPageSkinContentSelfConstrain?: boolean;
/**
* Whether the article format is Timeline. Defaults to false.
*/
isTimeline?: boolean;
/**
* @deprecated Do not use
*
Expand Down Expand Up @@ -302,6 +306,7 @@ export const Section = ({
shouldCenter,
hasPageSkin = false,
hasPageSkinContentSelfConstrain = false,
isTimeline = false,
className,
}: Props) => {
const overrides =
Expand Down Expand Up @@ -333,6 +338,7 @@ export const Section = ({
hasPageSkinContentSelfConstrain={
hasPageSkinContentSelfConstrain
}
isTimeline={isTimeline}
>
{children}
</ElementContainer>
Expand Down
28 changes: 20 additions & 8 deletions dotcom-rendering/src/components/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ const eventStyles = css`
position: relative;
${from.tablet} {
margin-left: -21px;
margin-right: -21px;
border-left: none;
}
${from.leftCol} {
border-left: 1px solid ${palette('--timeline-event-border')};
margin-left: -11px;
margin-right: -11px;
}
Expand All @@ -162,10 +163,11 @@ const labelStyles = css`
${textSans.small({ fontWeight: 'regular' })}
${from.tablet} {
margin-left: -21px;
margin-right: -21px;
border-left: none;
}
${from.leftCol} {
border-left: 1px solid ${palette('--timeline-event-border')};
margin-left: -11px;
margin-right: -11px;
}
Expand Down Expand Up @@ -225,6 +227,16 @@ const TimelineEvent = ({
</>
);

const containerStyles = css`
border-left: none;
${from.tablet} {
border-left: 1px solid ${palette('--timeline-event-border')};
}
${from.leftCol} {
border-left: none;
}
`;

// ----- Timeline ----- //

type Props = {
Expand All @@ -243,7 +255,7 @@ export const Timeline = ({
const someEventsHaveTitles = timeline.events.some(hasTitle);

return (
<>
<div css={containerStyles}>
{timeline.events.map((event) => (
<TimelineEvent
event={event}
Expand All @@ -254,7 +266,7 @@ export const Timeline = ({
format={format}
/>
))}
</>
</div>
);
}
case 'model.dotcomrendering.pageElements.DCRSectionedTimelineBlockElement': {
Expand All @@ -263,7 +275,7 @@ export const Timeline = ({
);

return (
<>
<div css={containerStyles}>
{timeline.sections.map((section) => (
<section key={section.title}>
<Subheading format={format} topPadding={false}>
Expand All @@ -283,7 +295,7 @@ export const Timeline = ({
))}
</section>
))}
</>
</div>
);
}
}
Expand Down
6 changes: 6 additions & 0 deletions dotcom-rendering/src/layouts/StandardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ export const StandardLayout = (props: WebProps | AppProps) => {
? article.matchUrl
: undefined;

const isTimeline = format.design === ArticleDesign.Timeline;

const isMatchReport =
format.design === ArticleDesign.MatchReport && !!footballMatchUrl;

Expand Down Expand Up @@ -494,6 +496,7 @@ export const StandardLayout = (props: WebProps | AppProps) => {
padSides={false}
backgroundColour={sourcePalette.brand[400]}
element="nav"
isTimeline={isTimeline}
>
<Nav
nav={props.NAV}
Expand Down Expand Up @@ -526,6 +529,7 @@ export const StandardLayout = (props: WebProps | AppProps) => {
)}
padSides={false}
element="aside"
isTimeline={isTimeline}
>
<Island
priority="enhancement"
Expand All @@ -552,6 +556,7 @@ export const StandardLayout = (props: WebProps | AppProps) => {
)}
padSides={false}
showTopBorder={false}
isTimeline={isTimeline}
>
<StraightLines
count={4}
Expand Down Expand Up @@ -613,6 +618,7 @@ export const StandardLayout = (props: WebProps | AppProps) => {
'--article-inner-background',
)}
element="article"
// isTimeline={isTimeline}
>
<StandardGrid
isMatchReport={isMatchReport}
Expand Down

0 comments on commit a8569fd

Please sign in to comment.