Skip to content

Commit 353c139

Browse files
committed
UI: Callout add fallback icons
1 parent 6e93136 commit 353c139

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

.changeset/calm-owls-double.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'fumadocs-ui': patch
3+
---
4+
5+
Callout add fallback icons

packages/ui/src/components/callout.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ type CalloutProps = Omit<
1818
icon?: ReactNode;
1919
};
2020

21+
const iconClass = 'size-5 -me-0.5 fill-(--callout-color) text-fd-card';
22+
2123
export const Callout = forwardRef<HTMLDivElement, CalloutProps>(
2224
({ className, children, title, type = 'info', icon, ...props }, ref) => {
2325
if (type === 'warn') type = 'warning';
24-
const DefaultIcon = {
25-
info: Info,
26-
warning: TriangleAlert,
27-
error: CircleX,
28-
success: CircleCheck,
29-
}[type];
26+
if ((type as unknown) === 'tip') type = 'info';
3027

3128
return (
3229
<div
@@ -38,17 +35,21 @@ export const Callout = forwardRef<HTMLDivElement, CalloutProps>(
3835
{...props}
3936
style={
4037
{
41-
'--callout-color': `var(--color-fd-${type})`,
38+
'--callout-color': `var(--color-fd-${type}, var(--color-fd-muted))`,
4239
...props.style,
4340
} as object
4441
}
4542
>
4643
<div role="none" className="w-0.5 bg-(--callout-color)/50 rounded-sm" />
47-
{icon ?? (
48-
<DefaultIcon className="size-5 -me-0.5 fill-(--callout-color) text-fd-card" />
49-
)}
44+
{icon ??
45+
{
46+
info: <Info className={iconClass} />,
47+
warning: <TriangleAlert className={iconClass} />,
48+
error: <CircleX className={iconClass} />,
49+
success: <CircleCheck className={iconClass} />,
50+
}[type]}
5051
<div className="flex flex-col gap-2 min-w-0 flex-1">
51-
{title ? <p className="font-medium !my-0">{title}</p> : null}
52+
{title && <p className="font-medium !my-0">{title}</p>}
5253
<div className="text-fd-muted-foreground prose-no-margin empty:hidden">
5354
{children}
5455
</div>

0 commit comments

Comments
 (0)