2023-07-24 14:38:56 -07:00
|
|
|
import { Group } from '@mantine/core';
|
2023-07-20 17:31:56 -07:00
|
|
|
import { forwardRef, ReactNode, Ref } from 'react';
|
2023-01-02 03:47:05 -08:00
|
|
|
import { Link } from 'react-router-dom';
|
2023-07-24 14:38:56 -07:00
|
|
|
import styles from './library-header.module.scss';
|
2023-01-05 21:59:07 -08:00
|
|
|
import { LibraryItem } from '/@/renderer/api/types';
|
2023-07-24 14:38:56 -07:00
|
|
|
import { Text } from '/@/renderer/components';
|
|
|
|
|
import { ItemImagePlaceholder } from '/@/renderer/features/shared/components/item-image-placeholder';
|
2023-01-02 03:47:05 -08:00
|
|
|
|
|
|
|
|
interface LibraryHeaderProps {
|
2023-07-01 19:10:05 -07:00
|
|
|
background: string;
|
|
|
|
|
children?: ReactNode;
|
|
|
|
|
imagePlaceholderUrl?: string | null;
|
|
|
|
|
imageUrl?: string | null;
|
|
|
|
|
item: { route: string; type: LibraryItem };
|
|
|
|
|
title: string;
|
2023-01-02 03:47:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const LibraryHeader = forwardRef(
|
2023-07-01 19:10:05 -07:00
|
|
|
(
|
|
|
|
|
{ imageUrl, imagePlaceholderUrl, background, title, item, children }: LibraryHeaderProps,
|
|
|
|
|
ref: Ref<HTMLDivElement>,
|
|
|
|
|
) => {
|
|
|
|
|
return (
|
2023-07-24 14:38:56 -07:00
|
|
|
<div
|
|
|
|
|
ref={ref}
|
|
|
|
|
className={styles.libraryHeader}
|
2023-01-02 03:47:05 -08:00
|
|
|
>
|
2023-07-24 14:38:56 -07:00
|
|
|
<div
|
|
|
|
|
className={styles.background}
|
|
|
|
|
style={{ background }}
|
|
|
|
|
/>
|
|
|
|
|
<div className={styles.backgroundOverlay} />
|
|
|
|
|
<div className={styles.imageSection}>
|
2023-07-01 19:10:05 -07:00
|
|
|
{imageUrl ? (
|
2023-08-06 12:02:13 -07:00
|
|
|
<img
|
2023-07-01 19:10:05 -07:00
|
|
|
alt="cover"
|
2023-07-24 14:38:56 -07:00
|
|
|
className={styles.image}
|
2023-07-01 19:10:05 -07:00
|
|
|
placeholder={imagePlaceholderUrl || 'var(--placeholder-bg)'}
|
|
|
|
|
src={imageUrl}
|
2023-07-24 14:38:56 -07:00
|
|
|
style={{ height: '' }}
|
2023-07-01 19:10:05 -07:00
|
|
|
/>
|
|
|
|
|
) : (
|
2023-07-24 14:38:56 -07:00
|
|
|
<ItemImagePlaceholder itemType={item.type} />
|
2023-07-01 19:10:05 -07:00
|
|
|
)}
|
2023-07-24 14:38:56 -07:00
|
|
|
</div>
|
|
|
|
|
<div className={styles.metadataSection}>
|
2023-07-01 19:10:05 -07:00
|
|
|
<Group>
|
|
|
|
|
<Text
|
|
|
|
|
$link
|
|
|
|
|
component={Link}
|
|
|
|
|
to={item.route}
|
|
|
|
|
tt="uppercase"
|
|
|
|
|
weight={600}
|
|
|
|
|
>
|
|
|
|
|
{item.type}
|
|
|
|
|
</Text>
|
|
|
|
|
</Group>
|
2023-07-24 14:38:56 -07:00
|
|
|
<h1 className={styles.title}>{title}</h1>
|
2023-07-01 19:10:05 -07:00
|
|
|
{children}
|
2023-07-24 14:38:56 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-07-01 19:10:05 -07:00
|
|
|
);
|
|
|
|
|
},
|
2023-01-02 03:47:05 -08:00
|
|
|
);
|