Merge pull request #590 from rastislavcore/update/org-fix-01

Handle multiple organizations
This commit is contained in:
Ariful Alam 2024-05-19 13:42:03 +06:00 committed by GitHub
commit db2a2de1b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,12 +66,7 @@ const ListItem: React.FC<{
skeleton?: boolean; skeleton?: boolean;
}> = ({ icon, title, value, link, skeleton = false }) => { }> = ({ icon, title, value, link, skeleton = false }) => {
return ( return (
<a <div className="flex justify-start py-2 px-1 items-center">
href={link}
target="_blank"
rel="noreferrer"
className="flex justify-start py-2 px-1 items-center"
>
<div className="flex-grow font-medium gap-2 flex items-center my-1"> <div className="flex-grow font-medium gap-2 flex items-center my-1">
{icon} {title} {icon} {title}
</div> </div>
@ -82,10 +77,68 @@ const ListItem: React.FC<{
style={{ style={{
wordBreak: 'break-word', wordBreak: 'break-word',
}} }}
>
<a
href={link}
target="_blank"
rel="noreferrer"
className="flex justify-start py-2 px-1 items-center"
> >
{value} {value}
</div>
</a> </a>
</div>
</div>
);
};
const OrganizationItem: React.FC<{
icon: React.ReactNode;
title: React.ReactNode;
value: React.ReactNode | string;
link?: string;
skeleton?: boolean;
}> = ({ icon, title, value, link, skeleton = false }) => {
const renderValue = () => {
if (typeof value === 'string') {
return value.split(' ').map((company) => {
company = company.trim();
if (!company) return null;
if (isCompanyMention(company)) {
return (
<a
href={companyLink(company)}
target="_blank"
rel="noreferrer"
key={company}
>
{company}
</a>
);
} else {
return <span key={company}>{company}</span>;
}
});
}
return value;
};
return (
<div className="flex justify-start py-2 px-1 items-center">
<div className="flex-grow font-medium gap-2 flex items-center my-1">
{icon} {title}
</div>
<div
className={`${
skeleton ? 'flex-grow' : ''
} text-sm font-normal text-right mr-2 ml-3 space-x-2 ${link ? 'truncate' : ''}`}
style={{
wordBreak: 'break-word',
}}
>
{renderValue()}
</div>
</div>
); );
}; };
@ -132,9 +185,9 @@ const DetailsCard = ({ profile, loading, social, github }: Props) => {
/> />
)} )}
{profile.company && ( {profile.company && (
<ListItem <OrganizationItem
icon={<FaBuilding />} icon={<FaBuilding />}
title="Company:" title="Organization:"
value={profile.company} value={profile.company}
link={ link={
isCompanyMention(profile.company.trim()) isCompanyMention(profile.company.trim())