From 6c2085e1e673b3658ced7429c0b6d27316e361e8 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 26 Jul 2024 21:11:36 +0200 Subject: [PATCH] Nicer formatting of global stats badges (#235) --- .../datasetSummary/datasetSamples.tsx | 4 +- .../home/homeMidSection/homeMidSection.tsx | 55 +++++++++++-------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/src/components/browse/dataset/datasetAccordion/datasetSummary/datasetSamples.tsx b/src/components/browse/dataset/datasetAccordion/datasetSummary/datasetSamples.tsx index 92401889..62327a97 100644 --- a/src/components/browse/dataset/datasetAccordion/datasetSummary/datasetSamples.tsx +++ b/src/components/browse/dataset/datasetAccordion/datasetSummary/datasetSamples.tsx @@ -31,8 +31,8 @@ const DatasetSamples = (props: DataSetSamplesProps) => { {stats.sex.length > 0 ? ( <> (Sex:  - {stats.sex.map((x, idx, arr) => { - const sex = /FEMALE/.test(x.value) ? "Female" : "Male"; + {stats.sex.map((x, idx) => { + const sex = x.value.toLowerCase(); return ( {`${idx ? ", " : ""} ${x.count} ${sex}`} diff --git a/src/components/home/homeMidSection/homeMidSection.tsx b/src/components/home/homeMidSection/homeMidSection.tsx index bc82e635..4bff0bc8 100644 --- a/src/components/home/homeMidSection/homeMidSection.tsx +++ b/src/components/home/homeMidSection/homeMidSection.tsx @@ -104,16 +104,20 @@ const HomeMidSection = () => { badgeDark: true, }); - const protocolTypes = - summary?.resource_stats?.ExperimentMethod?.stats?.instrument_model || []; + const experimentMethods = summary?.resource_stats?.ExperimentMethod; + const protocolTypes = experimentMethods?.stats?.instrument_model || []; Badges.push({ badgeTitle: BadgeTitleGen(faDna, "Platforms: " + protocolTypes.length), - badgeBody: protocolTypes.map((x: any) => ( - - {x.value}: - {x.count} - - )), + badgeBody: ( + + {protocolTypes.map((x) => ( + + + + + ))} +
{x.count}{x.value}
+ ), bodyColClasses: "pt-3 fs-7 align-items-center", }); @@ -122,15 +126,16 @@ const HomeMidSection = () => { const individualSexes = individuals?.stats?.sex || []; Badges.push({ badgeTitle: BadgeTitleGen(faUser, "Individuals: " + numIndividuals, true), - badgeBody: individualSexes.map((x, i) => { - const sex = /FEMALE/.test(x.value) ? "Female" : "Male"; - return ( - - {sex}: - {x.count} - - ); - }), + badgeBody: ( + + {individualSexes.map((x) => ( + + + + + ))} +
{x.count}{x.value.toLowerCase()}
+ ), badgeDark: true, bodyColClasses: "pt-3 fs-7 align-items-center", }); @@ -138,12 +143,16 @@ const HomeMidSection = () => { const fileStats = aggregateFileStats(summary); Badges.push({ badgeTitle: BadgeTitleGen(faChartColumn, "Files: " + fileStats.count), - badgeBody: fileStats.stats.format.map((x) => ( - - {x.value}: - {x.count} - - )), + badgeBody: ( + + {fileStats.stats.format.map((x) => ( + + + + + ))} +
{x.count}{x.value}
+ ), bodyColClasses: "pt-3 fs-7 align-items-center", }); }