From 2304b05c08fc25a1b1988f15881e18c6c1d5d5ab Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 6 Dec 2024 14:01:06 +0800 Subject: [PATCH] More formatting for annual report --- src/locales/en.po | 4 ++-- src/pages/annual-report.css | 16 ++++++++++++---- src/pages/annual-report.jsx | 37 +++++++++++++++++++++++++++++++++---- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/locales/en.po b/src/locales/en.po index c10dba6a..34b2b02b 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -2268,7 +2268,7 @@ msgid "Failed to load history" msgstr "" #: src/components/status.jsx:3006 -#: src/pages/annual-report.jsx:44 +#: src/pages/annual-report.jsx:46 msgid "Loading…" msgstr "" @@ -2410,7 +2410,7 @@ msgid "Login required." msgstr "Login required." #: src/compose.jsx:90 -#: src/pages/annual-report.jsx:136 +#: src/pages/annual-report.jsx:165 #: src/pages/http-route.jsx:91 #: src/pages/login.jsx:270 msgid "Go home" diff --git a/src/pages/annual-report.css b/src/pages/annual-report.css index be765301..461f485a 100644 --- a/src/pages/annual-report.css +++ b/src/pages/annual-report.css @@ -31,8 +31,13 @@ table { width: 100%; - td, th { + td, + th { vertical-align: top; + + &.number { + text-align: end; + } } th { @@ -44,6 +49,10 @@ tr > * { border-top: 1px dashed var(--outline-color); + + ~ * { + padding-inline-start: 1ch; + } } } @@ -68,10 +77,9 @@ .status { pointer-events: none; - font-size: calc(var(--text-size) * .8); + font-size: calc(var(--text-size) * 0.8); } } - } } -} \ No newline at end of file +} diff --git a/src/pages/annual-report.jsx b/src/pages/annual-report.jsx index ee71ef40..3483e0c2 100644 --- a/src/pages/annual-report.jsx +++ b/src/pages/annual-report.jsx @@ -35,6 +35,8 @@ export default function AnnualReport() { const { accounts, annualReports, statuses } = results || {}; const report = annualReports?.find((report) => report.year == year)?.data; + const datePlaceholder = new Date(); + return (
@@ -54,8 +56,16 @@ export default function AnnualReport() { - {Object.keys(value[0]).map((key) => ( - + {Object.entries(value[0]).map(([key, value]) => ( + ))} @@ -63,7 +73,13 @@ export default function AnnualReport() { {value.map((item) => ( {Object.entries(item).map(([k, value]) => ( - - + ))}
{key} + {key} +
+ {value && /(accountId)/i.test(k) && /^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test( @@ -75,6 +91,13 @@ export default function AnnualReport() { )} showAvatar /> + ) : k === 'month' ? ( + datePlaceholder.setMonth(value - 1) && + datePlaceholder.toLocaleString(undefined, { + month: 'long', + }) + ) : typeof value === 'number' ? ( + value.toLocaleString() ) : ( value )} @@ -112,7 +135,13 @@ export default function AnnualReport() { {Object.entries(value).map(([k, value]) => (
{k}{value} + {value} +