Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: make github button serverfull, make site header serverfull

dev_wandry8ba3ad3cf108
diff --git a/app/(home)/components/github-button.tsx b/app/(home)/components/github-button.tsx
new file mode 100644
index 00000000..ba25c7b2
--- /dev/null
+++ b/app/(home)/components/github-button.tsx
@@ -0,0 +1,41 @@
+import { githubUrl } from "@/config/site";
+import { formatStars, getGitHubStars } from "@/lib/github";
+import { Star } from "lucide-react";
+import Link from "next/link";
+
+export async function GithubButton() {
+ const stars = await getGitHubStars();
+ return (
+ <Link
+ href={githubUrl}
+ target="_blank"
+ rel="noreferrer"
+ data-track="cta_clicked"
+ data-cta="github_header"
+ data-destination={githubUrl}
+ className="inline-flex h-9 items-center gap-2 rounded-full border border-border px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
+ >
+ <GitHubIcon className="size-4" />
+ <span className="hidden sm:inline">Star</span>
+ {stars !== null && (
+ <span className="inline-flex items-center gap-1 tabular-nums text-foreground">
+ <Star className="size-3.5 fill-current" />
+ {formatStars(stars)}
+ </span>
+ )}
+ </Link>
+ );
+}
+
+const GitHubIcon = ({ className }: { className?: string }) => (
+ <svg
+ viewBox="0 0 24 24"
+ className={className}
+ fill="currentColor"
+ role="img"
+ aria-label="GitHub"
+ >
+ <title>GitHub</title>
+ <path d="M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.27-.01-1-.02-1.96-3.2.69-3.87-1.54-3.87-1.54-.52-1.33-1.28-1.69-1.28-1.69-1.05-.72.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.7 1.26 3.36.96.1-.75.4-1.26.73-1.55-2.55-.29-5.24-1.28-5.24-5.71 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.47.11-3.06 0 0 .97-.31 3.18 1.18a11 11 0 0 1 5.79 0c2.21-1.49 3.18-1.18 3.18-1.18.63 1.59.23 2.77.11 3.06.74.81 1.19 1.84 1.19 3.1 0 4.44-2.7 5.41-5.27 5.7.41.36.78 1.06.78 2.14 0 1.55-.01 2.8-.01 3.18 0 .31.21.68.8.56C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5Z" />
+ </svg>
+);
diff --git a/app/(home)/components/header-nav.tsx b/app/(home)/components/header-nav.tsx
index 69bfecc5..0b3ec75d 100644
--- a/app/(home)/components/header-nav.tsx
+++ b/app/(home)/components/header-nav.tsx
@@ -3,6 +3,7 @@
import Link from "next/link";
import { useRef, useState } from "react";
import { SlidingHighlight } from "@/components/sliding-highlight";
+import { SheetClose } from "@/components/ui/sheet";
import type { NavLink } from "@/config/landing";
import { cn } from "@/lib/utils";
@@ -68,26 +69,23 @@ export function NavDesktop({
/**
* Mobile nav: just the stacked list of links rendered inside the header's
* Sheet. The Sheet shell, GitHub stars, and the Get-started CTA stay with the
- * header; `onNavigate` lets a tap close the sheet before routing.
+ * header; each link is a `SheetClose` so a tap closes the sheet before routing.
*/
-export function NavMobile({
- links,
- onNavigate,
-}: {
- links: NavLink[];
- onNavigate?: () => void;
-}) {
+export function NavMobile({ links }: { links: NavLink[] }) {
return (
<nav className="flex flex-col px-6 text-base">
{links.map((link) => (
- <Link
+ <SheetClose
key={link.href}
- href={link.href}
- onClick={() => onNavigate?.()}
- className="py-3 text-foreground/90 transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-none"
+ render={
+ <Link
+ href={link.href}
+ className="py-3 text-foreground/90 transition-colors hover:text-foreground focus-visible:text-foreground focus-visible:outline-none"
+ />
+ }
>
{link.label}
- </Link>
+ </SheetClose>
))}
</nav>
);
diff --git a/app/(home)/components/header-parts.tsx b/app/(home)/components/header-parts.tsx
index 7fe79975..7eee8a2c 100644
--- a/app/(home)/components/header-parts.tsx
+++ b/app/(home)/components/header-parts.tsx
@@ -1,66 +1,21 @@
-"use client";
-
-import { Menu, Star } from "lucide-react";
+import { Menu } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
-import { useState } from "react";
-import { Button } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
import {
Sheet,
+ SheetClose,
SheetContent,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/sheet";
-import type { NavLink } from "@/config/landing";
-import { useTrackEvent } from "@/lib/analytics";
-import { formatStars } from "@/lib/github";
+import { NAV_LINKS } from "@/config/landing";
+import { cn } from "@/lib/utils";
import { NavMobile } from "./header-nav";
import { ThemeToggle } from "./theme-toggle";
+import { GithubButton } from "./github-button";
-const GITHUB_URL = "https://github.com/kapishdima/remocn";
-
-const GitHubIcon = ({ className }: { className?: string }) => (
- <svg
- viewBox="0 0 24 24"
- className={className}
- fill="currentColor"
- role="img"
- aria-label="GitHub"
- >
- <title>GitHub</title>
- <path d="M12 .5C5.65.5.5 5.65.5 12c0 5.08 3.29 9.39 7.86 10.91.58.11.79-.25.79-.56 0-.27-.01-1-.02-1.96-3.2.69-3.87-1.54-3.87-1.54-.52-1.33-1.28-1.69-1.28-1.69-1.05-.72.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.7 1.26 3.36.96.1-.75.4-1.26.73-1.55-2.55-.29-5.24-1.28-5.24-5.71 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.47.11-3.06 0 0 .97-.31 3.18 1.18a11 11 0 0 1 5.79 0c2.21-1.49 3.18-1.18 3.18-1.18.63 1.59.23 2.77.11 3.06.74.81 1.19 1.84 1.19 3.1 0 4.44-2.7 5.41-5.27 5.7.41.36.78 1.06.78 2.14 0 1.55-.01 2.8-.01 3.18 0 .31.21.68.8.56C20.21 21.39 23.5 17.08 23.5 12 23.5 5.65 18.35.5 12 .5Z" />
- </svg>
-);
-
-function GitHubStars({
- stars,
- onClick,
-}: {
- stars: number | null;
- onClick?: () => void;
-}) {
- return (
- <Link
- href={GITHUB_URL}
- target="_blank"
- rel="noreferrer"
- onClick={onClick}
- className="inline-flex h-9 items-center gap-2 rounded-full border border-border px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
- >
- <GitHubIcon className="size-4" />
- <span className="hidden sm:inline">Star</span>
- {stars !== null && (
- <span className="inline-flex items-center gap-1 tabular-nums text-foreground">
- <Star className="size-3.5 fill-current" />
- {formatStars(stars)}
- </span>
- )}
- </Link>
- );
-}
-
-/** Wordmark + logo, links home. Shared across the landing and docs headers. */
export function HeaderLogo() {
return (
<Link
@@ -80,36 +35,16 @@ export function HeaderLogo() {
);
}
-/**
- * Right-hand header cluster shared by both headers: GitHub stars (desktop),
- * theme toggle, and the mobile menu Sheet. Owns its own open state and the
- * GitHub click tracking. The Sheet contains the mobile link list plus the
- * stars and Get-started CTA.
- */
-export function HeaderActions({
- navLinks,
- githubStars,
-}: {
- navLinks: NavLink[];
- githubStars: number | null;
-}) {
- const [open, setOpen] = useState(false);
- const trackEvent = useTrackEvent();
- const trackGitHubClick = () =>
- trackEvent("cta_clicked", {
- cta: "github_header",
- destination: GITHUB_URL,
- });
-
+export function HeaderActions() {
return (
<div className="flex items-center gap-2">
<div className="hidden sm:block">
- <GitHubStars stars={githubStars} onClick={trackGitHubClick} />
+ <GithubButton />
</div>
<ThemeToggle />
{/* Mobile nav trigger */}
- <Sheet open={open} onOpenChange={setOpen}>
+ <Sheet>
<SheetTrigger
render={
<Button
@@ -126,27 +61,22 @@ export function HeaderActions({
<SheetHeader>
<SheetTitle>Menu</SheetTitle>
</SheetHeader>
- <NavMobile links={navLinks} onNavigate={() => setOpen(false)} />
+ <NavMobile links={NAV_LINKS} />
<div className="mt-4 flex flex-col gap-4 px-6 pb-6">
- <GitHubStars
- stars={githubStars}
- onClick={() => {
- setOpen(false);
- trackGitHubClick();
- }}
- />
- <Button
- size="lg"
- className="h-11 w-full rounded-full"
+ <GithubButton />
+ <SheetClose
render={
<Link
href="/docs/getting-started/introduction"
- onClick={() => setOpen(false)}
+ className={cn(
+ buttonVariants({ size: "lg" }),
+ "h-11 w-full rounded-full",
+ )}
/>
}
>
Get started
- </Button>
+ </SheetClose>
</div>
</SheetContent>
</Sheet>
diff --git a/app/(home)/components/site-header.tsx b/app/(home)/components/site-header.tsx
index fd0bd886..7271cba5 100644
--- a/app/(home)/components/site-header.tsx
+++ b/app/(home)/components/site-header.tsx
@@ -1,58 +1,14 @@
-"use client";
-
-import { useEffect, useState } from "react";
-import { type NavLink } from "@/config/landing";
-import { cn } from "@/lib/utils";
+import { NAV_LINKS } from "@/config/landing";
import { NavDesktop } from "./header-nav";
import { HeaderActions, HeaderLogo } from "./header-parts";
+import { StickyHeaderShell } from "./sticky-header-shell";
-/**
- * Sticky header for the external pages (landing, sponsors). It always sticks to
- * the top and collapses the full-width bar into a floating, container-width
- * pill once the page scrolls. The static docs header lives in `DocsHeader`.
- */
-export function SiteHeader({
- navLinks,
- githubStars = null,
-}: {
- navLinks: NavLink[];
- githubStars?: number | null;
-}) {
- const [scrolled, setScrolled] = useState(false);
-
- // Collapse the full-width bar into a floating, container-width pill on scroll.
- useEffect(() => {
- const onScroll = () => setScrolled(window.scrollY > 8);
- onScroll();
- window.addEventListener("scroll", onScroll, { passive: true });
- return () => window.removeEventListener("scroll", onScroll);
- }, []);
-
- const isPill = scrolled;
-
+export function SiteHeader() {
return (
- <header
- className={cn(
- "sticky inset-x-0 top-0 z-40 transition-[background-color,border-color,padding] duration-300",
- isPill
- ? "border-transparent bg-transparent py-3"
- : "border-border bg-background/70 backdrop-blur-xl",
- )}
- >
- {/* Inner bar matches the page content width (same utilities as SECTION),
- so when scrolled it becomes a floating pill exactly that width. */}
- <div
- className={cn(
- "mx-auto flex w-full max-w-6xl items-center justify-between border px-4 transition-all duration-300 sm:px-6",
- isPill
- ? "h-14 rounded-2xl border-border bg-background/80 shadow-lg shadow-black/5 backdrop-blur-xl dark:shadow-black/30"
- : "h-16 border-transparent",
- )}
- >
- <HeaderLogo />
- <NavDesktop links={navLinks} />
- <HeaderActions navLinks={navLinks} githubStars={githubStars} />
- </div>
- </header>
+ <StickyHeaderShell>
+ <HeaderLogo />
+ <NavDesktop links={NAV_LINKS} />
+ <HeaderActions />
+ </StickyHeaderShell>
);
}
diff --git a/app/(home)/components/sticky-header-shell.tsx b/app/(home)/components/sticky-header-shell.tsx
new file mode 100644
index 00000000..9f2b1052
--- /dev/null
+++ b/app/(home)/components/sticky-header-shell.tsx
@@ -0,0 +1,31 @@
+"use client";
+
+import type { ReactNode } from "react";
+import { cn } from "@/lib/utils";
+import { useScroll } from "@/hooks/use-scroll";
+
+export function StickyHeaderShell({ children }: { children: ReactNode }) {
+ const scrolled = useScroll();
+
+ return (
+ <header
+ className={cn(
+ "sticky inset-x-0 top-0 z-40 transition-[background-color,border-color,padding] duration-300",
+ scrolled
+ ? "border-transparent bg-transparent py-3"
+ : "border-border bg-background/70 backdrop-blur-xl",
+ )}
+ >
+ <div
+ className={cn(
+ "mx-auto flex w-full max-w-6xl items-center justify-between border px-4 transition-all duration-300 sm:px-6",
+ scrolled
+ ? "h-14 rounded-2xl border-border bg-background/80 shadow-lg shadow-black/5 backdrop-blur-xl dark:shadow-black/30"
+ : "h-16 border-transparent",
+ )}
+ >
+ {children}
+ </div>
+ </header>
+ );
+}
diff --git a/app/(home)/page.tsx b/app/(home)/page.tsx
index 4e42926a..cd82eef6 100644
--- a/app/(home)/page.tsx
+++ b/app/(home)/page.tsx
@@ -1,5 +1,4 @@
-import { FOOTER_NAV, HOME_NAV } from "@/config/landing";
-import { getGitHubStars } from "@/lib/github";
+import { FOOTER_NAV } from "@/config/landing";
import { PageShell } from "./components/page-shell";
import { BentoRegistry } from "./components/sections/bento-registry";
import { FinalCTA } from "./components/sections/final-cta";
@@ -11,11 +10,9 @@ import { SiteFooter } from "./components/site-footer";
import { SiteHeader } from "./components/site-header";
export default async function Page() {
- const githubStars = await getGitHubStars();
-
return (
<PageShell>
- <SiteHeader navLinks={HOME_NAV} githubStars={githubStars} />
+ <SiteHeader />
<main className="relative flex-1">
<Hero />
<InteractiveCode />
diff --git a/app/(home)/sponsors/page.tsx b/app/(home)/sponsors/page.tsx
index 7666fe24..512ae72a 100644
--- a/app/(home)/sponsors/page.tsx
+++ b/app/(home)/sponsors/page.tsx
@@ -1,5 +1,4 @@
-import { FOOTER_NAV, SPONSORS_NAV } from "@/config/landing";
-import { getGitHubStars } from "@/lib/github";
+import { FOOTER_NAV } from "@/config/landing";
import { PageShell } from "../components/page-shell";
import { SiteFooter } from "../components/site-footer";
import { SiteHeader } from "../components/site-header";
@@ -8,11 +7,9 @@ import { Tiers } from "./components/sections/tiers";
import { WallOfLove } from "./components/sections/wall-of-love";
export default async function SponsorsPage() {
- const githubStars = await getGitHubStars();
-
return (
<PageShell>
- <SiteHeader navLinks={SPONSORS_NAV} githubStars={githubStars} />
+ <SiteHeader />
<main className="relative flex-1">
<Hero />
<Tiers />
diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx
index d89d50a9..7f903769 100644
--- a/app/docs/layout.tsx
+++ b/app/docs/layout.tsx
@@ -1,20 +1,16 @@
import { DocsLayout } from "fumadocs-ui/layouts/docs";
import type { ReactNode } from "react";
-import { DOCS_NAV } from "@/config/landing";
import { DocsHeader } from "@/components/docs/docs-header";
-import { getGitHubStars } from "@/lib/github";
import { baseOptions } from "@/lib/layout.shared";
import { source } from "@/source";
export default async function Layout({ children }: { children: ReactNode }) {
- const githubStars = await getGitHubStars();
-
return (
<>
{/* Custom remocn chrome owns the only top nav. Static (non-sticky) and
content-aligned so the bar tracks the docs grid: logo over the
sidebar, nav starting at the article column's left edge. */}
- <DocsHeader navLinks={DOCS_NAV} githubStars={githubStars} />
+ <DocsHeader />
<DocsLayout
tree={source.pageTree}
{...baseOptions()}
diff --git a/components/docs/docs-header.tsx b/components/docs/docs-header.tsx
index 058d271b..b4cd065a 100644
--- a/components/docs/docs-header.tsx
+++ b/components/docs/docs-header.tsx
@@ -3,7 +3,7 @@ import {
HeaderLogo,
} from "@/app/(home)/components/header-parts";
import { NavDesktop } from "@/app/(home)/components/header-nav";
-import { type NavLink } from "@/config/landing";
+import { NAV_LINKS } from "@/config/landing";
/**
* Static, content-aligned header for the docs. Unlike `SiteHeader` it never
@@ -24,13 +24,7 @@ import { type NavLink } from "@/config/landing";
* inline (Tailwind JIT can't read JS constants); if a fumadocs upgrade changes
* those defaults, re-sync the two values below.
*/
-export function DocsHeader({
- navLinks,
- githubStars = null,
-}: {
- navLinks: NavLink[];
- githubStars?: number | null;
-}) {
+export function DocsHeader() {
return (
<header className="relative z-40 h-16 w-full border-b border-border bg-background/70 backdrop-blur-xl">
<div className="mx-auto flex h-16 w-full max-w-(--fd-layout-width) items-center [--fd-layout-width:1400px] md:[--fd-sidebar-width:268px]">
@@ -38,8 +32,8 @@ export function DocsHeader({
<HeaderLogo />
</div>
<div className="flex flex-1 items-center justify-between px-4 md:px-6 xl:px-5">
- <NavDesktop links={navLinks} className="-ml-4" />
- <HeaderActions navLinks={navLinks} githubStars={githubStars} />
+ <NavDesktop links={NAV_LINKS} className="-ml-4" />
+ <HeaderActions />
</div>
</div>
</header>
diff --git a/config/landing.ts b/config/landing.ts
index 34b79f03..f34beedb 100644
--- a/config/landing.ts
+++ b/config/landing.ts
@@ -34,22 +34,13 @@ export type NavLink = {
smOnly?: boolean;
};
-// Single source of truth for the top nav. "Components" sends people straight
-// into the docs (typography is the first component category), so every surface
-// — landing, sponsors, docs — shares the same three root-absolute links and the
-// menu reads identically wherever it's mounted.
-const MAIN_NAV: NavLink[] = [
+// Единый источник топ-навигации для landing / sponsors / docs.
+export const NAV_LINKS: NavLink[] = [
{ href: "/docs/typography", label: "Components" },
{ href: "/sponsors", label: "Sponsors" },
{ href: "/docs/getting-started/introduction", label: "Docs" },
];
-export const HOME_NAV: NavLink[] = MAIN_NAV;
-
-export const SPONSORS_NAV: NavLink[] = MAIN_NAV;
-
-export const DOCS_NAV: NavLink[] = MAIN_NAV;
-
export const FOOTER_NAV: NavLink[] = [
{ href: "/docs/getting-started/introduction", label: "Docs" },
{ href: GITHUB_URL, label: "GitHub" },
diff --git a/config/site.ts b/config/site.ts
new file mode 100644
index 00000000..d6754754
--- /dev/null
+++ b/config/site.ts
@@ -0,0 +1 @@
+export const githubUrl = "https://github.com/kapishdima/remocn";
\ No newline at end of file
diff --git a/hooks/use-scroll.ts b/hooks/use-scroll.ts
new file mode 100644
index 00000000..f00d85c4
--- /dev/null
+++ b/hooks/use-scroll.ts
@@ -0,0 +1,15 @@
+import { useEffect, useState } from "react";
+
+export const useScroll = () => {
+ const [scrolled, setScrolled] = useState(false);
+
+ // Collapse the full-width bar into a floating, container-width pill on scroll.
+ useEffect(() => {
+ const onScroll = () => setScrolled(window.scrollY > 8);
+ onScroll();
+ window.addEventListener("scroll", onScroll, { passive: true });
+ return () => window.removeEventListener("scroll", onScroll);
+ }, []);
+
+ return scrolled;
+}
\ No newline at end of file