Skip to content

Commit

Permalink
refactor: make the link tag optional on learning card
Browse files Browse the repository at this point in the history
Signed-off-by: jerensl <[email protected]>
  • Loading branch information
jerensl committed Oct 10, 2024
1 parent ab91647 commit 7d5c9c6
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.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 href={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 7d5c9c6

Please sign in to comment.