|
| 1 | +import "swiper/css"; |
| 2 | +import "swiper/css/navigation"; |
| 3 | +import "swiper/css/pagination"; |
| 4 | + |
| 5 | +import { |
| 6 | + Homepage, |
| 7 | + Label, |
| 8 | + Metadata, |
| 9 | + PartOf, |
| 10 | + RequiredStatement, |
| 11 | + SeeAlso, |
| 12 | + Summary, |
| 13 | + Thumbnail, |
| 14 | +} from "src/components/Primitives"; |
| 15 | +import { |
| 16 | + IIIFExternalWebResource, |
| 17 | + InternationalString, |
| 18 | + Manifest, |
| 19 | + MetadataItem, |
| 20 | +} from "@iiif/presentation-3"; |
| 21 | +import { |
| 22 | + PrimitivesExternalWebResource, |
| 23 | + PrimitivesIIIFResource, |
| 24 | +} from "./types/primitives"; |
| 25 | +import React, { useEffect, useState } from "react"; |
| 26 | + |
| 27 | +import ReactDOM from "react-dom/client"; |
| 28 | +import Slider from "src/components/Slider"; |
| 29 | +import Viewer from "src/components/Viewer"; |
| 30 | + |
| 31 | +const App = () => { |
| 32 | + const [manifest, setManifest] = useState<Manifest>(); |
| 33 | + |
| 34 | + const manifestId = |
| 35 | + "https://api.dc.library.northwestern.edu/api/v2/works/71153379-4283-43be-8b0f-4e7e3bfda275?as=iiif"; |
| 36 | + const collectionId = |
| 37 | + "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif"; |
| 38 | + |
| 39 | + useEffect(() => { |
| 40 | + (async () => { |
| 41 | + const data = await fetch(manifestId).then((response) => response.json()); |
| 42 | + setManifest(data); |
| 43 | + })(); |
| 44 | + }, [manifest]); |
| 45 | + |
| 46 | + if (!manifest) return null; |
| 47 | + |
| 48 | + return ( |
| 49 | + <div style={{ padding: "1rem" }}> |
| 50 | + <Viewer iiifContent={manifestId} /> |
| 51 | + <Slider iiifContent={collectionId} /> |
| 52 | + <article> |
| 53 | + <Label label={manifest.label} as="h1" /> |
| 54 | + <Summary summary={manifest.summary as InternationalString} /> |
| 55 | + <Metadata metadata={manifest.metadata as MetadataItem[]} /> |
| 56 | + <RequiredStatement |
| 57 | + requiredStatement={manifest.requiredStatement as MetadataItem} |
| 58 | + /> |
| 59 | + <Homepage |
| 60 | + homepage={manifest.homepage as PrimitivesExternalWebResource[]} |
| 61 | + /> |
| 62 | + <PartOf partOf={manifest.partOf as PrimitivesIIIFResource[]} /> |
| 63 | + <SeeAlso |
| 64 | + seeAlso={manifest.seeAlso as PrimitivesExternalWebResource[]} |
| 65 | + /> |
| 66 | + <Thumbnail |
| 67 | + thumbnail={manifest.thumbnail as IIIFExternalWebResource[]} |
| 68 | + altAsLabel={manifest.label as InternationalString} |
| 69 | + /> |
| 70 | + </article> |
| 71 | + </div> |
| 72 | + ); |
| 73 | +}; |
| 74 | + |
| 75 | +ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( |
| 76 | + <React.StrictMode> |
| 77 | + <App /> |
| 78 | + </React.StrictMode> |
| 79 | +); |
0 commit comments