Skip to content

Commit c1d7484

Browse files
committed
feat: add favicons to sidebar;
1 parent 66d75ec commit c1d7484

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

apps/basket/src/hooks/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from './auth';
1111

1212
// Mock the logger to prevent console output during tests
13-
vi.mock('../lib/logger', () => ({
13+
vi.mock('../../lib/logger', () => ({
1414
logger: {
1515
warn: vi.fn(),
1616
error: vi.fn(),

apps/dashboard/components/analytics/favicon-image.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface FaviconImageProps {
99
altText?: string;
1010
size?: number;
1111
className?: string;
12+
fallbackIcon?: React.ReactNode;
1213
}
1314

1415
const hostnameRegex = /^https?:\/\//;
@@ -19,6 +20,7 @@ export function FaviconImage({
1920
altText,
2021
size = 20,
2122
className = '',
23+
fallbackIcon,
2224
}: FaviconImageProps) {
2325
const [error, setError] = useState(false);
2426

@@ -44,12 +46,14 @@ export function FaviconImage({
4446
className={`${className} flex items-center justify-center rounded-sm`}
4547
style={{ width: size, height: size }}
4648
>
47-
<GlobeIcon
48-
aria-label={altText || 'Website icon'}
49-
className="not-dark:text-primary text-muted-foreground"
50-
size={size}
51-
weight="duotone"
52-
/>
49+
{fallbackIcon || (
50+
<GlobeIcon
51+
aria-label={altText || 'Website icon'}
52+
className="not-dark:text-primary text-muted-foreground"
53+
size={size}
54+
weight="duotone"
55+
/>
56+
)}
5357
</div>
5458
);
5559
}

apps/dashboard/components/layout/navigation/website-header.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { CaretLeftIcon, PlanetIcon } from '@phosphor-icons/react';
33
import Link from 'next/link';
44
import { Button } from '@/components/ui/button';
55
import { Skeleton } from '@/components/ui/skeleton';
6+
import { FaviconImage } from '@/components/analytics/favicon-image';
67

78
interface WebsiteHeaderProps {
89
website: Website | null | undefined;
@@ -31,10 +32,18 @@ export function WebsiteHeader({ website }: WebsiteHeaderProps) {
3132

3233
<div className="rounded-lg border border-border/50 bg-accent/30 px-2 py-2">
3334
<h2 className="flex items-center truncate font-semibold text-base">
34-
<PlanetIcon
35-
className="mr-2 h-5 w-5 text-primary/70"
36-
size={64}
37-
weight="duotone"
35+
<FaviconImage
36+
altText={`${website?.name || website?.domain || 'Website'} favicon`}
37+
className="mr-2"
38+
domain={website?.domain || ''}
39+
fallbackIcon={
40+
<PlanetIcon
41+
className="text-primary/70"
42+
size={20}
43+
weight="duotone"
44+
/>
45+
}
46+
size={20}
3847
/>
3948
{website?.name || website?.domain || (
4049
<Skeleton className="h-5 w-36" />

0 commit comments

Comments
 (0)