From c642ba62c4c855f0dad3e40deaf1b3dbeb9961cf Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 13 Oct 2021 04:45:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Generify=20`ResourceDescriptionBox`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 19 ++++++++--- .../generic/ResourceDescriptionBox.tsx | 32 +++++++++++++++++++ .../components/group/GroupDescriptionBox.tsx | 24 -------------- 3 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 frontend/src/components/generic/ResourceDescriptionBox.tsx delete mode 100644 frontend/src/components/group/GroupDescriptionBox.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d3bcf35..e0c420f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,8 +6,8 @@ import {AuthorizationRouter} from "./components/authorization/AuthorizationRoute import {AuthorizationStepPage} from "./components/authorization/AuthorizationStepPage" import {SophonFooter} from "./components/elements/SophonFooter" import {ErrorCatcherBox} from "./components/errors/ErrorCatcherBox" +import {ResourceDescriptionBox} from "./components/generic/ResourceDescriptionBox" import {GroupCreateBox} from "./components/group/GroupCreateBox" -import {GroupDescriptionBox} from "./components/group/GroupDescriptionBox" import {GroupListBox} from "./components/group/GroupListBox" import {GroupMembersBox} from "./components/group/GroupMembersBox" import {GroupRouter} from "./components/group/GroupRouter" @@ -36,7 +36,9 @@ function App({..._}: RouteComponentProps) { } selectedRoute={() => <> - + + + } selectedRoute={({selection}) => <> - + } selectedRoute={({selection}) => <> + + + } - selectedRoute={DebugBox} + unselectedRoute={({viewSet}) => <> + + } + selectedRoute={(props) => <> + + } /> } /> diff --git a/frontend/src/components/generic/ResourceDescriptionBox.tsx b/frontend/src/components/generic/ResourceDescriptionBox.tsx new file mode 100644 index 0000000..6e58c42 --- /dev/null +++ b/frontend/src/components/generic/ResourceDescriptionBox.tsx @@ -0,0 +1,32 @@ +import {Box, Heading, Idiomatic} from "@steffo/bluelib-react" +import * as React from "react" +import ReactMarkdown from "react-markdown" +import {ManagedResource} from "../../hooks/useManagedViewSet" + + +export interface NamedAndDescribed { + name: string, + description: string, +} + + +export interface ResourceDescriptionBoxProps { + resource: ManagedResource +} + + +export function ResourceDescriptionBox({resource}: ResourceDescriptionBoxProps): JSX.Element { + return React.useMemo( + () => ( + + + About {resource.value.name} + + + {resource.value.description} + + + ), + [resource], + ) +} diff --git a/frontend/src/components/group/GroupDescriptionBox.tsx b/frontend/src/components/group/GroupDescriptionBox.tsx deleted file mode 100644 index f90cb11..0000000 --- a/frontend/src/components/group/GroupDescriptionBox.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import {Box, Heading, Idiomatic} from "@steffo/bluelib-react" -import * as React from "react" -import ReactMarkdown from "react-markdown" -import {ManagedResource} from "../../hooks/useManagedViewSet" -import {SophonResearchGroup} from "../../types/SophonTypes" - - -export interface GroupDescriptionBoxProps { - resource: ManagedResource -} - - -export function GroupDescriptionBox({resource}: GroupDescriptionBoxProps): JSX.Element { - return ( - - - About {resource.value.name} - - - {resource.value.description} - - - ) -}