|
1 | 1 | 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'; |
4 | 7 | import { useState } from 'react'; |
5 | 8 | import type { ArticleFormat } from '../lib/articleFormat'; |
6 | 9 | import type { ProductBlockElement } from '../types/content'; |
7 | 10 | import { HorizontalSummaryProductCard } from './HorizontalSummaryProductCard'; |
8 | 11 |
|
9 | 12 | const buttonStyles = css` |
10 | | - ${textSans15}; |
11 | | - color: ${palette.lifestyle[400]}; |
12 | | - font-weight: 700; |
13 | 13 | background-color: transparent; |
14 | 14 | padding: ${space[4]}px 0px 0px 0px; |
15 | 15 | border: none; |
| 16 | + display: flex; |
| 17 | +`; |
| 18 | + |
| 19 | +const buttonTextStyles = css` |
| 20 | + ${textSans15}; |
| 21 | + color: ${palette.lifestyle[400]}; |
| 22 | + font-weight: 700; |
16 | 23 | border-bottom: 1px solid ${palette.neutral[86]}; |
| 24 | + padding-right: ${space[1]}px; |
17 | 25 | `; |
18 | 26 |
|
19 | 27 | export const StackedProducts = ({ |
@@ -46,12 +54,25 @@ export const StackedProducts = ({ |
46 | 54 | )} |
47 | 55 | </div> |
48 | 56 |
|
49 | | - {products.length > 3 && !isExpanded && ( |
| 57 | + {products.length > 3 && ( |
50 | 58 | <button |
51 | 59 | onClick={() => setIsExpanded(!isExpanded)} |
52 | 60 | css={buttonStyles} |
53 | 61 | > |
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 | + )} |
55 | 76 | </button> |
56 | 77 | )} |
57 | 78 | </div> |
|
0 commit comments