UNPKG

@macrostrat/column-components

Version:

React rendering primitives for stratigraphic columns

53 lines (52 loc) 1.7 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const React = require("react"); const h = require("@macrostrat/hyper"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const h__default = /* @__PURE__ */ _interopDefault(h); const passThrough = (src) => src; const PhotoLibraryContext = React.createContext({ photos: null, computePhotoPath: passThrough }); function PhotoLibraryProvider(props) { const { children, computePhotoPath = passThrough, photos } = props; return h__default.default(PhotoLibraryContext.Provider, { value: { photos, computePhotoPath }, children }); } function PhotoOverlay(props) { const { photos, computePhotoPath } = React.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__default.default(PhotoGallery, { images, ...rest }); } const PhotoGallery = function({ images, isOpen = false, onClose }) { React.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; }; exports.PhotoLibraryContext = PhotoLibraryContext; exports.PhotoLibraryProvider = PhotoLibraryProvider; exports.PhotoOverlay = PhotoOverlay; //# sourceMappingURL=photos.cjs.map