Skip to content

Commit

Permalink
Merge pull request #754 from jerensl/learning-card
Browse files Browse the repository at this point in the history
refactor: make the link tag optional on learning card
  • Loading branch information
leecalcote authored Oct 17, 2024
2 parents e427107 + 20983da commit 21bed8a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/custom/LearningCard/LearningCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ interface Tutorial {

interface Props {
tutorial: Tutorial;
path: string;
path?: string;
courseCount: number;
courseType: string;
}

const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string }>> = ({ path, children }) => {
if (!path) {
return <>{children}</>;
}

return <CardLink href={path}>{children}</CardLink>;
};

const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType }) => {
return (
<CardWrapper>
Expand Down Expand Up @@ -57,7 +65,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
</CardParent>
</Card2>
) : (
<CardLink href={path}>
<OptionalLink path={path}>
<CardActive>
<CardParent style={{ borderTop: `5px solid ${tutorial.frontmatter.themeColor}` }}>
<div>
Expand Down Expand Up @@ -88,7 +96,7 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
</div>
</CardParent>
</CardActive>
</CardLink>
</OptionalLink>
)}
</CardWrapper>
);
Expand Down

0 comments on commit 21bed8a

Please sign in to comment.