mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Add artist image lightbox
This commit is contained in:
parent
1823159b25
commit
84bbcdbfc2
@ -7,6 +7,7 @@ import CardMedia from '@material-ui/core/CardMedia'
|
|||||||
import ArtistExternalLinks from './ArtistExternalLink'
|
import ArtistExternalLinks from './ArtistExternalLink'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
import { LoveButton, RatingField } from '../common'
|
import { LoveButton, RatingField } from '../common'
|
||||||
|
import Lightbox from 'react-image-lightbox'
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
(theme) => ({
|
(theme) => ({
|
||||||
@ -32,6 +33,7 @@ const useStyles = makeStyles(
|
|||||||
cover: {
|
cover: {
|
||||||
width: 151,
|
width: 151,
|
||||||
borderRadius: '6em',
|
borderRadius: '6em',
|
||||||
|
cursor: 'pointer',
|
||||||
},
|
},
|
||||||
artistImage: {
|
artistImage: {
|
||||||
maxHeight: '9.5rem',
|
maxHeight: '9.5rem',
|
||||||
@ -66,6 +68,13 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
|
|||||||
const [expanded, setExpanded] = useState(false)
|
const [expanded, setExpanded] = useState(false)
|
||||||
const classes = useStyles({ img, expanded })
|
const classes = useStyles({ img, expanded })
|
||||||
const title = record.name
|
const title = record.name
|
||||||
|
const [isLightboxOpen, setLightboxOpen] = React.useState(false)
|
||||||
|
|
||||||
|
const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
|
||||||
|
const handleCloseLightbox = React.useCallback(
|
||||||
|
() => setLightboxOpen(false),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
@ -74,7 +83,8 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
|
|||||||
{artistInfo && (
|
{artistInfo && (
|
||||||
<CardMedia
|
<CardMedia
|
||||||
className={classes.cover}
|
className={classes.cover}
|
||||||
image={`${artistInfo.mediumImageUrl}`}
|
image={artistInfo.mediumImageUrl}
|
||||||
|
onClick={handleOpenLightbox}
|
||||||
title={title}
|
title={title}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -126,6 +136,15 @@ const DesktopArtistDetails = ({ img, artistInfo, record, biography }) => {
|
|||||||
<ArtistExternalLinks artistInfo={artistInfo} record={record} />
|
<ArtistExternalLinks artistInfo={artistInfo} record={record} />
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
|
{isLightboxOpen && (
|
||||||
|
<Lightbox
|
||||||
|
imagePadding={50}
|
||||||
|
animationDuration={200}
|
||||||
|
imageTitle={record.name}
|
||||||
|
mainSrc={artistInfo.largeImageUrl}
|
||||||
|
onCloseRequest={handleCloseLightbox}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -5,6 +5,7 @@ import Card from '@material-ui/core/Card'
|
|||||||
import CardMedia from '@material-ui/core/CardMedia'
|
import CardMedia from '@material-ui/core/CardMedia'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
import { LoveButton, RatingField } from '../common'
|
import { LoveButton, RatingField } from '../common'
|
||||||
|
import Lightbox from 'react-image-lightbox'
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
(theme) => ({
|
(theme) => ({
|
||||||
@ -77,6 +78,13 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
|
|||||||
const [expanded, setExpanded] = useState(false)
|
const [expanded, setExpanded] = useState(false)
|
||||||
const classes = useStyles({ img, expanded })
|
const classes = useStyles({ img, expanded })
|
||||||
const title = record.name
|
const title = record.name
|
||||||
|
const [isLightboxOpen, setLightboxOpen] = React.useState(false)
|
||||||
|
|
||||||
|
const handleOpenLightbox = React.useCallback(() => setLightboxOpen(true), [])
|
||||||
|
const handleCloseLightbox = React.useCallback(
|
||||||
|
() => setLightboxOpen(false),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -86,7 +94,8 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
|
|||||||
{artistInfo && (
|
{artistInfo && (
|
||||||
<CardMedia
|
<CardMedia
|
||||||
className={classes.cover}
|
className={classes.cover}
|
||||||
image={`${artistInfo.mediumImageUrl}`}
|
image={artistInfo.mediumImageUrl}
|
||||||
|
onClick={handleOpenLightbox}
|
||||||
title={title}
|
title={title}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -127,6 +136,15 @@ const MobileArtistDetails = ({ img, artistInfo, biography, record }) => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</div>
|
</div>
|
||||||
|
{isLightboxOpen && (
|
||||||
|
<Lightbox
|
||||||
|
imagePadding={50}
|
||||||
|
animationDuration={200}
|
||||||
|
imageTitle={record.name}
|
||||||
|
mainSrc={artistInfo.largeImageUrl}
|
||||||
|
onCloseRequest={handleCloseLightbox}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user