Skip to content

Commit e9e98bc

Browse files
committed
add download spinner
1 parent 9adde87 commit e9e98bc

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/components/liveseries/episodes-list/episode-download-indicator.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import type { Episode as TvMazeEpisode, Show as TvMazeShow } from "tvmaze-wrapper-ts";
44
import { useEffect, useState } from "react";
5-
import { DownloadIcon, TriangleIcon } from "lucide-react";
5+
import { CircleDashedIcon, CircleIcon, DownloadIcon, TriangleIcon } from "lucide-react";
66
import { useLocale, useTranslations } from "next-intl";
77

88
import type { DownloadedEpisode, DownloadStatusType } from "@/lib/types";
@@ -101,25 +101,37 @@ export function EpisodeDownloadIndicator({
101101
"text-accent2 cursor-help": downloadStatus === DownloadStatus.UNKNOWN,
102102
})}
103103
title={downloadTooltip}
104-
style={{ minWidth: 20 }}
104+
style={{
105+
minWidth: 20,
106+
transform: showProgress
107+
? `rotate(${90 + (metadata?.progress ?? 0) * 180}deg)`
108+
: undefined,
109+
}}
105110
onClick={downloadStatus === DownloadStatus.STOPPED ? startDownload : undefined}
106111
>
107112
{showProgress && (
108113
<div
109-
className="absolute overflow-hidden"
114+
className="transition-width absolute overflow-hidden duration-300"
110115
style={{
111116
width: `${100 * (metadata?.progress ?? 0)}%`,
112117
}}
113118
>
114-
<DownloadIcon
119+
<CircleIcon
115120
className={cn({
116121
"text-success": downloadStatus === DownloadStatus.PENDING,
117122
"text-accent2": downloadStatus === DownloadStatus.VERIFYING,
118123
})}
119-
></DownloadIcon>
124+
></CircleIcon>
120125
</div>
121126
)}
122-
<DownloadIcon />
127+
{downloadStatus === DownloadStatus.FAILED ||
128+
downloadStatus === DownloadStatus.UNKNOWN ? (
129+
<CircleDashedIcon />
130+
) : showProgress ? (
131+
<CircleIcon />
132+
) : (
133+
<DownloadIcon />
134+
)}
123135
</button>
124136
)}
125137
{!showProgress && user != null && (

0 commit comments

Comments
 (0)