-
Notifications
You must be signed in to change notification settings - Fork 0
Feat(router): Add placeholder page for ARK loader #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| import { Outlet } from "react-router"; | ||
| import Header from "./Header"; | ||
| import Navbar from "./NavBar"; | ||
|
|
||
| export function Layout({ children }: { children: React.ReactNode }) { | ||
| export function Layout() { | ||
| return ( | ||
| <> | ||
| <Navbar /> | ||
| <Header /> | ||
| {children} | ||
| <Outlet /> | ||
| </> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import CircularProgress from "@mui/material/CircularProgress"; | ||
| import Container from "@mui/material/Container"; | ||
|
|
||
| export function Loader() { | ||
| return ( | ||
| <Container | ||
| maxWidth="sm" | ||
| sx={{ | ||
| display: "flex", | ||
| justifyContent: "center", | ||
| alignItems: "center", | ||
| flexGrow: 1, | ||
| }} | ||
| > | ||
| <CircularProgress size={48} /> | ||
| </Container> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import { Viewer } from "@istex/react-tei/Viewer.js"; | ||
| import KeyboardBackspaceIcon from "@mui/icons-material/KeyboardBackspace"; | ||
| import Alert from "@mui/material/Alert"; | ||
| import Button from "@mui/material/Button"; | ||
| import Container from "@mui/material/Container"; | ||
| import Link from "@mui/material/Link"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { type LoaderFunction, useLoaderData } from "react-router"; | ||
| import document from "./document/minimal.tei.xml?raw"; | ||
| import unitexEnrichment from "./document/minimal.unitex.xml?raw"; | ||
|
|
||
| export type ArkViewerLoaderData = { | ||
| document: string | null; | ||
| unitexEnrichment?: string | null; | ||
| teeftEnrichment?: string | null; | ||
| multicatEnrichment?: string | null; | ||
| nbEnrichment?: string | null; | ||
| }; | ||
|
|
||
| export const arkViewerLoader: LoaderFunction = async ({ | ||
| params, | ||
| }): Promise<ArkViewerLoaderData> => { | ||
| const { id } = params; | ||
|
|
||
| /** | ||
| * Simulate loading time | ||
| * @todo In a real app, you would fetch the document by its id here | ||
| */ | ||
| await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
|
|
||
| if (!id) { | ||
| return { | ||
| document: null, | ||
| }; | ||
| } | ||
|
|
||
| return { | ||
| document, | ||
| unitexEnrichment, | ||
| }; | ||
| }; | ||
|
|
||
| export function ArkViewer() { | ||
| const { document, ...rest } = useLoaderData<ArkViewerLoaderData>(); | ||
|
|
||
| if (!document) { | ||
| return <DocumentNotFound />; | ||
| } | ||
|
|
||
| return ( | ||
| <Viewer | ||
| document={document} | ||
| {...rest} | ||
| height="calc(100dvh - 49.5px - 118.5px)" | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| function DocumentNotFound() { | ||
| const { t } = useTranslation(); | ||
| return ( | ||
| <Container | ||
| maxWidth="sm" | ||
| sx={{ | ||
| display: "flex", | ||
| justifyContent: "center", | ||
| alignItems: "center", | ||
| flexDirection: "column", | ||
| gap: 2, | ||
| flexGrow: 1, | ||
| }} | ||
| > | ||
| <Alert | ||
| severity="warning" | ||
| sx={{ | ||
| width: "100%", | ||
| }} | ||
| > | ||
| {t("ark.documentNotFound")} | ||
| </Alert> | ||
| <Button | ||
| component={Link} | ||
| href="https://search.istex.fr/fr-FR" | ||
| fullWidth | ||
| variant="contained" | ||
| startIcon={<KeyboardBackspaceIcon />} | ||
| > | ||
| {t("ark.goToIstexSearch")} | ||
| </Button> | ||
| </Container> | ||
| ); | ||
| } | ||
76 changes: 76 additions & 0 deletions
76
packages/demo/src/modules/ark-viewer/document/minimal.tei.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| <TEI version="3.3.0" xmlns="http://www.tei-c.org/ns/1.0"> | ||
| <teiHeader> | ||
| <fileDesc> | ||
| <titleStmt> | ||
| <title>The shortest TEI Document Imaginable</title> | ||
| </titleStmt> | ||
| <publicationStmt> | ||
| <p>First published as part of TEI P2, this is the P5 | ||
| version using a namespace.</p> | ||
| </publicationStmt> | ||
| <sourceDesc> | ||
| <p>No source: this is an original work.</p> | ||
| </sourceDesc> | ||
| </fileDesc> | ||
| </teiHeader> | ||
| <text> | ||
| <body> | ||
| <div> | ||
| <head>Correspondance simple</head> | ||
| <p>lorem ipsum Gustave Eiffel</p> | ||
|
|
||
| <head>Entité encadrée par une ponctuation</head> | ||
| <p>lorem ipsum (Gustave Eiffel)</p> | ||
|
|
||
| <head>Entité suivie d'une ponctuation</head> | ||
| <p>Gustave Eiffel, lorem ipsum</p> | ||
|
|
||
| <head>Entité avec abréviation</head> | ||
| <p>Eiffel G., lorem ipsum</p> | ||
|
|
||
| <head>Entité contenant un caractère HTML</head> | ||
| <p>Gustave	Eiffel, lorem ipsum</p> | ||
| </div> | ||
| <div> | ||
| <head>Juxtaposition</head> | ||
| <p>Gustave Eiffel Marie Curie</p> | ||
| </div> | ||
| <div> | ||
| <head>Rendition complète : L'intégralité de l'entité est formatée</head> | ||
| <p>lorem ipsum <hi rend="bold">Gustave Eiffel</hi></p> | ||
|
|
||
| <head>Rendition partielle : L'entité est partiellement formatée</head> | ||
| <p>lorem ipsum (Gustave <hi rend="bold">Eiffel</hi>)</p> | ||
|
|
||
| <head>Rendition imbriquée : Renditions imbriquées sur l'entité</head> | ||
| <p>lorem ipsum (<hi rend="italic">Gustave <hi rend="bold">Eiffel</hi></hi>)</p> | ||
| </div> | ||
| <div> | ||
| <head>Inclusion totale : Une entité est complètement incluse dans une autre</head> | ||
| <p>Laboratoire Marie Curie de l'Université Saclay</p> | ||
| </div> | ||
| <div> | ||
| <head>Overlap : Une entité est partiellement incluse dans une autre</head> | ||
| <p>Université Gustave Eiffel, lorem ipsum</p> | ||
| </div> | ||
|
|
||
| <div> | ||
| <head>Titre avec annotation: Gustave Eiffel</head> | ||
| <p>Gustave Eiffel</p> | ||
| </div> | ||
| <div> | ||
| <head> | ||
| Overlap: deux annotations du même groupe se chevauchent partiellement | ||
| </head> | ||
| <p>Gustave Eiffel G.</p> | ||
| </div> | ||
| <div> | ||
| <head> | ||
| Overlap: deux annotations de groupes différents se chevauchent | ||
| partiellement | ||
| </head> | ||
| <p>Université Gustave Eiffel G.</p> | ||
| </div> | ||
| </body> | ||
| </text> | ||
| </TEI> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.