sendou.ink/app/features/vods/components/VodListing.tsx
Kalle 30063f6075
VoDs (#1283)
* YouTube lite embed + CSS bundled import

* Migration initial

* New VoD page initial functioning

* Table changes + add TODOs

* New structure for add vod page

* WIP add new VoD backend

* Merge branch 'rewrite' of https://github.com/Sendouc/sendou.ink into vods

* Fix when leaderboard appears

* Function new vod form

* Single vod page initial

* Different YouTubeEmbed

* Scroll to top when going to timestamp

* Vod match weapon/mode icons

* Vod page user

* Add date to vod page

* Adjust migration order

* Vod page many weapons

* Add title to vod page

* New vods page cast many weapons

* Add player index to order by

* Vods new more validation

* Vod listing page initial

* Vods page with filters

* Show message if no vods

* Fix not being to unset filters

* Fix seed sometimes throwing errors

* User page VoDs

* Vods nullable weapon combobox

* Link directly to user custom url from vod page

* Make video adder admin action

* Can add video checks

* i18n

* New VoD form tests

* VoD operates filters test

* Vods behind flag

* Remove from config
2023-02-26 14:31:57 +02:00

68 lines
1.8 KiB
TypeScript

import { Link } from "@remix-run/react";
import { WeaponImage } from "~/components/Image";
import { useTranslation } from "~/hooks/useTranslation";
import { vodVideoPage } from "~/utils/urls";
import type { ListVod } from "../vods-types";
import { PovUser } from "./VodPov";
export function VodListing({
vod,
showUser = true,
}: {
vod: ListVod;
showUser?: boolean;
}) {
const { t } = useTranslation(["vods"]);
return (
<div className="vods__listing">
<Link to={vodVideoPage(vod.id)} className="stack sm">
<img alt="" src={youtubeIdToThumbnailUrl(vod.youtubeId)} />
<h2 className="text-sm text-main-forced">{vod.title}</h2>
</Link>
<div className="vods__listing__info">
{vod.type === "CAST" || !showUser ? (
<div className="vods__listing__cast-text">
{t(`vods:type.${vod.type}`)}
</div>
) : (
<PovUser pov={vod.pov} />
)}
<WeaponsPeek weapons={vod.weapons} />
</div>
</div>
);
}
const MAX_WEAPONS_TO_SHOW = 4;
function WeaponsPeek({ weapons }: { weapons: ListVod["weapons"] }) {
const limitedWeapons =
weapons.length <= MAX_WEAPONS_TO_SHOW
? weapons
: weapons.slice(0, MAX_WEAPONS_TO_SHOW - 1);
const amountOfWeaponsNotShown = weapons.length - limitedWeapons.length;
return (
<div className="stack horizontal xs">
{limitedWeapons.map((weapon) => (
<WeaponImage
key={weapon}
variant="build"
weaponSplId={weapon}
width={38}
/>
))}
{amountOfWeaponsNotShown > 0 ? (
<div className="vods__listing__weapons-not-shown">
+{amountOfWeaponsNotShown}
</div>
) : null}
</div>
);
}
function youtubeIdToThumbnailUrl(youtubeId: string) {
return `http://img.youtube.com/vi/${youtubeId}/maxresdefault.jpg`;
}