Skip to content

Commit b9e8eb6

Browse files
committed
Add card counter to bottom right corner
1 parent 3ad0ec6 commit b9e8eb6

File tree

1 file changed

+39
-20
lines changed

1 file changed

+39
-20
lines changed

dotcom-rendering/src/components/StackedProducts.tsx

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ import type { ArticleFormat } from '../lib/articleFormat';
99
import type { ProductBlockElement } from '../types/content';
1010
import { HorizontalSummaryProductCard } from './HorizontalSummaryProductCard';
1111

12-
const buttonStyles = css`
12+
const showAllButtonStyles = css`
1313
background-color: transparent;
14-
padding: ${space[4]}px 0px 0px 0px;
1514
border: none;
1615
display: flex;
1716
`;
1817

19-
const buttonTextStyles = css`
18+
const showAllTextStyles = css`
2019
${textSans15};
2120
color: ${palette.lifestyle[400]};
2221
font-weight: 700;
2322
border-bottom: 1px solid ${palette.neutral[86]};
2423
padding-right: ${space[1]}px;
2524
`;
2625

26+
const cardCounterStyles = css`
27+
${textSans15};
28+
color: ${palette.neutral[46]};
29+
font-weight: 700;
30+
`;
31+
2732
export const StackedProducts = ({
2833
products,
2934
format,
@@ -55,25 +60,39 @@ export const StackedProducts = ({
5560
</div>
5661

5762
{products.length > 3 && (
58-
<button
59-
onClick={() => setIsExpanded(!isExpanded)}
60-
css={buttonStyles}
63+
<div
64+
css={[
65+
css`
66+
display: flex;
67+
justify-content: space-between;
68+
padding-top: ${space[4]}px;
69+
`,
70+
]}
6171
>
62-
<p css={buttonTextStyles}>
63-
{isExpanded ? 'Show less' : 'Show all'}
72+
<button
73+
onClick={() => setIsExpanded(!isExpanded)}
74+
css={showAllButtonStyles}
75+
>
76+
<p css={showAllTextStyles}>
77+
{isExpanded ? 'Show less' : 'Show all'}
78+
</p>
79+
{isExpanded ? (
80+
<SvgChevronUpSingle
81+
size="xsmall"
82+
theme={{ fill: palette.lifestyle[400] }}
83+
/>
84+
) : (
85+
<SvgChevronDownSingle
86+
size="xsmall"
87+
theme={{ fill: palette.lifestyle[400] }}
88+
/>
89+
)}
90+
</button>
91+
92+
<p css={cardCounterStyles}>
93+
{isExpanded ? products.length : '3'}/{products.length}
6494
</p>
65-
{isExpanded ? (
66-
<SvgChevronUpSingle
67-
size="xsmall"
68-
theme={{ fill: palette.lifestyle[400] }}
69-
/>
70-
) : (
71-
<SvgChevronDownSingle
72-
size="xsmall"
73-
theme={{ fill: palette.lifestyle[400] }}
74-
/>
75-
)}
76-
</button>
95+
</div>
7796
)}
7897
</div>
7998
);

0 commit comments

Comments
 (0)