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

34 lines
896 B
TypeScript
Raw Normal View History

import {Box, Heading} from "@steffo/bluelib-react"
import * as React from "react"
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
}
// TODO: In the future, it would be nice for this to be parsed as Markdown!
return (
<Box>
<Heading level={3}>
Welcome to {instance.state.details.name}!
</Heading>
<pre>
{instance.state.details.description}
</pre>
</Box>
)
}