-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathAppbar.tsx
More file actions
149 lines (143 loc) · 5.51 KB
/
Appbar.tsx
File metadata and controls
149 lines (143 loc) · 5.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"use client";
import { useState, useEffect } from "react";
import { SignInButton, SignedIn, SignedOut, UserButton } from "@clerk/nextjs";
import { Button } from "./ui/button";
import { Credits } from "./navbar/Credits";
import Link from "next/link";
import { motion } from "framer-motion";
import { ThemeToggle } from "./ThemeToggle";
export function Appbar() {
const [isScrolled, setIsScrolled] = useState(false);
useEffect(() => {
const handleScroll = () => {
if (window.scrollY > 0) {
setIsScrolled(true);
} else {
setIsScrolled(false);
}
};
window.addEventListener("scroll", handleScroll);
return () => window.removeEventListener("scroll", handleScroll);
}, []);
return (
<motion.header
initial={{ y: -20, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
transition={{ duration: 0.5, ease: "easeOut" }}
className="fixed top-0 z-50 w-full p-2"
>
<motion.div
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
transition={{ duration: 0.4, ease: "easeOut" }}
className={`mx-auto max-w-6xl px-4 sm:px-6 lg:px-8 backdrop-blur-xl rounded-2xl transition-all duration-300 ${
isScrolled
? "bg-white/80 border border-neutral-200 shadow-lg dark:bg-neutral-900/80 dark:border-neutral-800"
: "bg-transparent border-transparent"
}`}
>
<div className="flex h-16 items-center justify-between">
<motion.div whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }}>
<Link
href="/"
className="flex items-center space-x-2 transition-opacity hover:opacity-90"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="h-6 w-6"
>
<path d="M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3" />
</svg>
<span
className={`hidden font-bold font-mono text-xl sm:inline-block ${
isScrolled
? "text-neutral-900 dark:text-neutral-100"
: "text-neutral-900 dark:text-neutral-100"
}`}
>
100xPhoto
</span>
</Link>
</motion.div>
{/* Auth & Pricing */}
<div className="flex items-center gap-4">
<SignedIn>
<Button
variant="ghost"
size="sm"
className={`${
isScrolled
? "text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"
: "text-neutral-700 hover:bg-neutral-100/50 dark:text-neutral-300 dark:hover:bg-neutral-800/30"
} transition`}
asChild
>
<Link href="/dashboard">Dashboard</Link>
</Button>
<Button
variant="ghost"
size="sm"
className={`${
isScrolled
? "text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"
: "text-neutral-700 hover:bg-neutral-100/50 dark:text-neutral-300 dark:hover:bg-neutral-800/30"
} transition`}
asChild
>
<Link href="/purchases">My Purchases</Link>
</Button>
<Credits />
<UserButton
afterSignOutUrl="/"
appearance={{
elements: {
avatarBox:
"h-8 w-8 rounded-full ring-2 ring-primary/10 transition-all hover:ring-primary/30",
userButtonPopover: "right-0 mt-2",
},
}}
/>
</SignedIn>
<SignedOut>
<Button
variant="ghost"
size="sm"
className={`${
isScrolled
? "text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800"
: "text-neutral-700 hover:bg-neutral-100/50 dark:text-neutral-300 dark:hover:bg-neutral-800/30"
} transition`}
asChild
>
<Link href="/pricing">Pricing</Link>
</Button>
<motion.div
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<Button
variant="default"
size="sm"
className={`relative overflow-hidden bg-gradient-to-r from-neutral-800 to-neutral-900 text-white dark:from-neutral-700 dark:to-neutral-800 border ${
isScrolled ? "border-neutral-300" : "border-neutral-700/50"
} rounded-lg shadow-md shadow-neutral-800/20 dark:shadow-black/30 px-4 py-2 font-medium tracking-wide transition-all duration-300 ease-in-out hover:shadow-lg hover:scale-[1.02]`}
asChild
>
<SignInButton mode="modal">
<span>Sign In</span>
</SignInButton>
</Button>
</motion.div>
</SignedOut>
</div>
</div>
</motion.div>
</motion.header>
);
}