forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIconBadge.tsx
34 lines (31 loc) · 855 Bytes
/
IconBadge.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
import React from "react"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
import {
faExclamationTriangle,
faCircleXmark,
} from "@fortawesome/free-solid-svg-icons"
import { OwidGdocErrorMessageType } from "@ourworldindata/utils"
import { Badge } from "antd"
export const IconBadge = ({
status,
children,
}: {
status: OwidGdocErrorMessageType | null
children: React.ReactNode
}) => {
if (!status) return <>{children}</>
let icon
switch (status) {
case OwidGdocErrorMessageType.Warning:
icon = faExclamationTriangle
break
case OwidGdocErrorMessageType.Error:
icon = faCircleXmark
break
}
return (
<Badge count={<FontAwesomeIcon icon={icon} className={status} />}>
{children}
</Badge>
)
}