Files
movie-advisor/components/ui/hint.tsx
T
nerandClaude Opus 5 6fc41c0901 feat: surface availability, airing progress and the director in preview
Movies get a theatre/stream/blu-ray icon in the info row, series get the
latest aired episode as S03 E07. Both reveal the relevant dates on hover or
tap through a shared Hint tooltip.

Release dates ride along on the details request via append_to_response and
the series fields are already in the tv payload, so neither indicator costs
an extra call. Theatre state is only claimed while the run can still be
current, otherwise a classic with no digital entry would read as in cinemas.

The credits carousel now opens with the director, read from the crew array
that the credits response already carries. A series has no single director,
so the one behind most episodes stands in.

Drop with_cast from the starring query: TMDB ANDs it with with_people, so
every director link would have resolved to an empty list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 19:46:51 +03:00

52 lines
1.6 KiB
TypeScript

'use client';
import { FC, ReactNode, useState } from 'react';
import { cn } from '@/lib/utils';
interface Props {
lines: string[];
children: ReactNode;
className?: string;
triggerClassName?: string;
}
const Hint: FC<Props> = ({ lines, children, className, triggerClassName }) => {
const [open, setOpen] = useState(false);
// an animation that lands on a transform turns this wrapper into a stacking context,
// so the tooltip can only reach above the following rows by raising the wrapper itself
return (
<span className={cn('relative z-10 inline-flex', className)}>
<button
type='button'
aria-label={lines.join('. ')}
className={cn('inline-flex cursor-help items-center', triggerClassName)}
// a tap fires pointerenter too, opening what the click would then toggle shut
onPointerEnter={({ pointerType }) => pointerType === 'mouse' && setOpen(true)}
onPointerLeave={({ pointerType }) => pointerType === 'mouse' && setOpen(false)}
onClick={() => setOpen((value) => !value)}
onBlur={() => setOpen(false)}
>
{children}
</button>
<span
role='tooltip'
aria-hidden={!open}
className={cn(
'pointer-events-none absolute left-1/2 top-full z-10 mt-1.5 -translate-x-1/2 whitespace-nowrap rounded-md border bg-popover px-2 py-1 text-xs text-popover-foreground shadow-md transition-opacity',
open ? 'opacity-100' : 'opacity-0'
)}
>
{lines.map((line) => (
<span key={line} className='block'>
{line}
</span>
))}
</span>
</span>
);
};
export default Hint;