Skip to content

Commit 3ad0ec6

Browse files
committed
Add Show less and chevron icons
1 parent b4b577b commit 3ad0ec6

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

dotcom-rendering/src/components/StackedProducts.tsx

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import { css } from '@emotion/react';
2-
import { space } from '@guardian/source/foundations';
3-
import { palette, textSans15 } from '@guardian/source/foundations';
2+
import { palette, space, textSans15 } from '@guardian/source/foundations';
3+
import {
4+
SvgChevronDownSingle,
5+
SvgChevronUpSingle,
6+
} from '@guardian/source/react-components';
47
import { useState } from 'react';
58
import type { ArticleFormat } from '../lib/articleFormat';
69
import type { ProductBlockElement } from '../types/content';
710
import { HorizontalSummaryProductCard } from './HorizontalSummaryProductCard';
811

912
const buttonStyles = css`
10-
${textSans15};
11-
color: ${palette.lifestyle[400]};
12-
font-weight: 700;
1313
background-color: transparent;
1414
padding: ${space[4]}px 0px 0px 0px;
1515
border: none;
16+
display: flex;
17+
`;
18+
19+
const buttonTextStyles = css`
20+
${textSans15};
21+
color: ${palette.lifestyle[400]};
22+
font-weight: 700;
1623
border-bottom: 1px solid ${palette.neutral[86]};
24+
padding-right: ${space[1]}px;
1725
`;
1826

1927
export const StackedProducts = ({
@@ -46,12 +54,25 @@ export const StackedProducts = ({
4654
)}
4755
</div>
4856

49-
{products.length > 3 && !isExpanded && (
57+
{products.length > 3 && (
5058
<button
5159
onClick={() => setIsExpanded(!isExpanded)}
5260
css={buttonStyles}
5361
>
54-
Show all
62+
<p css={buttonTextStyles}>
63+
{isExpanded ? 'Show less' : 'Show all'}
64+
</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+
)}
5576
</button>
5677
)}
5778
</div>

0 commit comments

Comments
 (0)