MCPcopy Create free account
hub / github.com/pacexy/flow / Block

Function Block

apps/reader/src/components/viewlets/ImageView.tsx:30–73  ·  view source on GitHub ↗
({ section })

Source from the content-addressed store, hash-verified

28 section: ISection
29}
30const Block: React.FC<BlockProps> = ({ section }) => {
31 const { focusedBookTab } = useReaderSnapshot()
32 const [expanded, toggle] = useBoolean(false)
33
34 const resources = focusedBookTab?.epub?.resources
35 if (!resources) return null
36
37 const blobs = resources.replacementUrls
38 const assets = resources.assets
39
40 return (
41 <div>
42 <Row badge expanded={expanded} toggle={toggle} subitems={section.images}>
43 {section.navitem?.label}
44 </Row>
45
46 {expanded && (
47 <div>
48 {section.images.map((src) => {
49 const i = assets.findIndex((a: any) => src.includes(a.href))
50 const asset = assets[i]
51 const blob = blobs[i]
52
53 if (!blob) return null
54 return (
55 <img
56 className="w-full cursor-pointer px-5 py-2"
57 key={i}
58 src={blob}
59 alt={asset.href}
60 onClick={() => {
61 reader.focusedBookTab?.displayFromSelector(
62 `img[src*="${asset.href}"]`,
63 section,
64 )
65 }}
66 />
67 )
68 })}
69 </div>
70 )}
71 </div>
72 )
73}

Callers

nothing calls this directly

Calls 3

useReaderSnapshotFunction · 0.90
mapMethod · 0.80
displayFromSelectorMethod · 0.80

Tested by

no test coverage detected