Skip to content

Implement reusable leader links component #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions frontend/src/components/ui/LeadersLinks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Link } from '@chakra-ui/react'
import { LeaderLinksProps } from 'types/leader'

const LeaderLinks = ({ leaders }: LeaderLinksProps) => {
return (
<span>
{leaders.map((leader, index) => (
<span key={leader}>
<Link
href={`/community/users?q=${encodeURIComponent(leader)}`}
target="_blank"
className="text-blue-600 hover:underline dark:text-blue-400"
>
{leader}
</Link>
{index < leaders.length - 1 && ', '}
</span>
))}
</span>
)
}

export default LeaderLinks
3 changes: 2 additions & 1 deletion frontend/src/pages/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ErrorDisplay } from 'wrappers/ErrorWrapper'
import DetailsCard from 'components/CardDetailsPage'
import LoadingSpinner from 'components/LoadingSpinner'
import MetadataManager from 'components/MetadataManager'
import LeaderLinks from 'components/ui/LeadersLinks'
import { toaster } from 'components/ui/toaster'

const ProjectDetailsPage = () => {
Expand Down Expand Up @@ -63,7 +64,7 @@ const ProjectDetailsPage = () => {
)
const projectDetails = [
{ label: 'Last Updated', value: formatDate(project.updatedAt) },
{ label: 'Leaders', value: project.leaders.join(', ') },
{ label: 'Leaders', value: <LeaderLinks leaders={project.leaders} /> },
{
label: 'Level',
value: capitalize(project.level),
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/types/leader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface LeaderLinksProps {
leaders: string[]
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.