1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00
sophon/frontend/src/components/instance/InstanceDescriptionBox.tsx

34 lines
907 B
TypeScript
Raw Normal View History

2021-10-12 01:24:55 +00:00
import {Box, Heading, Idiomatic} from "@steffo/bluelib-react"
import * as React from "react"
2021-10-12 01:24:55 +00:00
import ReactMarkdown from "react-markdown"
import {useInstanceContext} from "../../contexts/instance"
import {ErrorBox} from "../errors/ErrorBox"
2021-10-06 14:41:47 +00:00
export function InstanceDescriptionBox(): JSX.Element | null {
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>
</Heading>
2021-10-12 01:24:55 +00:00
<ReactMarkdown>
{instance.state.details.description}
2021-10-12 01:24:55 +00:00
</ReactMarkdown>
</Box>
)
}