Skip to content

Commit 84779d6

Browse files
juristrFrozenPandaz
authored andcommittedFeb 6, 2025
feat(nx-dev): allow link-card components to take an image URL
(cherry picked from commit 2f1b6f9)
1 parent aec9215 commit 84779d6

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed
 

Diff for: ‎nx-dev/ui-markdoc/src/lib/tags/cards.component.tsx

+15-8
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function LinkCard({
117117
}: {
118118
title: string;
119119
type: string;
120-
icon: string; // `icon` is the link to the SVG file
120+
icon: string; // Can be either a component name or a direct image URL
121121
url: string;
122122
appearance?: 'default' | 'small';
123123
}): JSX.Element {
@@ -138,13 +138,20 @@ export function LinkCard({
138138
}
139139
)}
140140
>
141-
{icon &&
142-
(frameworkIcons[icon as Framework]?.image ||
143-
callIfFunction(nxDevIcons[icon as keyof typeof nxDevIcons]) ||
144-
callIfFunction(
145-
(heroIcons[icon as keyof typeof heroIcons] as any)?.render,
146-
{ className: 'w-full h-full' }
147-
))}
141+
{icon.startsWith('/') ? (
142+
<img
143+
src={icon}
144+
alt={title}
145+
className="h-full w-full object-contain"
146+
/>
147+
) : (
148+
frameworkIcons[icon as Framework]?.image ||
149+
callIfFunction(nxDevIcons[icon as keyof typeof nxDevIcons]) ||
150+
callIfFunction(
151+
(heroIcons[icon as keyof typeof heroIcons] as any)?.render,
152+
{ className: 'w-full h-full' }
153+
)
154+
)}
148155
</div>
149156
)}
150157
<div

0 commit comments

Comments
 (0)
Please sign in to comment.