Skip to content

Commit

Permalink
Add artist image lightbox
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Oct 31, 2021
1 parent 1823159 commit 84bbcdb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
21 changes: 20 additions & 1 deletion ui/src/artist/DesktopArtistDetails.js
Expand Up @@ -7,6 +7,7 @@ import CardMedia from '@material-ui/core/CardMedia'
import ArtistExternalLinks from './ArtistExternalLink'
import config from '../config'
import { LoveButton, RatingField } from '../common'
import Lightbox from 'react-image-lightbox'

const useStyles = makeStyles(
(theme) => ({
Expand All @@ -32,6 +33,7 @@ const useStyles = makeStyles(
cover: {
width: 151,
borderRadius: '6em',
cursor: 'pointer',
},
artistImage: {
maxHeight: '9.5rem',
Expand Down Expand Up @@ -66,6 +68,13 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
const [expanded, setExpanded] = useState(false)
const classes = useStyles({ img, expanded })
const title = record.name
const [isLightboxOpen, setLightboxOpen] = React.useState(false)

const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
const handleCloseLightbox = React.useCallback(
() => setLightboxOpen(false),
[]
)

return (
<div className={classes.root}>
Expand All @@ -74,7 +83,8 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
{artistInfo && (
<CardMedia
className={classes.cover}
image={`${artistInfo.mediumImageUrl}`}
image={artistInfo.mediumImageUrl}
onClick={handleOpenLightbox}
title={title}
/>
)}
Expand Down Expand Up @@ -126,6 +136,15 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
<ArtistExternalLinks artistInfo={artistInfo} record={record} />
</Typography>
</div>
{isLightboxOpen && (
<Lightbox
imagePadding={50}
animationDuration={200}
imageTitle={record.name}
mainSrc={artistInfo.largeImageUrl}
onCloseRequest={handleCloseLightbox}
/>
)}
</Card>
</div>
)
Expand Down
20 changes: 19 additions & 1 deletion ui/src/artist/MobileArtistDetails.js
Expand Up @@ -5,6 +5,7 @@ import Card from '@material-ui/core/Card'
import CardMedia from '@material-ui/core/CardMedia'
import config from '../config'
import { LoveButton, RatingField } from '../common'
import Lightbox from 'react-image-lightbox'

const useStyles = makeStyles(
(theme) => ({
Expand Down Expand Up @@ -77,6 +78,13 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
const [expanded, setExpanded] = useState(false)
const classes = useStyles({ img, expanded })
const title = record.name
const [isLightboxOpen, setLightboxOpen] = React.useState(false)

const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
const handleCloseLightbox = React.useCallback(
() => setLightboxOpen(false),
[]
)

return (
<>
Expand All @@ -86,7 +94,8 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
{artistInfo && (
<CardMedia
className={classes.cover}
image={`${artistInfo.mediumImageUrl}`}
image={artistInfo.mediumImageUrl}
onClick={handleOpenLightbox}
title={title}
/>
)}
Expand Down Expand Up @@ -127,6 +136,15 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
</Typography>
</Collapse>
</div>
{isLightboxOpen && (
<Lightbox
imagePadding={50}
animationDuration={200}
imageTitle={record.name}
mainSrc={artistInfo.largeImageUrl}
onCloseRequest={handleCloseLightbox}
/>
)}
</>
)
}
Expand Down

0 comments on commit 84bbcdb

Please sign in to comment.