1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2025-01-09 07:19:46 +00:00
sophon/frontend/src/components/elements/DescriptionBox.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-10-13 03:05:34 +00:00
import {IconDefinition} from "@fortawesome/fontawesome-svg-core"
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
import {Box, Heading, Idiomatic} from "@steffo/bluelib-react"
import * as React from "react"
import ReactMarkdown from "react-markdown"
import {Empty} from "./Empty"
2021-10-13 03:05:34 +00:00
2021-10-16 23:31:29 +00:00
export interface DescriptionBoxProps {
2021-10-13 03:05:34 +00:00
icon: IconDefinition,
name: string,
description?: string | null,
2021-10-13 03:05:34 +00:00
}
2021-10-16 23:31:29 +00:00
export function DescriptionBox({icon, name, description}: DescriptionBoxProps): JSX.Element {
2021-10-13 03:05:34 +00:00
return React.useMemo(
() => (
<Box>
<Heading level={3}>
<FontAwesomeIcon icon={icon}/>&nbsp;About <Idiomatic>{name}</Idiomatic>
</Heading>
{
description ?
<ReactMarkdown>
{description}
</ReactMarkdown>
:
<Empty>
This resource has no about text.
</Empty>
}
2021-10-13 03:05:34 +00:00
</Box>
),
[icon, name, description],
)
}