|
1 |
| -import { FC } from 'react'; |
| 1 | +import { FC, useState } from 'react'; |
2 | 2 |
|
3 | 3 | import { Box, Button, Typography } from '@mui/material';
|
4 | 4 |
|
5 |
| -import { BANNER_CY, SUMMON_BUTTON_CY } from '../../../config/selectors'; |
| 5 | +import { BANNER_CY, SHOW_KEYWORDS_BUTTON_CY } from '../../../config/selectors'; |
6 | 6 | import {
|
7 | 7 | DEFAULT_MARGIN,
|
8 | 8 | GRAASP_VIOLET,
|
9 | 9 | } from '../../../config/stylingConstants';
|
10 | 10 |
|
11 | 11 | type Prop = {
|
12 | 12 | title: string;
|
13 |
| - onSummonClick: () => void; |
14 |
| - showDisable: boolean; |
15 |
| - onHideClick: () => void; |
16 |
| - hideDisable: boolean; |
| 13 | + disabled: boolean; |
| 14 | + onClick: (showKeywords: boolean) => void; |
17 | 15 | };
|
18 | 16 |
|
19 |
| -const Banner: FC<Prop> = ({ |
20 |
| - title, |
21 |
| - onSummonClick, |
22 |
| - showDisable, |
23 |
| - onHideClick, |
24 |
| - hideDisable, |
25 |
| -}) => ( |
26 |
| - <Box |
27 |
| - data-cy={BANNER_CY} |
28 |
| - component="span" |
29 |
| - justifyContent="space-between" |
30 |
| - display="flex" |
31 |
| - alignItems="center" |
32 |
| - sx={{ minHeight: '70px' }} |
33 |
| - > |
34 |
| - <Typography |
35 |
| - variant="h4" |
36 |
| - sx={{ |
37 |
| - color: GRAASP_VIOLET, |
38 |
| - marginLeft: DEFAULT_MARGIN, |
39 |
| - }} |
| 17 | +const Banner: FC<Prop> = ({ title, disabled, onClick }) => { |
| 18 | + const [showKeywords, setShowKeywords] = useState(false); |
| 19 | + |
| 20 | + // TODO: translate me |
| 21 | + const SHOW_KEYWORDS_LABEL = 'show keywords'; |
| 22 | + const HIDE_KEYWORDS_LABEL = 'hide keywords'; |
| 23 | + |
| 24 | + const toggleKeywords = (): void => { |
| 25 | + onClick(!showKeywords); |
| 26 | + setShowKeywords(!showKeywords); |
| 27 | + }; |
| 28 | + |
| 29 | + return ( |
| 30 | + <Box |
| 31 | + data-cy={BANNER_CY} |
| 32 | + component="span" |
| 33 | + justifyContent="space-between" |
| 34 | + display="flex" |
| 35 | + alignItems="center" |
| 36 | + sx={{ minHeight: '70px' }} |
40 | 37 | >
|
41 |
| - {title} |
42 |
| - </Typography> |
43 |
| - <Box display="flex" flex-direction="row-reverse"> |
44 |
| - <Button |
45 |
| - variant="contained" |
46 |
| - sx={{ marginRight: DEFAULT_MARGIN }} |
47 |
| - onClick={onHideClick} |
48 |
| - disabled={hideDisable} |
| 38 | + <Typography |
| 39 | + variant="h4" |
| 40 | + sx={{ |
| 41 | + color: GRAASP_VIOLET, |
| 42 | + marginLeft: DEFAULT_MARGIN, |
| 43 | + }} |
49 | 44 | >
|
50 |
| - Hide Keywords |
51 |
| - </Button> |
52 |
| - <Button |
53 |
| - data-cy={SUMMON_BUTTON_CY} |
54 |
| - variant="contained" |
55 |
| - color="success" |
56 |
| - sx={{ marginRight: DEFAULT_MARGIN }} |
57 |
| - onClick={onSummonClick} |
58 |
| - disabled={showDisable} |
59 |
| - > |
60 |
| - Show Keywords |
61 |
| - </Button> |
| 45 | + {title} |
| 46 | + </Typography> |
| 47 | + <Box display="flex" flex-direction="row-reverse"> |
| 48 | + <Button |
| 49 | + data-cy={SHOW_KEYWORDS_BUTTON_CY} |
| 50 | + variant={showKeywords ? 'outlined' : 'contained'} |
| 51 | + sx={{ marginRight: DEFAULT_MARGIN }} |
| 52 | + onClick={toggleKeywords} |
| 53 | + disabled={disabled} |
| 54 | + > |
| 55 | + {showKeywords ? HIDE_KEYWORDS_LABEL : SHOW_KEYWORDS_LABEL} |
| 56 | + </Button> |
| 57 | + </Box> |
62 | 58 | </Box>
|
63 |
| - </Box> |
64 |
| -); |
| 59 | + ); |
| 60 | +}; |
65 | 61 |
|
66 | 62 | export default Banner;
|
0 commit comments