create-landing-app 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-landing-app",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Create a production-ready Next.js landing page with one command",
5
5
  "type": "module",
6
6
  "bin": {
@@ -44,5 +44,7 @@
44
44
  "ts-jest": "^29.1.0",
45
45
  "typescript": "^5.0.0"
46
46
  },
47
- "engines": { "node": ">=20.9.0" }
47
+ "engines": {
48
+ "node": ">=20.9.0"
49
+ }
48
50
  }
@@ -1,13 +1,40 @@
1
+ "use client";
2
+ import { useState, useEffect, useRef } from "react";
1
3
  import Link from "next/link";
2
4
  import { NAV_LINKS, SITE_NAME } from "@/constants/common";
3
5
  import NavbarMobile from "./navbar-mobile";
4
6
  import { Button } from "@/components/ui/button";
7
+ import { cn } from "@/lib/utils";
5
8
  // __NAVBAR_IMPORT__
6
9
 
7
- // Server component — no animation needed at nav level
8
10
  export default function Navbar() {
11
+ const [isVisible, setIsVisible] = useState(true);
12
+ const lastScrollY = useRef(0);
13
+
14
+ useEffect(() => {
15
+ const controlNavbar = () => {
16
+ const currentScrollY = window.scrollY;
17
+
18
+ if (currentScrollY < lastScrollY.current || currentScrollY < 10) {
19
+ setIsVisible(true); // scrolling up OR near top → show
20
+ } else {
21
+ setIsVisible(false); // scrolling down → hide
22
+ }
23
+
24
+ lastScrollY.current = currentScrollY;
25
+ };
26
+
27
+ window.addEventListener("scroll", controlNavbar);
28
+ return () => window.removeEventListener("scroll", controlNavbar);
29
+ }, []);
30
+
9
31
  return (
10
- <header className="sticky top-0 z-50 w-full border-b border-border/40 bg-background/80 backdrop-blur-sm header-shadow">
32
+ <header
33
+ className={cn(
34
+ "fixed top-0 z-50 w-full border-b border-border/40 bg-background/80 backdrop-blur-sm header-shadow transition-transform duration-300",
35
+ isVisible ? "translate-y-0" : "-translate-y-[calc(100%+20px)]"
36
+ )}
37
+ >
11
38
  <div className="content-container flex h-16 items-center justify-between">
12
39
  {/* Logo */}
13
40
  <Link href="/" className="flex items-center gap-2 text-xl font-bold text-primary">
@@ -1,15 +1,42 @@
1
1
  "use client";
2
+ import { useState, useEffect, useRef } from "react";
2
3
  import Link from "next/link";
3
4
  import { NAV_LINKS, SITE_NAME } from "@/constants/common";
4
5
  import NavbarMobile from "./navbar-mobile";
5
6
  import { Button } from "@/components/ui/button";
6
7
  import LanguageSwitcher from "./language-switcher";
7
8
  import { useDictionary } from "@/lib/dict-context";
9
+ import { cn } from "@/lib/utils";
8
10
 
9
11
  export default function Navbar() {
10
12
  const dict = useDictionary();
13
+ const [isVisible, setIsVisible] = useState(true);
14
+ const lastScrollY = useRef(0);
15
+
16
+ useEffect(() => {
17
+ const controlNavbar = () => {
18
+ const currentScrollY = window.scrollY;
19
+
20
+ if (currentScrollY < lastScrollY.current || currentScrollY < 10) {
21
+ setIsVisible(true);
22
+ } else {
23
+ setIsVisible(false);
24
+ }
25
+
26
+ lastScrollY.current = currentScrollY;
27
+ };
28
+
29
+ window.addEventListener("scroll", controlNavbar);
30
+ return () => window.removeEventListener("scroll", controlNavbar);
31
+ }, []);
32
+
11
33
  return (
12
- <header className="sticky top-0 z-50 w-full border-b border-border/40 bg-background/80 backdrop-blur-sm header-shadow">
34
+ <header
35
+ className={cn(
36
+ "fixed top-0 z-50 w-full border-b border-border/40 bg-background/80 backdrop-blur-sm header-shadow transition-transform duration-300",
37
+ isVisible ? "translate-y-0" : "-translate-y-[calc(100%+20px)]"
38
+ )}
39
+ >
13
40
  <div className="content-container flex h-16 items-center justify-between">
14
41
  {/* Logo */}
15
42
  <Link href="/" className="flex items-center gap-2 text-xl font-bold text-primary">