Skip to content

Commit b19c5a9

Browse files
committed
polish QueueList, prepping for duplication for Playlist featureset
1 parent 83944db commit b19c5a9

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

packages/react/src/components/player/QueueList.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ export function QueueList({ currentId }: { currentId?: string }) {
6161
</div>
6262
<div className="flex flex-col px-2">
6363
{queue.map((video) => (
64-
<VideoCard showDuration={false} size="sm" video={video} />
64+
<VideoCard
65+
showDuration={false}
66+
showStatus="available_at_only"
67+
size="list"
68+
video={video}
69+
/>
6570
))}
6671
</div>
6772
</div>

packages/react/src/components/video/VideoCard.tsx

+21-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { cn, makeThumbnailUrl, resizeChannelPhoto } from "@/lib/utils";
77
import React, { Suspense, useCallback, useMemo, useState } from "react";
88
import { useTranslation } from "react-i18next";
99
import { useDuration } from "@/hooks/useDuration";
10-
import { clsx } from "clsx";
1110
import { VideoThumbnail } from "./VideoThumbnail";
1211
import { usePreferredName } from "@/store/settings";
1312
import { useAtomValue } from "jotai";
@@ -51,6 +50,8 @@ interface VideoCardProps {
5150
*/
5251
onClick?: OnClickHandler;
5352
showDuration?: boolean;
53+
// showing the status of the video object (live now, # watching, or available_at time)
54+
showStatus?: boolean | "available_at_only";
5455
}
5556

5657
const LazyVideoCardPlaceholder = React.lazy(
@@ -64,6 +65,7 @@ export function VideoCard({
6465
size,
6566
onClick,
6667
showDuration = true,
68+
showStatus = true,
6769
}: VideoCardProps) {
6870
const isTwitchPlaceholder = video.link?.includes("twitch");
6971
const videoHref =
@@ -119,36 +121,37 @@ export function VideoCard({
119121

120122
const videoCardClasses = useMemo(
121123
() => ({
122-
outerLayer: clsx([
123-
"starting:opacity-0 opacity-100 transition-opacity duration-300",
124+
outerLayer: cn([
125+
"opacity-100 transition-opacity duration-300 starting:opacity-0",
124126
size == "list" && "rounded-sm hover:bg-base-3 @lg:px-2",
125-
(size == "list" || size == "sm") && "group relative flex gap-4 py-2",
127+
(size == "list" || size == "sm") &&
128+
"group relative flex gap-2 py-2 @lg:gap-4",
126129
(size == "md" || size == "lg") && "group flex w-full flex-col gap-4",
127130
onClick && "cursor-pointer",
128131
selectionMode &&
129132
(selectedSet?.has(video.id)
130-
? "ring-offset-base-2 ring-offset-2 ring-4 ring-primary-8 rounded-lg "
131-
: "ring-offset-base-2 ring-offset-2 ring-4 ring-base-6 rounded-lg saturate-[0.75] brightness-75 opacity-50"),
133+
? "rounded-lg ring-4 ring-primary-8 ring-offset-2 ring-offset-base-2 "
134+
: "rounded-lg opacity-50 ring-4 ring-base-6 ring-offset-2 ring-offset-base-2 brightness-75 saturate-[0.75]"),
132135
]),
133-
thumbnailLink: clsx([
136+
thumbnailLink: cn([
134137
size == "list" &&
135-
"@lg:w-36 relative aspect-video w-28 shrink-0 overflow-hidden",
136-
size == "sm" && "@lg:w-48 relative w-36 shrink-0 overflow-hidden",
138+
"relative aspect-video w-28 shrink-0 overflow-hidden @lg:w-36",
139+
size == "sm" && "relative w-36 shrink-0 overflow-hidden @lg:w-48",
137140
(size == "md" || size == "lg") && "relative w-full",
138141
]),
139-
videoTextInfo: clsx([
142+
videoTextInfo: cn([
140143
(size == "list" || size == "sm") && "flex flex-col gap-1",
141144
(size == "md" || size == "lg") &&
142145
"flex min-h-[6rem] cursor-pointer flex-col gap-0",
143146
]),
144-
titleLink: clsx([
147+
titleLink: cn([
145148
(size == "list" || size == "sm") &&
146-
"@lg:text-lg line-clamp-2 pr-4 text-sm font-bold",
149+
"line-clamp-2 pr-4 text-sm font-bold @lg:text-lg",
147150
(size == "md" || size == "lg") &&
148151
"line-clamp-2 pr-4 text-sm font-bold md:text-[1rem] md:leading-6",
149152
]),
150153
channelLink:
151-
"line-clamp-1 text-xs text-primary-11 hover:text-primary-12 @lg:text-sm",
154+
"line-clamp-1 text-sm text-primary-11 hover:text-primary-12 @lg:text-sm",
152155
scheduleText: "text-sm @lg:text-sm text-base-11",
153156
}),
154157
[size, onClick, selectionMode, selectedSet, video.id],
@@ -266,9 +269,12 @@ export function VideoCard({
266269
{chName}
267270
</Link>
268271
)}
269-
{size != "xs" && (
272+
{size != "xs" && showStatus && (
270273
<div className={videoCardClasses.scheduleText}>
271-
<VideoCardCountdownToLive video={video} />
274+
<VideoCardCountdownToLive
275+
video={video}
276+
onlyTime={showStatus === "available_at_only"}
277+
/>
272278
</div>
273279
)}
274280
</div>

packages/react/src/components/video/VideoCardCountdownToLive.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ const TimeTooltip = ({
8989
export function VideoCardCountdownToLive({
9090
video,
9191
className,
92+
onlyTime = false,
9293
}: {
9394
className?: string;
9495
video: VideoCardType;
96+
onlyTime?: boolean; // Only show time info, basically pretending it's a available_at only.
9597
}) {
9698
const { t } = useTranslation();
9799
const { dayjs } = useAtomValue(localeAtom);
@@ -101,7 +103,7 @@ export function VideoCardCountdownToLive({
101103
useInterval(() => setTime(Date.now()), 30000);
102104

103105
// Early return for live videos
104-
if (video.status === "live") {
106+
if (video.status === "live" && !onlyTime) {
105107
return (
106108
<LiveCounter
107109
viewers={video.live_viewers}
@@ -114,7 +116,8 @@ export function VideoCardCountdownToLive({
114116
// Handle upcoming videos
115117
if (
116118
(video.type === "placeholder" || video.status === "upcoming") &&
117-
video.start_scheduled
119+
video.start_scheduled &&
120+
!onlyTime
118121
) {
119122
const tick = dayjs(video.start_scheduled);
120123
const countdownText = t("time.diff_future_date", {
@@ -135,7 +138,7 @@ export function VideoCardCountdownToLive({
135138
}
136139

137140
// Handle past videos
138-
if (video.status === "past" && video.available_at) {
141+
if (onlyTime || (video.status === "past" && video.available_at)) {
139142
const tick = dayjs(video.available_at);
140143
const pastText = t("time.distance_past_date", {
141144
0: tick.fromNow(false),

0 commit comments

Comments
 (0)