Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/story/[storylineId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function StoryHeader({
) : storyline.last_plot_time ? (
<>
<div className="text-foreground text-sm font-bold leading-tight">
<DeadlineCountdown lastPlotTime={storyline.last_plot_time} hideLabel />
<DeadlineCountdown lastPlotTime={storyline.last_plot_time} hideLabel valueClassName="text-foreground text-sm font-bold" />
</div>
<div className="text-muted text-[9px]">Deadline</div>
</>
Expand Down
19 changes: 15 additions & 4 deletions src/components/DeadlineCountdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ import { useState, useEffect } from "react";
export const DEADLINE_HOURS = 168;
export const DEADLINE_MS = DEADLINE_HOURS * 60 * 60 * 1000;

export function DeadlineCountdown({ lastPlotTime, hideLabel }: { lastPlotTime: string; hideLabel?: boolean }) {
export function DeadlineCountdown({
lastPlotTime,
hideLabel,
valueClassName,
}: {
lastPlotTime: string;
hideLabel?: boolean;
valueClassName?: string;
}) {
const [remaining, setRemaining] = useState<number | null>(null);

useEffect(() => {
Expand All @@ -17,11 +25,14 @@ export function DeadlineCountdown({ lastPlotTime, hideLabel }: { lastPlotTime: s
return () => clearInterval(interval);
}, [lastPlotTime]);

const defaultValueClass = "text-accent font-medium";
const activeClass = valueClassName ?? defaultValueClass;

if (remaining === null) {
return (
<div className="text-xs">
{!hideLabel && <><span className="text-muted">Deadline:</span>{" "}</>}
<span className="text-accent font-medium">--</span>
<span className={activeClass}>--</span>
</div>
);
}
Expand All @@ -30,7 +41,7 @@ export function DeadlineCountdown({ lastPlotTime, hideLabel }: { lastPlotTime: s
return (
<div className="text-xs">
{!hideLabel && <><span className="text-muted">Deadline:</span>{" "}</>}
<span className="text-error font-medium">expired</span>
<span className={valueClassName ? `${valueClassName} text-error` : "text-error font-medium"}>expired</span>
</div>
);
}
Expand All @@ -52,7 +63,7 @@ export function DeadlineCountdown({ lastPlotTime, hideLabel }: { lastPlotTime: s
return (
<div className="text-xs">
{!hideLabel && <><span className="text-muted">Deadline:</span>{" "}</>}
<span className="text-accent font-medium">{formatted}</span>
<span className={activeClass}>{formatted}</span>
</div>
);
}
Expand Down
Loading