Files
OpenCut/apps/web/src/components/header.tsx
T

71 lines
2.0 KiB
TypeScript
Raw Normal View History

2025-06-22 13:07:02 +02:00
"use client";
import Link from "next/link";
import { Button } from "./ui/button";
import { ArrowRight } from "lucide-react";
import { HeaderBase } from "./header-base";
import { useSession } from "@opencut/auth/client";
2025-06-24 02:06:55 +05:30
import { getStars } from "@/lib/fetchGhStars";
import { useEffect, useState } from "react";
import Image from "next/image";
2025-06-25 22:58:16 +01:00
2025-06-22 13:07:02 +02:00
export function Header() {
const { data: session } = useSession();
2025-06-24 02:06:55 +05:30
const [star, setStar] = useState<string>("");
useEffect(() => {
const fetchStars = async () => {
try {
const data = await getStars();
setStar(data);
} catch (err) {
console.error("Failed to fetch GitHub stars", err);
}
};
fetchStars();
}, []);
2025-06-22 13:07:02 +02:00
const leftContent = (
<Link href="/" className="flex items-center gap-3">
<Image src="/logo.svg" alt="OpenCut Logo" width={32} height={32} />
<span className="text-xl font-medium hidden md:block">OpenCut</span>
2025-06-22 13:07:02 +02:00
</Link>
);
const rightContent = (
2025-06-25 21:44:54 +02:00
<nav className="flex items-center gap-3">
<Link href="/contributors">
2025-06-25 21:44:54 +02:00
<Button variant="text" className="text-sm p-0">
Contributors
2025-06-22 13:07:02 +02:00
</Button>
</Link>
{process.env.NODE_ENV === "development" ? (
<Link href="/editor">
<Button size="sm" className="text-sm ml-4">
Editor
<ArrowRight className="h-4 w-4" />
</Button>
</Link>
) : (
<Link href="https://github.com/OpenCut-app/OpenCut" target="_blank">
<Button size="sm" className="text-sm ml-4">
2025-06-25 15:36:50 +02:00
GitHub {star}+
<ArrowRight className="h-4 w-4" />
</Button>
</Link>
)}
2025-06-22 13:07:02 +02:00
</nav>
);
2025-06-25 15:00:35 +01:00
return (
2025-06-25 22:58:16 +01:00
<div className="mx-4 md:mx-0">
<HeaderBase
2025-06-29 20:09:43 +02:00
className="bg-accent border rounded-2xl max-w-3xl mx-auto mt-4 pl-4 pr-[14px]"
2025-06-25 22:58:16 +01:00
leftContent={leftContent}
rightContent={rightContent}
/>
</div>
2025-06-25 15:00:35 +01:00
);
2025-06-22 13:07:02 +02:00
}