ui: home carousel height lock + bubble polish

- Home: lock category carousel height to the tallest page so the
  Official Recommendations section below does not jump up when
  swiping to a page with fewer categories.
- CollapsibleText: raise default threshold to 25 lines and tighten
  the spacing between the expand-all button and the timestamp
  (drop the fixed h-8 and use mt-1 instead of mt-1.5).
- formatTime: always render dates as yyyy/m/d HH:mm regardless of
  locale, matching the requested timestamp format.
This commit is contained in:
TerryM
2026-05-30 00:43:54 +08:00
parent c0068e957e
commit d7e2e56cde
4 changed files with 19 additions and 33 deletions

View File

@@ -1,34 +1,17 @@
function localeFor(lang: string): string {
const locales: Record<string, string> = {
zh: "zh-CN",
en: "en-US",
ja: "ja-JP",
ko: "ko-KR",
vi: "vi-VN",
id: "id-ID",
ms: "ms-MY",
};
return locales[lang] ?? "en-US";
function pad2(n: number): string {
return String(n).padStart(2, "0");
}
function formatDate(iso: string, lang: string): string {
function formatDate(iso: string): string {
const d = new Date(iso);
return new Intl.DateTimeFormat(localeFor(lang), {
year: "numeric",
month: lang === "en" ? "short" : "numeric",
day: "numeric",
}).format(d);
return `${d.getFullYear()}/${d.getMonth() + 1}/${d.getDate()}`;
}
export function formatTime(iso: string, lang: string): string {
export function formatTime(iso: string): string {
const d = new Date(iso);
return new Intl.DateTimeFormat(localeFor(lang), {
hour: "numeric",
minute: "2-digit",
hour12: lang === "en",
}).format(d);
return `${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
}
export function formatDateTime(iso: string, lang: string): string {
return `${formatDate(iso, lang)} ${formatTime(iso, lang)}`;
export function formatDateTime(iso: string): string {
return `${formatDate(iso)} ${formatTime(iso)}`;
}