Skip to content

Commit

Permalink
More formatting for annual report
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Dec 6, 2024
1 parent 4e1572f commit 2304b05
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/locales/en.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions src/pages/annual-report.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@
table {
width: 100%;

td, th {
td,
th {
vertical-align: top;

&.number {
text-align: end;
}
}

th {
Expand All @@ -44,6 +49,10 @@

tr > * {
border-top: 1px dashed var(--outline-color);

~ * {
padding-inline-start: 1ch;
}
}
}

Expand All @@ -68,10 +77,9 @@

.status {
pointer-events: none;
font-size: calc(var(--text-size) * .8);
font-size: calc(var(--text-size) * 0.8);
}
}

}
}
}
}
37 changes: 33 additions & 4 deletions src/pages/annual-report.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div id="annual-report-page" class="deck-container" tabIndex="-1">
<div class="report">
Expand All @@ -54,16 +56,30 @@ export default function AnnualReport() {
<table>
<thead>
<tr>
{Object.keys(value[0]).map((key) => (
<th>{key}</th>
{Object.entries(value[0]).map(([key, value]) => (
<th
class={
key !== 'month' && typeof value === 'number'
? 'number'
: ''
}
>
{key}
</th>
))}
</tr>
</thead>
<tbody>
{value.map((item) => (
<tr>
{Object.entries(item).map(([k, value]) => (
<td>
<td
class={
k !== 'month' && typeof value === 'number'
? 'number'
: ''
}
>
{value &&
/(accountId)/i.test(k) &&
/^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test(
Expand All @@ -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
)}
Expand Down Expand Up @@ -112,7 +135,13 @@ export default function AnnualReport() {
{Object.entries(value).map(([k, value]) => (
<tr>
<th>{k}</th>
<td>{value}</td>
<td
class={
typeof value === 'number' ? 'number' : ''
}
>
{value}
</td>
</tr>
))}
</tbody>
Expand Down

0 comments on commit 2304b05

Please sign in to comment.