header.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. "use client";
  2. import Link from "next/link";
  3. import { usePathname } from "next/navigation";
  4. import { ThemeToggle } from "./theme-toggle";
  5. import { cn } from "@/lib/utils";
  6. export function Header() {
  7. const pathname = usePathname();
  8. const isActive = (href: string) => {
  9. if (href === "/playground") {
  10. return pathname === "/playground";
  11. }
  12. if (href === "/docs") {
  13. return pathname.startsWith("/docs");
  14. }
  15. return false;
  16. };
  17. return (
  18. <header className="sticky top-0 z-50 bg-background">
  19. <div className="flex h-14 items-center justify-between px-4 gap-6">
  20. <div className="flex items-center gap-2">
  21. <Link href="https://vercel.com" title="Made with love by Vercel">
  22. <svg
  23. data-testid="geist-icon"
  24. height="18"
  25. strokeLinejoin="round"
  26. viewBox="0 0 16 16"
  27. width="18"
  28. style={{ color: "currentcolor" }}
  29. >
  30. <path
  31. fillRule="evenodd"
  32. clipRule="evenodd"
  33. d="M8 1L16 15H0L8 1Z"
  34. fill="currentColor"
  35. ></path>
  36. </svg>
  37. </Link>
  38. <span className="text-(--ds-gray-500)">
  39. <svg
  40. data-testid="geist-icon"
  41. height="16"
  42. strokeLinejoin="round"
  43. viewBox="0 0 16 16"
  44. width="16"
  45. style={{ color: "currentcolor" }}
  46. >
  47. <path
  48. fillRule="evenodd"
  49. clipRule="evenodd"
  50. d="M4.01526 15.3939L4.3107 14.7046L10.3107 0.704556L10.6061 0.0151978L11.9849 0.606077L11.6894 1.29544L5.68942 15.2954L5.39398 15.9848L4.01526 15.3939Z"
  51. fill="currentColor"
  52. ></path>
  53. </svg>
  54. </span>
  55. <Link href="/">
  56. <span className="font-medium tracking-tight text-lg font-(family-name:--font-geist-pixel-square)">
  57. json-render
  58. </span>
  59. </Link>
  60. </div>
  61. <nav className="flex items-center gap-4">
  62. <Link
  63. href="/playground"
  64. className={cn(
  65. "text-sm transition-colors",
  66. isActive("/playground")
  67. ? "text-primary font-medium"
  68. : "text-muted-foreground hover:text-foreground",
  69. )}
  70. >
  71. <span className="sm:hidden">Play</span>
  72. <span className="hidden sm:inline">Playground</span>
  73. </Link>
  74. <Link
  75. href="/docs"
  76. className={cn(
  77. "text-sm transition-colors",
  78. isActive("/docs")
  79. ? "text-primary font-medium"
  80. : "text-muted-foreground hover:text-foreground",
  81. )}
  82. >
  83. Docs
  84. </Link>
  85. <a
  86. href="https://github.com/vercel-labs/json-render"
  87. target="_blank"
  88. rel="noopener noreferrer"
  89. className="flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors"
  90. >
  91. <svg
  92. viewBox="0 0 16 16"
  93. className="h-4 w-4"
  94. fill="currentColor"
  95. aria-hidden="true"
  96. >
  97. <path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z" />
  98. </svg>
  99. <span>12k</span>
  100. </a>
  101. <ThemeToggle />
  102. </nav>
  103. </div>
  104. </header>
  105. );
  106. }