mirror of
https://github.com/Steffo99/sophon.git
synced 2024-12-22 14:54:22 +00:00
🔧 Add status text to the NotebookListBox
This commit is contained in:
parent
24f4b5847f
commit
750bdc5ca4
3 changed files with 38 additions and 1 deletions
4
frontend/src/components/elements/Empty.module.css
Normal file
4
frontend/src/components/elements/Empty.module.css
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
.Empty {
|
||||||
|
opacity: 0.5;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
18
frontend/src/components/elements/Empty.tsx
Normal file
18
frontend/src/components/elements/Empty.tsx
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import {faExpand} from "@fortawesome/free-solid-svg-icons"
|
||||||
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome"
|
||||||
|
import * as React from "react"
|
||||||
|
import Style from "./Empty.module.css"
|
||||||
|
|
||||||
|
|
||||||
|
export interface EmptyProps {
|
||||||
|
children: React.ReactNode,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function Empty({children}: EmptyProps): JSX.Element {
|
||||||
|
return (
|
||||||
|
<span className={Style.Empty}>
|
||||||
|
<FontAwesomeIcon icon={faExpand}/> {children}
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
|
@ -2,6 +2,8 @@ import {Box, Heading} from "@steffo/bluelib-react"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
import {ManagedViewSet} from "../../hooks/useManagedViewSet"
|
import {ManagedViewSet} from "../../hooks/useManagedViewSet"
|
||||||
import {SophonNotebook} from "../../types/SophonTypes"
|
import {SophonNotebook} from "../../types/SophonTypes"
|
||||||
|
import {Empty} from "../elements/Empty"
|
||||||
|
import {Loading} from "../elements/Loading"
|
||||||
import {NotebookResourcePanel} from "./NotebookResourcePanel"
|
import {NotebookResourcePanel} from "./NotebookResourcePanel"
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +13,19 @@ export interface NotebookListBoxProps {
|
||||||
|
|
||||||
|
|
||||||
export function NotebookListBox({viewSet}: NotebookListBoxProps): JSX.Element {
|
export function NotebookListBox({viewSet}: NotebookListBoxProps): JSX.Element {
|
||||||
|
const resources = React.useMemo(
|
||||||
|
() => {
|
||||||
|
if(!viewSet.resources) {
|
||||||
|
return <Loading/>
|
||||||
|
}
|
||||||
|
if(viewSet.resources.length === 0) {
|
||||||
|
return <Empty>This project has no notebooks.</Empty>
|
||||||
|
}
|
||||||
|
return viewSet.resources?.map(res => <NotebookResourcePanel resource={res} key={res.value.slug}/>)
|
||||||
|
},
|
||||||
|
[viewSet],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Heading level={3}>
|
<Heading level={3}>
|
||||||
|
@ -19,7 +34,7 @@ export function NotebookListBox({viewSet}: NotebookListBoxProps): JSX.Element {
|
||||||
<p>
|
<p>
|
||||||
Notebooks are interactive Python documents that you can edit in your browser and run on Sophon server.
|
Notebooks are interactive Python documents that you can edit in your browser and run on Sophon server.
|
||||||
</p>
|
</p>
|
||||||
{viewSet.resources?.map(res => <NotebookResourcePanel resource={res} key={res.value.slug}/>)}
|
{resources}
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue