diff --git a/src/LazyHydrate.js b/src/LazyHydrate.js index c7b0d3d1..64b467d3 100644 --- a/src/LazyHydrate.js +++ b/src/LazyHydrate.js @@ -28,8 +28,7 @@ if (isBrowser()) { will be removed. */ export function LazyStyles() { - const amp = useAmp() - if (amp) return null + if (useAmp()) return null let styles = null try { @@ -91,11 +90,8 @@ Router.events.on('routeChangeStart', () => { }) function LazyHydrateInstance({ id, className, ssrOnly, children, on, ...props }) { - const amp = useAmp() - function isHydrated() { if (isBrowser()) { - if (amp) return true // If rendering after client side navigation if (window.__lazyHydrateNavigated) return true // return true @@ -216,6 +212,7 @@ function LazyHydrateInstance({ id, className, ssrOnly, children, on, ...props }) */ function LazyHydrate({ children, ...props }) { + if (useAmp()) return children return ( {/* LazyStylesProvider should not be used in the browser. Once components diff --git a/src/carousel/CarouselThumbnails.js b/src/carousel/CarouselThumbnails.js index 6a962754..3a5f7d57 100644 --- a/src/carousel/CarouselThumbnails.js +++ b/src/carousel/CarouselThumbnails.js @@ -127,6 +127,7 @@ function CarouselThumbnails({ classes, className, thumbnailPosition, + ImageComponent, }) { const styles = useStyles({ classes }) const theme = useTheme() @@ -152,7 +153,7 @@ function CarouselThumbnails({ }} > {thumbnails.map(({ src, alt }, i) => { - const icon = {alt} + const icon = return ( ({ * An element that determines the proper tag to use for a media node within a * [`Carousel`](/apiReference/carousel/Carousel). */ -export default function Media({ +function Media({ magnifyProps, imageProps, videoProps, @@ -29,6 +29,8 @@ export default function Media({ magnify, sources, type = 'image', + ImageComponent, + ImageMagnifyComponent, }) { const classes = useStyles() @@ -69,7 +71,7 @@ export default function Media({ } } else if (magnify) { return ( - ) } else { - return {alt} + return } } @@ -127,4 +129,21 @@ Media.propTypes = { * If `false`, the media is not able to be magnified. */ magnify: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]), + + /** + * The component type to use to display images. + */ + ImageComponent: PropTypes.elementType, + + /** + * The component type to use to display magnified images. + */ + ImageMagnifyComponent: PropTypes.elementType, +} + +Media.defaultProps = { + ImageComponent: Image, + ImageMagnifyComponent: ReactImageMagnify, } + +export default Media diff --git a/src/carousel/MediaCarousel.js b/src/carousel/MediaCarousel.js index 404b3590..b1449e3e 100644 --- a/src/carousel/MediaCarousel.js +++ b/src/carousel/MediaCarousel.js @@ -1,10 +1,8 @@ -import { light } from '@material-ui/core/styles/createPalette' import PropTypes from 'prop-types' import React, { useCallback, useEffect, useState, useRef } from 'react' import clsx from 'clsx' import { makeStyles, useTheme } from '@material-ui/core/styles' import useMediaQuery from '@material-ui/core/useMediaQuery' -import Fill from '../Fill' import Carousel from './Carousel' import Image from '../Image' import Lightbox from './Lightbox' @@ -142,6 +140,7 @@ function MediaCarousel(props) { magnifyProps, id, CarouselComponent, + ImageComponent, MediaComponent, CarouselThumbnailsComponent, ...others @@ -212,7 +211,7 @@ function MediaCarousel(props) { if (thumbnail && !imagesLoaded) { belowAdornments.push( -