Skip to content

Commit

Permalink
Add a split top bar variant using linear gradient that is applied to …
Browse files Browse the repository at this point in the history
…all standard layouts except the top row (#12528)
  • Loading branch information
abeddow91 authored Oct 10, 2024
1 parent 9ab1efb commit 482b37c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 16 additions & 3 deletions dotcom-rendering/src/components/Card/components/UL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const marginBottomStyles = (isFlexibleContainer: boolean) => css`
margin-bottom: ${isFlexibleContainer ? space[6] : space[3]}px;
`;

const topBarStyles = css`
const topBarStyles = (splitTopBar: boolean) => css`
${from.tablet} {
padding-top: 8px;
::before {
Expand All @@ -49,7 +49,17 @@ const topBarStyles = css`
left: 10px;
width: calc(100% - 20px);
height: 1px;
background-color: ${palette('--card-border-top')};
${splitTopBar
? `background-image: linear-gradient(
to right,
${palette('--card-border-top')},
${palette('--card-border-top')} calc(50% - 10px),
rgba(0, 0, 0, 0) calc(50% - 10px),
rgba(0, 0, 0, 0) calc(50% + 10px),
${palette('--card-border-top')} calc(50% + 10px),
${palette('--card-border-top')}
)`
: `background-color: ${palette('--card-border-top')};`}
}
}
`;
Expand All @@ -66,6 +76,8 @@ type Props = {
wrapCards?: boolean;
/** Used to display a full width bar along the top of the container */
showTopBar?: boolean;
/** Used to add a gap in the center of the top bar */
splitTopBar?: boolean;
/** Used to give flexible container stories additional space */
isFlexibleContainer?: boolean;
};
Expand All @@ -78,6 +90,7 @@ export const UL = ({
wrapCards = false,
showTopBar = false,
isFlexibleContainer = false,
splitTopBar = false,
}: Props) => {
return (
<ul
Expand All @@ -86,7 +99,7 @@ export const UL = ({
showDivider && verticalDivider(palette('--section-border')),
padBottom && marginBottomStyles(isFlexibleContainer),
wrapCards && wrapStyles,
showTopBar && topBarStyles,
showTopBar && topBarStyles(splitTopBar),
]}
>
{children}
Expand Down
6 changes: 5 additions & 1 deletion dotcom-rendering/src/components/FlexibleGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ export const StandardCardLayout = ({
absoluteServerTimes,
showImage = true,
imageLoading,
isFirstRow,
}: {
cards: DCRFrontCard[];
imageLoading: Loading;
isFirstRow: boolean;
containerPalette?: DCRContainerPalette;
showAge?: boolean;
absoluteServerTimes: boolean;
Expand All @@ -301,6 +303,7 @@ export const StandardCardLayout = ({
padBottom={true}
isFlexibleContainer={true}
showTopBar={true}
splitTopBar={!isFirstRow}
>
{cards.map((card, cardIndex) => {
return (
Expand Down Expand Up @@ -359,7 +362,7 @@ export const FlexibleGeneral = ({
/>
)}

{groupedCards.map((row) => {
{groupedCards.map((row, i) => {
switch (row.layout) {
case 'oneCardBoosted':
return (
Expand All @@ -382,6 +385,7 @@ export const FlexibleGeneral = ({
showAge={showAge}
absoluteServerTimes={absoluteServerTimes}
imageLoading={imageLoading}
isFirstRow={i === 0}
/>
);
}
Expand Down

0 comments on commit 482b37c

Please sign in to comment.