diff --git a/ui/src/album/AlbumDetails.jsx b/ui/src/album/AlbumDetails.jsx index 534b176c0..f55d94ffc 100644 --- a/ui/src/album/AlbumDetails.jsx +++ b/ui/src/album/AlbumDetails.jsx @@ -20,7 +20,7 @@ import Lightbox from 'react-image-lightbox' import config from '../config' import 'react-image-lightbox/style.css' import subsonic from '../subsonic' -import { CoverImage } from '../common/CoverImage' +import { Artwork } from '../common/Artwork' import { ArtistLinkField, CollapsibleComment, @@ -248,7 +248,7 @@ const AlbumDetails = (props) => {
- ({ @@ -136,7 +136,7 @@ const Cover = withContentRect('bounds')(({ return (
- ( - + )} linkType={'show'} @@ -173,7 +173,7 @@ const AlbumTableView = ({ /> ) : ( - + {columns} { /> ) : ( - + linkType(id)}> - + ({ @@ -90,7 +90,7 @@ const DesktopArtistDetails = ({ artistInfo, record, biography }) => { {artistInfo && ( - ({ @@ -93,7 +93,7 @@ const MobileArtistDetails = ({ artistInfo, biography, record }) => {
{artistInfo && ( - . -export const CoverImage = ({ +export const Artwork = ({ record, size = config.uiCoverArtSize, square = false, @@ -107,7 +107,7 @@ export const CoverImage = ({ ) } -CoverImage.propTypes = { +Artwork.propTypes = { record: PropTypes.object, size: PropTypes.number, square: PropTypes.bool, diff --git a/ui/src/common/CoverImage.test.jsx b/ui/src/common/Artwork.test.jsx similarity index 82% rename from ui/src/common/CoverImage.test.jsx rename to ui/src/common/Artwork.test.jsx index 93bd18f64..7ced75f4c 100644 --- a/ui/src/common/CoverImage.test.jsx +++ b/ui/src/common/Artwork.test.jsx @@ -8,7 +8,7 @@ vi.mock('../subsonic', () => ({ vi.mock('../config', () => ({ default: { uiCoverArtSize: 300 } })) import { useImageUrl } from './useImageUrl' -import { CoverImage } from './CoverImage' +import { Artwork } from './Artwork' const withArt = { id: 'al-1', @@ -16,7 +16,7 @@ const withArt = { blurHash: 'LEHV6nWB2yk8pyo0adR*.7kCMdnj', } -describe('CoverImage', () => { +describe('Artwork', () => { beforeEach(() => { vi.clearAllMocks() // jsdom has no 2D context; stub it so BlurHashCanvas bails cleanly without console noise @@ -25,29 +25,27 @@ describe('CoverImage', () => { it('renders nothing without a record', () => { useImageUrl.mockReturnValue({ imgUrl: null, loading: false }) - const { container } = render() + const { container } = render() expect(container.firstChild).toBeNull() }) it('shows the blurhash and no while loading', () => { useImageUrl.mockReturnValue({ imgUrl: null, loading: true }) - const { container } = render() + const { container } = render() expect(container.querySelector('canvas')).not.toBeNull() expect(container.querySelector('img')).toBeNull() }) it('shows neither a broken nor a canvas while loading a record with no blurhash', () => { useImageUrl.mockReturnValue({ imgUrl: null, loading: true }) - const { container } = render( - , - ) + const { container } = render() expect(container.querySelector('img')).toBeNull() expect(container.querySelector('canvas')).toBeNull() }) it('mounts the image only once its blob is ready', () => { useImageUrl.mockReturnValue({ imgUrl: 'blob:abc', loading: false }) - const { container } = render() + const { container } = render() const img = container.querySelector('img') expect(img).not.toBeNull() expect(img.getAttribute('src')).toBe('blob:abc') @@ -57,11 +55,11 @@ describe('CoverImage', () => { vi.useFakeTimers() try { useImageUrl.mockReturnValue({ imgUrl: null, loading: true }) - const { container, rerender } = render() + const { container, rerender } = render() // Blob arrives: the image mounts transparent, with the blurhash still behind it. useImageUrl.mockReturnValue({ imgUrl: 'blob:abc', loading: false }) - rerender() + rerender() const img = container.querySelector('img') expect(img).not.toBeNull() expect(container.querySelector('canvas')).not.toBeNull() @@ -87,7 +85,7 @@ describe('CoverImage', () => { it('does not fade an image that was already cached on mount', () => { useImageUrl.mockReturnValue({ imgUrl: 'blob:abc', loading: false }) - const { container } = render() + const { container } = render() // No placeholder to cross-fade from, so it paints at once. expect(container.querySelector('canvas')).toBeNull() expect(container.querySelector('img').className).toContain('imgInstant') @@ -95,9 +93,9 @@ describe('CoverImage', () => { it('keeps the blurhash visible when the image never decodes', () => { useImageUrl.mockReturnValue({ imgUrl: null, loading: true }) - const { container, rerender } = render() + const { container, rerender } = render() useImageUrl.mockReturnValue({ imgUrl: 'blob:abc', loading: false }) - rerender() + rerender() expect(container.querySelector('canvas')).not.toBeNull() }) @@ -106,13 +104,13 @@ describe('CoverImage', () => { const onClick = vi.fn() useImageUrl.mockReturnValue({ imgUrl: null, loading: true }) const { container, rerender } = render( - , + , ) container.firstChild.click() expect(onClick).not.toHaveBeenCalled() useImageUrl.mockReturnValue({ imgUrl: 'blob:abc', loading: false }) - rerender() + rerender() container.firstChild.click() expect(onClick).toHaveBeenCalledTimes(1) }) diff --git a/ui/src/common/CoverArtAvatar.jsx b/ui/src/common/ArtworkAvatar.jsx similarity index 78% rename from ui/src/common/CoverArtAvatar.jsx rename to ui/src/common/ArtworkAvatar.jsx index aab5d566d..7691050c6 100644 --- a/ui/src/common/CoverArtAvatar.jsx +++ b/ui/src/common/ArtworkAvatar.jsx @@ -2,7 +2,7 @@ import { useRecordContext } from 'react-admin' import { makeStyles } from '@material-ui/core/styles' import clsx from 'clsx' import config from '../config' -import { CoverImage } from './CoverImage' +import { Artwork } from './Artwork' const useStyles = makeStyles({ avatar: { @@ -17,17 +17,14 @@ const useStyles = makeStyles({ }, }) -export const CoverArtAvatar = ({ - record: recordProp, - variant = 'circular', -}) => { +export const ArtworkAvatar = ({ record: recordProp, variant = 'circular' }) => { const classes = useStyles() const recordContext = useRecordContext() const record = recordProp || recordContext if (!record) return null const square = variant !== 'circular' return ( - ({ @@ -106,7 +106,7 @@ const PlaylistDetails = (props) => {
- { bulkActionButtons={!isXsmall && } > isWritable(r?.ownerId)}> - + {columns} diff --git a/ui/src/radio/RadioList.jsx b/ui/src/radio/RadioList.jsx index b127e84a8..0cfb2cd68 100644 --- a/ui/src/radio/RadioList.jsx +++ b/ui/src/radio/RadioList.jsx @@ -21,7 +21,7 @@ import { ToggleFieldsMenu, useSelectedFields, } from '../common' -import { CoverImage } from '../common/CoverImage' +import { Artwork } from '../common/Artwork' import { StreamField } from './StreamField' import { setTrack } from '../actions' import { songFromRadio } from './helper' @@ -92,7 +92,7 @@ const CoverArtField = ({ record }) => { // Radios resolve art only from an uploaded image; otherwise show the generic radio icon. if (record.uploadedImage) { return ( -