@macrostrat/column-components
Version:
React rendering primitives for stratigraphic columns
51 lines (50 loc) • 1.39 kB
JavaScript
import { createContext, useContext, useEffect } from "react";
import h from "@macrostrat/hyper";
const passThrough = (src) => src;
const PhotoLibraryContext = createContext({
photos: null,
computePhotoPath: passThrough
});
function PhotoLibraryProvider(props) {
const { children, computePhotoPath = passThrough, photos } = props;
return h(PhotoLibraryContext.Provider, {
value: {
photos,
computePhotoPath
},
children
});
}
function PhotoOverlay(props) {
const { photos, computePhotoPath } = useContext(PhotoLibraryContext);
if (photos == null) {
return null;
}
const { photoIDs, ...rest } = props;
const displayedPhotos = photoIDs.map((id) => {
return photos.find((d) => d.id === id);
});
const getPaths = function(d) {
const src = computePhotoPath(d);
return { src, caption: d.note };
};
const images = displayedPhotos.filter((d) => d != null).map(getPaths);
return h(PhotoGallery, {
images,
...rest
});
}
const PhotoGallery = function({ images, isOpen = false, onClose }) {
useEffect(() => {
console.error(
"PhotoOverlay from @macrostrat/column-components has been disabled due to an outdated design. Please use another library for this functionality."
);
}, []);
return null;
};
export {
PhotoLibraryContext,
PhotoLibraryProvider,
PhotoOverlay
};
//# sourceMappingURL=photos.js.map