mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
fix click handler on LibraryHeader image
This commit is contained in:
@@ -6,7 +6,7 @@ import { Link } from 'react-router';
|
|||||||
|
|
||||||
import styles from './library-header.module.css';
|
import styles from './library-header.module.css';
|
||||||
|
|
||||||
import { ItemImage } from '/@/renderer/components/item-image/item-image';
|
import { getItemImageUrl, ItemImage } from '/@/renderer/components/item-image/item-image';
|
||||||
import { useIsPlayerFetching } from '/@/renderer/features/player/context/player-context';
|
import { useIsPlayerFetching } from '/@/renderer/features/player/context/player-context';
|
||||||
import {
|
import {
|
||||||
PlayLastTextButton,
|
PlayLastTextButton,
|
||||||
@@ -23,6 +23,7 @@ import { Button } from '/@/shared/components/button/button';
|
|||||||
import { Center } from '/@/shared/components/center/center';
|
import { Center } from '/@/shared/components/center/center';
|
||||||
import { Group } from '/@/shared/components/group/group';
|
import { Group } from '/@/shared/components/group/group';
|
||||||
import { Icon } from '/@/shared/components/icon/icon';
|
import { Icon } from '/@/shared/components/icon/icon';
|
||||||
|
import { BaseImage } from '/@/shared/components/image/image';
|
||||||
import { Rating } from '/@/shared/components/rating/rating';
|
import { Rating } from '/@/shared/components/rating/rating';
|
||||||
import { Spinner } from '/@/shared/components/spinner/spinner';
|
import { Spinner } from '/@/shared/components/spinner/spinner';
|
||||||
import { Text } from '/@/shared/components/text/text';
|
import { Text } from '/@/shared/components/text/text';
|
||||||
@@ -75,39 +76,57 @@ export const LibraryHeader = forwardRef(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openImage = useCallback(() => {
|
const openImage = useCallback(() => {
|
||||||
if (imageUrl && !isImageError) {
|
const imageId = item.imageId;
|
||||||
const fullSized = imageUrl.replace(/&?(size|width|height)=\d+/, '');
|
const itemType = item.type as LibraryItem;
|
||||||
|
|
||||||
openModal({
|
if (!imageId || !itemType) {
|
||||||
children: (
|
return;
|
||||||
<Center
|
|
||||||
onClick={() => closeAllModals()}
|
|
||||||
style={{
|
|
||||||
cursor: 'pointer',
|
|
||||||
height: 'calc(100vh - 80px)',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<img
|
|
||||||
alt="cover"
|
|
||||||
src={fullSized}
|
|
||||||
style={{
|
|
||||||
maxHeight: '100%',
|
|
||||||
maxWidth: '100%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Center>
|
|
||||||
),
|
|
||||||
fullScreen: true,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, [imageUrl, isImageError]);
|
|
||||||
|
const imageUrl = getItemImageUrl({
|
||||||
|
id: imageId,
|
||||||
|
itemType,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!imageUrl) {
|
||||||
|
console.error('No image URL found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openModal({
|
||||||
|
children: (
|
||||||
|
<Center
|
||||||
|
onClick={() => closeAllModals()}
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
height: 'calc(100vh - 80px)',
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<BaseImage
|
||||||
|
alt="cover"
|
||||||
|
src={imageUrl}
|
||||||
|
style={{
|
||||||
|
maxHeight: '100%',
|
||||||
|
maxWidth: '100%',
|
||||||
|
objectFit: 'contain',
|
||||||
|
}}
|
||||||
|
unloaderIcon="emptyImage"
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
),
|
||||||
|
fullScreen: true,
|
||||||
|
});
|
||||||
|
}, [item.imageId, item.type]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(styles.libraryHeader, containerClassName)} ref={ref}>
|
<div className={clsx(styles.libraryHeader, containerClassName)} ref={ref}>
|
||||||
<div
|
<div
|
||||||
className={styles.imageSection}
|
className={styles.imageSection}
|
||||||
onClick={() => openImage()}
|
onClick={() => {
|
||||||
|
console.log('openImage');
|
||||||
|
openImage();
|
||||||
|
}}
|
||||||
onKeyDown={(event) =>
|
onKeyDown={(event) =>
|
||||||
[' ', 'Enter', 'Spacebar'].includes(event.key) && openImage()
|
[' ', 'Enter', 'Spacebar'].includes(event.key) && openImage()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user