This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactored Navbar component (#85)
- Loading branch information
Showing
4 changed files
with
61 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { GitcoinLogo } from "@/assets"; | ||
|
||
const defaultLogo = GitcoinLogo; | ||
|
||
export interface NavbarLogoProps { | ||
link?: string; | ||
img?: string | React.FunctionComponent<React.SVGAttributes<SVGElement>>; | ||
size?: string; | ||
color?: string; | ||
} | ||
|
||
export const NavbarLogo = ({ | ||
link, | ||
img, | ||
size = "h-10 max-w-12", | ||
color = "black", | ||
}: NavbarLogoProps) => { | ||
const logoClasses = `${size} text-${color}`; | ||
|
||
if (!img) { | ||
return <img src={defaultLogo} alt="Default Logo" className={logoClasses} />; | ||
} | ||
|
||
if (typeof img === "string") { | ||
return <img src={img} alt="Logo" className={logoClasses} />; | ||
} | ||
|
||
const LogoComponent = img; | ||
|
||
return ( | ||
<a href={link || "#"} style={{ color }}> | ||
<LogoComponent className={logoClasses} /> | ||
</a> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { cn } from "@/lib"; | ||
|
||
export interface NavbarTitleProps { | ||
text: string; | ||
link?: string; | ||
className?: string; | ||
} | ||
|
||
export const NavbarTitle = ({ text, link, className = "" }: NavbarTitleProps) => { | ||
return ( | ||
<a href={link || "#"} className={cn("font-ui-mono text-lg", className)}> | ||
{text} | ||
</a> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./NavbarLogo"; | ||
export * from "./NavbarTitle"; |