movie-web/__old/parts/VideoPlayerHeader.tsx

69 lines
2.2 KiB
TypeScript
Raw Normal View History

import { MWMediaMeta } from "@/backend/metadata/types";
import { IconPatch } from "@/components/buttons/IconPatch";
2023-01-10 00:27:04 +01:00
import { Icon, Icons } from "@/components/Icon";
import { BrandPill } from "@/components/layout/BrandPill";
import {
getIfBookmarkedFromPortable,
useBookmarkContext,
} from "@/state/bookmark";
import { AirplayControl } from "../controls/AirplayControl";
import { ChromeCastControl } from "../controls/ChromeCastControl";
2023-01-10 00:27:04 +01:00
interface VideoPlayerHeaderProps {
media?: MWMediaMeta;
2023-01-10 00:27:04 +01:00
onClick?: () => void;
isMobile?: boolean;
2023-01-10 00:27:04 +01:00
}
export function VideoPlayerHeader(props: VideoPlayerHeaderProps) {
const { bookmarkStore, setItemBookmark } = useBookmarkContext();
const isBookmarked = props.media
? getIfBookmarkedFromPortable(bookmarkStore.bookmarks, props.media)
: false;
const showDivider = props.media && props.onClick;
2023-01-10 00:27:04 +01:00
return (
<div className="flex items-center">
<div className="flex flex-1 items-center">
<p className="flex items-center">
2023-01-10 21:18:10 +01:00
{props.onClick ? (
<span
onClick={props.onClick}
className="flex cursor-pointer items-center py-1 text-white opacity-50 transition-opacity hover:opacity-100"
>
<Icon className="mr-2" icon={Icons.ARROW_LEFT} />
<span>Back to home</span>
</span>
) : null}
{showDivider ? (
<span className="mx-4 h-6 w-[1.5px] rotate-[30deg] bg-white opacity-50" />
) : null}
{props.media ? (
<span className="flex items-center text-white">
<span>{props.media.title}</span>
</span>
2023-01-10 21:18:10 +01:00
) : null}
2023-01-10 00:27:04 +01:00
</p>
{props.media && (
<IconPatch
clickable
transparent
icon={isBookmarked ? Icons.BOOKMARK : Icons.BOOKMARK_OUTLINE}
className="ml-2 text-white"
onClick={() =>
props.media && setItemBookmark(props.media, !isBookmarked)
}
/>
)}
2023-01-10 00:27:04 +01:00
</div>
{props.isMobile ? (
<>
<AirplayControl />
<ChromeCastControl />
</>
) : (
<BrandPill />
)}
2023-01-10 00:27:04 +01:00
</div>
);
}