diff --git a/public/assets/ark-library/figma/official-recommendation-cover.png b/public/assets/ark-library/figma/official-recommendation-cover.png new file mode 100644 index 0000000..bf0fef6 Binary files /dev/null and b/public/assets/ark-library/figma/official-recommendation-cover.png differ diff --git a/src/components/FigmaBanner.tsx b/src/components/FigmaBanner.tsx index c195d94..85ca6a3 100644 --- a/src/components/FigmaBanner.tsx +++ b/src/components/FigmaBanner.tsx @@ -9,11 +9,7 @@ import { const FIGMA_ASSET_BASE = "/assets/ark-library/figma"; export const officialRecommendationCoverFallbacks = [ - `${FIGMA_ASSET_BASE}/official-recommendation-1.png`, - `${FIGMA_ASSET_BASE}/official-recommendation-2.png`, - `${FIGMA_ASSET_BASE}/official-recommendation-3.png`, - `${FIGMA_ASSET_BASE}/official-recommendation-4.png`, - `${FIGMA_ASSET_BASE}/official-recommendation-5.png`, + `${FIGMA_ASSET_BASE}/official-recommendation-cover.png`, ] as const; type BannerSlide = { diff --git a/src/components/RecommendedCard.tsx b/src/components/RecommendedCard.tsx index 35eb1ff..3557f4a 100644 --- a/src/components/RecommendedCard.tsx +++ b/src/components/RecommendedCard.tsx @@ -4,8 +4,8 @@ import type { Resource } from "../api"; import { assetUrl } from "../api"; import { useI18n } from "../i18n"; import { useMemo, useState } from "react"; -import { cleanCategoryDisplayName } from "../utils/categoryDisplay"; import { formatDateYmd } from "../utils/format"; +import { DownloadCloudIcon } from "./icons/DownloadCloudIcon"; import { officialRecommendationCoverFallbacks } from "./FigmaBanner"; import { downloadAttachment, @@ -17,7 +17,7 @@ function isPlaceholderAsset(path: string | undefined | null) { } const CARD_CLASS = - "group flex w-[208px] shrink-0 flex-col overflow-hidden rounded-xl border border-transparent bg-[#1D1E23] transition hover:border-ark-gold/55 md:w-[240px] md:border-ark-line md:bg-ark-panel lg:w-[246.4px] min-[1100px]:max-xl:w-[273px] xl:w-[246.4px]"; + "group flex w-[208px] shrink-0 flex-col overflow-hidden rounded-xl border bg-[#1D1E23] transition hover:border-ark-gold/55 md:w-[240px] lg:w-[246.4px] min-[1100px]:max-xl:w-[273px] xl:w-[246.4px]"; type RecommendedResource = Resource & { downloadPostId?: string; @@ -48,7 +48,7 @@ export function RecommendedCard({ return assetUrl(original); }, [figmaCover, r.coverImage, r.previewUrl, useFigmaDesign]); const displayTitle = r.title; - const displayCategoryName = cleanCategoryDisplayName(r.categoryName); + const displayCategoryName = r.categoryName; const dateStr = formatDateYmd(r.updatedAt); const dateTime = r.updatedAt; @@ -57,11 +57,37 @@ export function RecommendedCard({ ? assetUrl(r.fileUrl || r.previewUrl) : ""; + const handleDownload = async () => { + if (isDownloading) return; + setIsDownloading(true); + try { + if (r.downloadPostId && r.downloadAttachmentId) { + await downloadAttachment( + r.downloadPostId, + r.downloadAttachmentId, + displayTitle, + ); + return; + } + await downloadFile(dl, displayTitle); + } catch { + /* ignore */ + } finally { + setIsDownloading(false); + } + }; + return ( -
+
{cover ? ( )} - {r.badgeLabel ? ( + {!useFigmaDesign && r.badgeLabel ? ( {r.badgeLabel} ) : null} -
- +
+ + {displayTitle} + + {useFigmaDesign ? ( +
+ {displayCategoryName} +
+ ) : null} +
+
- {displayTitle} - -
-
- {displayCategoryName} - · +
+ {useFigmaDesign ? null : ( + <> + {displayCategoryName} + · + + )}
{dl ? (
); }