mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
fullscreen header image on click
This commit is contained in:
parent
9b95f47a91
commit
a8fb7ff11e
1 changed files with 42 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import { forwardRef, ReactNode, Ref, useState } from 'react';
|
import { forwardRef, ReactNode, Ref, useCallback, useState } from 'react';
|
||||||
import { Group } from '@mantine/core';
|
import { Center, Group } from '@mantine/core';
|
||||||
|
import { closeAllModals, openModal } from '@mantine/modals';
|
||||||
import { AutoTextSize } from 'auto-text-size';
|
import { AutoTextSize } from 'auto-text-size';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
@ -58,6 +59,35 @@ export const LibraryHeader = forwardRef(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openImage = useCallback(() => {
|
||||||
|
if (imageUrl && !isImageError) {
|
||||||
|
const fullSized = imageUrl.replace(/&?(size|width|height)=\d+/, '');
|
||||||
|
|
||||||
|
openModal({
|
||||||
|
children: (
|
||||||
|
<Center
|
||||||
|
style={{
|
||||||
|
cursor: 'pointer',
|
||||||
|
height: 'calc(100vh - 80px)',
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
onClick={() => closeAllModals()}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
alt="cover"
|
||||||
|
src={fullSized}
|
||||||
|
style={{
|
||||||
|
maxHeight: '100%',
|
||||||
|
maxWidth: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Center>
|
||||||
|
),
|
||||||
|
fullScreen: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [imageUrl, isImageError]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
|
|
@ -72,7 +102,16 @@ export const LibraryHeader = forwardRef(
|
||||||
[styles.opaqueOverlay]: albumBackground,
|
[styles.opaqueOverlay]: albumBackground,
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<div className={styles.imageSection}>
|
<div
|
||||||
|
className={styles.imageSection}
|
||||||
|
role="button"
|
||||||
|
style={{ cursor: 'pointer' }}
|
||||||
|
tabIndex={0}
|
||||||
|
onClick={() => openImage()}
|
||||||
|
onKeyDown={(event) =>
|
||||||
|
['Spacebar', ' ', 'Enter'].includes(event.key) && openImage()
|
||||||
|
}
|
||||||
|
>
|
||||||
{imageUrl && !isImageError ? (
|
{imageUrl && !isImageError ? (
|
||||||
<img
|
<img
|
||||||
alt="cover"
|
alt="cover"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue