-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathExpandableCard.tsx
64 lines (55 loc) · 1.9 KB
/
ExpandableCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import Image from 'next/image'
import pageStyles from '../../styles/Page.module.css'
import expandableCardStyles from './ExpandableCard.module.css'
import OpenIconLight from '../../public/OpenIconLight.png'
import CloseIconLight from '../../public/CloseIconLight.png'
import { classNames } from '../../utils/classNames'
const ExpandableCard = (props: {
title: string,
shortTitle: string
className?: string,
children: JSX.Element,
isOpen: boolean,
onClick: () => void;
}): JSX.Element => {
const imageSrc = props.isOpen ? CloseIconLight : OpenIconLight
const imageAlt = props.isOpen ? 'Close Card': 'Open Card'
const imageHeight = props.isOpen ? 5 : 20
const selectedBackgroundColorClass = props.isOpen ? expandableCardStyles.expandable_card_container_selected: ''
const className = props.className !== undefined ? props.className : ''
return (
<div
className={classNames(
pageStyles.background_card,
expandableCardStyles.expandable_card_container,
selectedBackgroundColorClass,
className
)}
id={props.title}
onClick={() => props.onClick()}
>
<div
className={expandableCardStyles.header}
>
<h3 className='only-on-desktop'>
{props.title}
</h3>
<h3 className='only-on-mobile'>
{props.shortTitle}
</h3>
<div>
<Image
src={imageSrc}
alt={imageAlt}
width={20}
height={imageHeight}
/>
</div>
</div>
{props.isOpen &&
props.children
}
</div>
)
}
export default ExpandableCard;