Skip to content

Commit 847aa2f

Browse files
Improve offline download UX and localize IBM Plex Mono (#579)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent b22d5c1 commit 847aa2f

12 files changed

Lines changed: 222 additions & 10 deletions

packages/workshop-app/app/components/epic-video.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,14 @@ function EpicVideo({
702702
}, [offlineVideoFetcher.state, offlineVideoFetcher.data, revalidator])
703703

704704
const handleDownload = React.useCallback(() => {
705-
toast.success(
706-
`Download of ${title} has started (${downloadResolutionLabel} quality).`,
705+
if (!isOnline) {
706+
toast.error('Cannot download while offline', {
707+
description: 'Reconnect to the internet and try again.',
708+
})
709+
return
710+
}
711+
toast.info(
712+
`Starting download for ${title} (${downloadResolutionLabel} quality).`,
707713
{
708714
description: (
709715
<span>
@@ -731,6 +737,7 @@ function EpicVideo({
731737
title,
732738
urlString,
733739
downloadResolutionLabel,
740+
isOnline,
734741
])
735742

736743
const handleDelete = React.useCallback(() => {
@@ -754,6 +761,7 @@ function EpicVideo({
754761
const offlineActions = showOfflineActions ? (
755762
<OfflineVideoActionButtons
756763
isAvailable={offlineVideoAvailable}
764+
isDownloadAvailable={isOnline}
757765
isBusy={isOfflineActionBusy}
758766
downloadProgress={downloadProgress}
759767
downloadSizeBytes={downloadSizeBytes}

packages/workshop-app/app/components/offline-video-actions.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function DeleteIcon(props: React.ComponentPropsWithoutRef<'svg'>) {
4444

4545
export type OfflineVideoActionButtonsProps = {
4646
isAvailable: boolean
47+
isDownloadAvailable?: boolean
4748
isBusy?: boolean
4849
downloadSizeBytes?: number | null
4950
/**
@@ -57,12 +58,14 @@ export type OfflineVideoActionButtonsProps = {
5758

5859
export function OfflineVideoActionButtons({
5960
isAvailable,
61+
isDownloadAvailable = true,
6062
isBusy = false,
6163
downloadSizeBytes,
6264
downloadProgress,
6365
onDownload,
6466
onDelete,
6567
}: OfflineVideoActionButtonsProps) {
68+
const isDownloadUnavailable = !isAvailable && !isDownloadAvailable
6669
const isDownloading = isBusy && !isAvailable
6770
const showProgressIndicator = isDownloading
6871
const downloadSizeLabel =
@@ -75,18 +78,23 @@ export function OfflineVideoActionButtons({
7578
? downloadProgress !== undefined
7679
? `Downloading: ${Math.round(downloadProgress)}%`
7780
: 'Downloading...'
78-
: `Download offline video${downloadSizeLabel}`
81+
: isDownloadUnavailable
82+
? 'Reconnect to download offline video'
83+
: `Download offline video${downloadSizeLabel}`
7984
const onClick = isAvailable ? onDelete : onDownload
8085
const className = isAvailable
8186
? 'text-foreground-destructive hover:bg-foreground-destructive/10'
82-
: 'text-foreground hover:bg-muted'
87+
: isDownloadUnavailable
88+
? 'text-muted-foreground'
89+
: 'text-foreground hover:bg-muted'
90+
const isDisabled = isBusy || isDownloadUnavailable
8391

8492
return (
8593
<SimpleTooltip content={label}>
8694
<button
8795
type="button"
8896
onClick={onClick}
89-
disabled={isBusy}
97+
disabled={isDisabled}
9098
className={`${className} inline-flex h-7 w-7 items-center justify-center rounded disabled:cursor-not-allowed disabled:opacity-50`}
9199
aria-label={label}
92100
>

packages/workshop-app/app/root.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ import { getToast } from './utils/toast.server'
6767
export const links: LinksFunction = () => {
6868
return [
6969
{ rel: 'stylesheet', href: '/neogrotesk-font.css' },
70-
{
71-
rel: 'stylesheet',
72-
href: 'https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,200;0,300;0,400;0,500;0,600;1,700&display=swap',
73-
},
70+
{ rel: 'stylesheet', href: '/ibm-plex-mono-font.css' },
7471
{ rel: 'stylesheet', href: tailwindStylesheetUrl },
7572
{ rel: 'stylesheet', href: appStylesheetUrl },
7673
{

packages/workshop-app/public/app-default.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* This is used by default for non-server apps */
22

33
@import ('/neogrotesk-font.css');
4+
@import ('/ibm-plex-mono-font.css');
45

56
html {
67
font-family:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)