Skip to content

Commit b0190c9

Browse files
author
Maria Mattlin
committed
Merge branch 'PROD-2321_bug-hunt-intake-form' into PROD-2429_start-work-tile
2 parents 3d5be35 + f7d8efc commit b0190c9

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed

src-ts/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export {
2323
xhrPatchAsync,
2424
xhrPostAsync,
2525
} from './functions'
26+
export * from './info-card'
2627
export * from './loading-spinner'
2728
export * from './modals'
2829
export * from './page-footer'
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
@import '../styles/includes';
2+
3+
.card {
4+
width: 100%;
5+
margin-top: 32px;
6+
padding: 16px;
7+
8+
&.collapsible {
9+
border-radius: 4px;
10+
}
11+
12+
&.notCollapsible {
13+
border-radius: 8px;
14+
}
15+
16+
.title {
17+
display: flex;
18+
justify-content: space-between;
19+
align-items: center;
20+
21+
&.collapsible {
22+
cursor: pointer;
23+
}
24+
25+
span {
26+
@include font-black-100;
27+
font-size: 18px;
28+
line-height: 22px;
29+
text-transform: uppercase;
30+
font-weight: 600;
31+
}
32+
33+
.arrowIcon {
34+
35+
&.up {
36+
transform: rotate(180deg);
37+
}
38+
}
39+
}
40+
41+
.spacing {
42+
padding-bottom: 17px;
43+
}
44+
45+
.content {
46+
@include font-black-100;
47+
@include font-roboto;
48+
}
49+
}
50+
51+
.info {
52+
background-color: $black-5;
53+
}
54+
55+
.success {
56+
background-color: $turq-15;
57+
}
58+
59+
.warn {
60+
background-color: $orange-25;
61+
}

src-ts/lib/info-card/InfoCard.tsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import classNames from 'classnames'
2+
import { Dispatch, FC, ReactNode, SetStateAction, useState } from 'react'
3+
4+
import { ArrowIcon } from '../svgs'
5+
6+
import styles from './InfoCard.module.scss'
7+
8+
interface InfoCardProps {
9+
children: ReactNode,
10+
color: 'info' | 'success' | 'warn',
11+
defaultOpen: boolean,
12+
isCollapsible: boolean,
13+
title?: string,
14+
}
15+
16+
const InfoCard: FC<InfoCardProps> = ({
17+
children,
18+
color = 'info',
19+
defaultOpen = true,
20+
isCollapsible = false,
21+
title,
22+
}: InfoCardProps) => {
23+
24+
const [isOpen, setIsOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(defaultOpen)
25+
const collapsibleClass: string = isCollapsible ? styles.collapsible : styles.notCollapsible
26+
const showSpacing: boolean = isOpen && !!title && !!children
27+
28+
return (
29+
<div className={classNames(styles.card, styles[color], collapsibleClass)}>
30+
{renderHeader(isCollapsible, isOpen, setIsOpen, title || '')}
31+
32+
{showSpacing && (
33+
<div className={styles.spacing}></div>
34+
)}
35+
36+
{isOpen &&
37+
<div className={styles.content}>{children}</div>
38+
}
39+
</div>
40+
)
41+
}
42+
43+
function renderHeader(
44+
isCollapsible: boolean,
45+
isOpen: boolean,
46+
setIsOpen: Dispatch<SetStateAction<boolean>>,
47+
title: string
48+
): JSX.Element {
49+
50+
const arrowClass: string = isOpen ? styles.up : undefined
51+
52+
if (isCollapsible) {
53+
return (
54+
<div
55+
className={classNames(styles.title, styles.collapsible)}
56+
onClick={() => setIsOpen(!isOpen)}
57+
role='button'
58+
tabIndex={0}
59+
>
60+
<span>{title}</span>
61+
62+
<div className={classNames(styles.arrowIcon, arrowClass)}>
63+
<ArrowIcon />
64+
</div>
65+
</div>
66+
)
67+
}
68+
69+
return (
70+
<div className={styles.title}>
71+
<span>{title}</span>
72+
</div>
73+
)
74+
}
75+
76+
export default InfoCard

src-ts/lib/info-card/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as InfoCard } from './InfoCard'

src-ts/lib/svgs/icon-arrow.svg

Lines changed: 1 addition & 0 deletions
Loading

src-ts/lib/svgs/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as IconOutline from '@heroicons/react/outline'
33
import * as IconSolid from '@heroicons/react/solid'
44

55
import { ReactComponent as ActiveTabTipIcon } from './activetab-tip-icon.svg'
6+
import { ReactComponent as ArrowIcon } from './icon-arrow.svg'
67
import { ReactComponent as LogoIcon } from './logo.svg'
78
import { ReactComponent as SocialIconFacebook } from './social-fb-icon.svg'
89
import { ReactComponent as SocialIconInstagram } from './social-insta-icon.svg'
@@ -12,6 +13,7 @@ import { ReactComponent as SocialIconYoutube } from './social-yt-icon.svg'
1213
import { ReactComponent as TooltipArrowIcon } from './tooltip-arrow.svg'
1314

1415
export { ActiveTabTipIcon }
16+
export { ArrowIcon }
1517
export { IconOutline }
1618
export { IconSolid }
1719
export { LogoIcon }

0 commit comments

Comments
 (0)