-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathclient-logo.tsx
More file actions
70 lines (63 loc) · 1.36 KB
/
client-logo.tsx
File metadata and controls
70 lines (63 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type { ReactElement } from "react";
import Image from "next/image";
import { cn } from "@/lib/utils";
import type { TurboUser } from "./users";
const DEFAULT_SIZE = {
width: 100,
height: 75
};
export function Logo({
user,
theme,
isLink,
className
}: {
user: TurboUser;
theme: "dark" | "light";
isLink: boolean;
className?: string;
}): ReactElement {
const styles = {
...DEFAULT_SIZE,
...user.style
};
// Initialize with default values
let numericWidth = DEFAULT_SIZE.width;
let numericHeight = DEFAULT_SIZE.height;
if (typeof styles.width === "number") {
numericWidth = styles.width;
}
if (typeof styles.height === "number") {
numericHeight = styles.height;
}
// Use white logos as base, invert for light mode to get dark grayscale logos
const logo = (
<Image
alt={`${user.caption}'s Logo`}
className={cn(
"mx-8",
// Light mode: invert white logos to dark
theme === "dark" && "invert",
className
)}
height={numericHeight}
priority
src={user.imageWhite}
style={styles}
width={numericWidth}
/>
);
if (isLink) {
return (
<a
className="item-center flex justify-center"
href={user.infoLink}
rel="noopener noreferrer"
target="_blank"
>
{logo}
</a>
);
}
return logo;
}