From 3caf56247f62e591ea2d482b60bd668f3d81ed62 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Wed, 1 Apr 2026 15:25:56 +0200 Subject: [PATCH] Refactor `profile-about` component structure to improve flexibility and simplify render logic, add `children` prop for custom content support. --- web/components/profile-about.tsx | 96 ++++++++++++++++---------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/web/components/profile-about.tsx b/web/components/profile-about.tsx index 5e0c1e7f..1d81ce7d 100644 --- a/web/components/profile-about.tsx +++ b/web/components/profile-about.tsx @@ -21,7 +21,7 @@ import {Profile} from 'common/profiles/profile' import {Socials} from 'common/socials' import {UserActivity} from 'common/user' import {capitalize} from 'lodash' -import {Home, Leaf} from 'lucide-react' +import {BarChart2, Home, Leaf} from 'lucide-react' import React, {ReactNode} from 'react' import {BiSolidDrink} from 'react-icons/bi' import {BsPersonVcard} from 'react-icons/bs' @@ -52,30 +52,36 @@ export function AboutRow(props: { preText?: string suffix?: string | null testId?: string + children?: ReactNode }) { const {icon, text, preText, suffix, testId} = props const t = useT() - if (!text?.length && !preText && !suffix) { - return <> - } - let formattedText = '' - if (preText) { - formattedText += preText - } - if (text?.length) { - formattedText += stringOrStringArrayToText({ - text: text, - preText: preText, - asSentence: false, - capitalizeFirstLetterOption: true, - t: t, - }) + let children = props.children + if (!children) { + if (!text?.length && !preText && !suffix) { + return <> + } + let formattedText = '' + if (preText) { + formattedText += preText + } + if (text?.length) { + formattedText += stringOrStringArrayToText({ + text: text, + preText: preText, + asSentence: false, + capitalizeFirstLetterOption: true, + t: t, + }) + } + children =
{formattedText}
} + return (
{icon}
- -
{formattedText}
+ + {children} {suffix &&
{capitalize(suffix)}
}
@@ -530,38 +536,30 @@ function Big5Traits(props: {profile: Profile}) { } return ( - -
- {t('profile.big5', 'Big Five personality traits')}: -
-
- {traits.map((trait) => { - if (trait.value === null || trait.value === undefined) return null + }> + +
{t('profile.big5', 'Big Five personality traits')}
+
+ {traits.map((trait) => { + if (trait.value === null || trait.value === undefined) return null - let levelText: string - if (trait.value <= 20) { - levelText = t('profile.big5_very_low', 'Very low') - } else if (trait.value <= 40) { - levelText = t('profile.big5_low', 'Low') - } else if (trait.value <= 60) { - levelText = t('profile.big5_average', 'Average') - } else if (trait.value <= 80) { - levelText = t('profile.big5_high', 'High') - } else { - levelText = t('profile.big5_very_high', 'Very high') - } - - return ( - -
{trait.icon}
-
- {trait.label}: {levelText} ({trait.value}) -
-
- ) - })} -
- + return ( + + {/*
{trait.icon}
*/} +
{trait.label}
+
+
+
+
{trait.value}
+ + ) + })} +
+ +
) }