2021-10-12 01:24:55 +00:00
|
|
|
import {Box, Heading, Idiomatic} from "@steffo/bluelib-react"
|
2021-10-06 00:52:06 +00:00
|
|
|
import * as React from "react"
|
2021-10-12 01:24:55 +00:00
|
|
|
import ReactMarkdown from "react-markdown"
|
2021-10-06 00:52:06 +00:00
|
|
|
import {useInstanceContext} from "../../contexts/instance"
|
|
|
|
import {ErrorBox} from "../errors/ErrorBox"
|
|
|
|
|
|
|
|
|
2021-10-06 14:41:47 +00:00
|
|
|
export function InstanceDescriptionBox(): JSX.Element | null {
|
2021-10-06 00:52:06 +00:00
|
|
|
const instance = useInstanceContext()
|
|
|
|
|
|
|
|
if(!instance) {
|
|
|
|
return <ErrorBox error={new Error("This component is being rendered outside an InstanceContext.")}/>
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!instance.state.details) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!instance.state.details.description) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Box>
|
|
|
|
<Heading level={3}>
|
2021-10-12 01:24:55 +00:00
|
|
|
About <Idiomatic>{instance.state.details.name}</Idiomatic>
|
2021-10-06 00:52:06 +00:00
|
|
|
</Heading>
|
2021-10-12 01:24:55 +00:00
|
|
|
<ReactMarkdown>
|
2021-10-06 00:52:06 +00:00
|
|
|
{instance.state.details.description}
|
2021-10-12 01:24:55 +00:00
|
|
|
</ReactMarkdown>
|
2021-10-06 00:52:06 +00:00
|
|
|
</Box>
|
|
|
|
)
|
|
|
|
}
|