1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +00:00

🔧 Add an icon to ResourceDescriptionBox

This commit is contained in:
Steffo 2021-10-13 04:51:55 +02:00
parent c642ba62c4
commit a9efd9dc3a
3 changed files with 10 additions and 9 deletions

View file

@ -1,3 +1,4 @@
import {faProjectDiagram, faUsers} from "@fortawesome/free-solid-svg-icons"
import * as Reach from "@reach/router"
import {RouteComponentProps} from "@reach/router"
import {Chapter, LayoutThreeCol} from "@steffo/bluelib-react"
@ -53,7 +54,7 @@ function App({..._}: RouteComponentProps) {
</>}
selectedRoute={({selection}) => <>
<Chapter>
<ResourceDescriptionBox resource={selection}/>
<ResourceDescriptionBox resource={selection} icon={faUsers}/>
<GroupMembersBox resource={selection}/>
</Chapter>
<ProjectRouter
@ -64,7 +65,7 @@ function App({..._}: RouteComponentProps) {
</>}
selectedRoute={({selection}) => <>
<Chapter>
<ResourceDescriptionBox resource={selection}/>
<ResourceDescriptionBox resource={selection} icon={faProjectDiagram}/>
</Chapter>
<NotebookRouter
projectPk={selection.value.slug}

View file

@ -1,3 +1,5 @@
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"
@ -11,16 +13,17 @@ export interface NamedAndDescribed {
export interface ResourceDescriptionBoxProps<T extends NamedAndDescribed> {
resource: ManagedResource<T>
resource: ManagedResource<T>,
icon: IconDefinition,
}
export function ResourceDescriptionBox<T extends NamedAndDescribed>({resource}: ResourceDescriptionBoxProps<T>): JSX.Element {
export function ResourceDescriptionBox<T extends NamedAndDescribed>({resource, icon}: ResourceDescriptionBoxProps<T>): JSX.Element {
return React.useMemo(
() => (
<Box>
<Heading level={3}>
About <Idiomatic>{resource.value.name}</Idiomatic>
<FontAwesomeIcon icon={icon}/>&nbsp;About <Idiomatic>{resource.value.name}</Idiomatic>
</Heading>
<ReactMarkdown>
{resource.value.description}

View file

@ -20,10 +20,7 @@ export interface ResourceRouterProps<Resource> {
* @warning Due to some particular memoization, changes to `unselectedRoute` and `selectedRoute` will apply **only** when `selection` changes.
* @constructor
*/
export function ResourceRouter<Resource>({selection, unselectedRoute, selectedRoute}: ResourceRouterProps<Resource>): JSX.Element {
const UnselectedRoute = unselectedRoute
const SelectedRoute = selectedRoute
export function ResourceRouter<Resource>({selection, unselectedRoute: UnselectedRoute, selectedRoute: SelectedRoute}: ResourceRouterProps<Resource>): JSX.Element {
return React.useMemo(
() => {
if(selection) {