extract YearHint component; fix fetchPriority casing
This commit is contained in:
1 parent
3dc2ebfe53
commit
c3adad3fc4
3 files changed
+35
-7
No files matched your search
@@ -12,10 +12,10 @@ interface Props {
|
|||||||
priority?: boolean;
|
priority?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
type FetchPriorityProps = ImgHTMLAttributes<HTMLImageElement> & { fetchpriority?: 'high' | 'low' | 'auto' };
|
type FetchPriorityProps = ImgHTMLAttributes<HTMLImageElement> & { fetchPriority?: 'high' | 'low' | 'auto' };
|
||||||
|
|
||||||
const Poster: FC<Props> = ({ show, onClick, className, lazy = true, priority = false }) => {
|
const Poster: FC<Props> = ({ show, onClick, className, lazy = true, priority = false }) => {
|
||||||
const fetchPriorityProps: FetchPriorityProps = priority ? { fetchpriority: 'high' } : {};
|
const fetchPriorityProps: FetchPriorityProps = priority ? { fetchPriority: 'high' } : {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { FC } from 'react';
|
||||||
|
|
||||||
|
import Hint from '@/components/ui/hint';
|
||||||
|
import { getAvailabilityState, isUpcoming } from '@/data/dto/Availability';
|
||||||
|
import { formatDate } from '@/lib/utils';
|
||||||
|
|
||||||
|
function getLabels({ theatre, stream, bluray }: Availability, state: AvailabilityState) {
|
||||||
|
if (state === 'bluray') return [bluray ? `On Blu-ray since ${formatDate(bluray)}` : 'On Blu-ray'];
|
||||||
|
if (state === 'stream') return [stream ? `Streaming since ${formatDate(stream)}` : 'Streaming'];
|
||||||
|
if (theatre && isUpcoming(theatre)) return [`In theatres from ${formatDate(theatre)}`];
|
||||||
|
|
||||||
|
const announced = [
|
||||||
|
stream && isUpcoming(stream) && `Streaming from ${formatDate(stream)}`,
|
||||||
|
bluray && isUpcoming(bluray) && `Blu-ray from ${formatDate(bluray)}`
|
||||||
|
].filter(Boolean) as string[];
|
||||||
|
|
||||||
|
return ['In theatres only', ...(announced.length ? announced : ['Streaming date to be announced'])];
|
||||||
|
}
|
||||||
|
|
||||||
|
const YearHint: FC<{ show: Show & Partial<Details> }> = ({ show }) => {
|
||||||
|
const state = getAvailabilityState(show.availability!);
|
||||||
|
if (!state) return <span>{new Date(show.release).getFullYear()}</span>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Hint lines={getLabels(show.availability!, state)}>
|
||||||
|
<span>{new Date(show.release).getFullYear()}</span>
|
||||||
|
</Hint>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default YearHint;
|
||||||
@@ -11,7 +11,7 @@ import { cn } from '@/lib/utils';
|
|||||||
|
|
||||||
import Actions from './components/Actions';
|
import Actions from './components/Actions';
|
||||||
import Airing from './components/Airing';
|
import Airing from './components/Airing';
|
||||||
import Availability from './components/Availability';
|
import YearHint from './components/YearHint';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
show?: Show & Partial<Details>;
|
show?: Show & Partial<Details>;
|
||||||
@@ -55,10 +55,7 @@ const Preview: FC<Props> = ({
|
|||||||
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
|
<span className='order-3 mb-4 text-3xl md:order-1 md:line-clamp-2'>{show.title}</span>
|
||||||
|
|
||||||
<div className='order-3 mb-4 flex w-full flex-wrap items-center gap-5 whitespace-nowrap text-sm md:order-2'>
|
<div className='order-3 mb-4 flex w-full flex-wrap items-center gap-5 whitespace-nowrap text-sm md:order-2'>
|
||||||
<span>{new Date(show.release).getFullYear()}</span>
|
{Boolean(show.availability) ? <YearHint show={show} /> : <span>{new Date(show.release).getFullYear()}</span>}
|
||||||
{Boolean(show.availability) && (
|
|
||||||
<Availability availability={show.availability!} className='animate-fade-aside-slide-in opacity-0' />
|
|
||||||
)}
|
|
||||||
{Boolean(show.airing) && <Airing airing={show.airing!} className='animate-fade-aside-slide-in opacity-0' />}
|
{Boolean(show.airing) && <Airing airing={show.airing!} className='animate-fade-aside-slide-in opacity-0' />}
|
||||||
{Boolean(show.runtime) && (
|
{Boolean(show.runtime) && (
|
||||||
<span className='animate-fade-aside-slide-in opacity-0'>{show.runtime} minutes</span>
|
<span className='animate-fade-aside-slide-in opacity-0'>{show.runtime} minutes</span>
|
||||||
|
|||||||
Reference in new issue
Block a user