Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

Fixed GitHub Icon Alignment in Site Header (#91)

achrafrzz19f937be61613
diff --git a/.env.example b/.env.example
deleted file mode 100644
index 95eeddbd..00000000
--- a/.env.example
+++ /dev/null
@@ -1,2 +0,0 @@
-PORT=3000
-NEXT_PUBLIC_APP_URL=http://localhost:3000
\ No newline at end of file
diff --git a/components/site-header.tsx b/components/site-header.tsx
index f76a9b51..73679394 100644
--- a/components/site-header.tsx
+++ b/components/site-header.tsx
@@ -16,27 +16,36 @@ interface SiteHeaderProps {
}
export async function SiteHeader({ user }: SiteHeaderProps) {
- const { stargazers_count: stars } = await fetch(
- "https://api.github.com/repos/magicuidesign/magicui",
- {
- ...(process.env.GITHUB_OAUTH_TOKEN && {
- headers: {
- Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,
- "Content-Type": "application/json",
+ let stars = 300; // Default value
+
+ try {
+ const response = await fetch(
+ "https://api.github.com/repos/magicuidesign/magicui",
+ {
+ headers: process.env.GITHUB_OAUTH_TOKEN
+ ? {
+ Authorization: `Bearer ${process.env.GITHUB_OAUTH_TOKEN}`,
+ "Content-Type": "application/json",
+ }
+ : {},
+ next: {
+ revalidate: 3600,
},
- }),
- next: {
- revalidate: 3600,
- },
- },
- )
- .then((res) => res.json())
- .catch(() => ({ stargazers_count: 300 }));
+ }
+ );
+
+ if (response.ok) {
+ const data = await response.json();
+ stars = data.stargazers_count || stars; // Update stars if API response is valid
+ }
+ } catch (error) {
+ console.error("Error fetching GitHub stars:", error);
+ }
return (
<header
className={cn(
- "supports-backdrop-blur:bg-background/90 sticky top-0 z-40 w-full bg-background/40 backdrop-blur-lg",
+ "supports-backdrop-blur:bg-background/90 sticky top-0 z-40 w-full bg-background/40 backdrop-blur-lg"
)}
>
<div className="container flex h-16 items-center">
@@ -47,15 +56,17 @@ export async function SiteHeader({ user }: SiteHeaderProps) {
className={cn(
buttonVariants(),
"hidden max-w-52 gap-2 overflow-hidden whitespace-pre md:flex",
- "group relative w-full justify-center gap-2 rounded-md transition-all duration-300 ease-out hover:ring-2 hover:ring-primary hover:ring-offset-2",
+ "group relative w-full justify-center gap-2 rounded-md transition-all duration-300 ease-out hover:ring-2 hover:ring-primary hover:ring-offset-2"
)}
target="_blank"
href={siteConfig.links.github}
>
<span className="absolute right-0 -mt-12 h-32 w-8 translate-x-12 rotate-12 transform bg-white opacity-10 transition-all duration-1000 ease-out group-hover:-translate-x-40" />
- <Icons.gitHub className="h-4 w-4" />
- Star on GitHub
- <div className="hidden items-center gap-1 text-sm md:flex">
+ <div className="flex items-center"> {/* Added a container div */}
+ <Icons.gitHub className="h-4 w-4" />
+ <span className="ml-1">Star on GitHub</span> {/* Adjusted spacing */}
+ </div>
+ <div className="flex items-center gap-1 text-sm md:flex ml-2"> {/* Adjusted alignment */}
<StarIcon className="h-4 w-4 text-gray-500 transition-all duration-300 group-hover:text-yellow-300" />
<NumberTicker
value={stars}