import React from 'react'; import PropTypes from 'prop-types'; import { Spinner } from '@openedx/paragon'; import { FormattedMessage, useIntl, } from '@edx/frontend-platform/i18n'; // SelectableBox in paragon has a bug where you can't change selection. So we override it import SelectableBox from '../SelectableBox'; import messages from './messages'; import GalleryCard from './GalleryCard'; import GalleryLoadMoreButton from './GalleryLoadMoreButton'; const Gallery = ({ galleryIsEmpty, searchIsEmpty, displayList, highlighted, onHighlightChange, emptyGalleryLabel, showIdsOnCards, height, isLoaded, isLibrary, thumbnailFallback, allowLazyLoad, fetchNextPage, assetCount, }) => { const intl = useIntl(); if (!isLoaded && !allowLazyLoad) { return (
); } if (galleryIsEmpty) { return (
); } if (searchIsEmpty) { return (
); } return (
{displayList.map(asset => ( )) } {(allowLazyLoad && !isLibrary) && ( )}
); }; Gallery.defaultProps = { highlighted: '', showIdsOnCards: false, height: '375px', show: true, thumbnailFallback: undefined, allowLazyLoad: false, fetchNextPage: null, assetCount: 0, }; Gallery.propTypes = { show: PropTypes.bool, isLoaded: PropTypes.bool.isRequired, galleryIsEmpty: PropTypes.bool.isRequired, searchIsEmpty: PropTypes.bool.isRequired, displayList: PropTypes.arrayOf(PropTypes.shape({})).isRequired, highlighted: PropTypes.string, onHighlightChange: PropTypes.func.isRequired, emptyGalleryLabel: PropTypes.shape({}).isRequired, isLibrary: PropTypes.bool, showIdsOnCards: PropTypes.bool, height: PropTypes.string, thumbnailFallback: PropTypes.element, allowLazyLoad: PropTypes.bool, fetchNextPage: PropTypes.func, assetCount: PropTypes.number, }; export default Gallery;