@trindtech/utils 1.2.0 → 1.3.0
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/motion/components/canvas-scrub.d.ts +21 -0
- package/dist/motion/components/canvas-scrub.d.ts.map +1 -0
- package/dist/motion/components/canvas-scrub.js +80 -0
- package/dist/motion/components/canvas-scrub.js.map +1 -0
- package/dist/motion/components/count-up.d.ts +15 -0
- package/dist/motion/components/count-up.d.ts.map +1 -0
- package/dist/motion/components/count-up.js +35 -0
- package/dist/motion/components/count-up.js.map +1 -0
- package/dist/motion/components/horizontal-scroll.d.ts +11 -0
- package/dist/motion/components/horizontal-scroll.d.ts.map +1 -0
- package/dist/motion/components/horizontal-scroll.js +46 -0
- package/dist/motion/components/horizontal-scroll.js.map +1 -0
- package/dist/motion/components/logo-marquee.d.ts +17 -0
- package/dist/motion/components/logo-marquee.d.ts.map +1 -0
- package/dist/motion/components/logo-marquee.js +21 -0
- package/dist/motion/components/logo-marquee.js.map +1 -0
- package/dist/motion/components/navbar.d.ts +21 -0
- package/dist/motion/components/navbar.d.ts.map +1 -0
- package/dist/motion/components/navbar.js +32 -0
- package/dist/motion/components/navbar.js.map +1 -0
- package/dist/motion/components/parallax-section.d.ts +10 -0
- package/dist/motion/components/parallax-section.d.ts.map +1 -0
- package/dist/motion/components/parallax-section.js +18 -0
- package/dist/motion/components/parallax-section.js.map +1 -0
- package/dist/motion/components/reveal-on-scroll.d.ts +15 -0
- package/dist/motion/components/reveal-on-scroll.d.ts.map +1 -0
- package/dist/motion/components/reveal-on-scroll.js +21 -0
- package/dist/motion/components/reveal-on-scroll.js.map +1 -0
- package/dist/motion/components/stacked-cards.d.ts +15 -0
- package/dist/motion/components/stacked-cards.d.ts.map +1 -0
- package/dist/motion/components/stacked-cards.js +53 -0
- package/dist/motion/components/stacked-cards.js.map +1 -0
- package/dist/motion/components/text-reveal.d.ts +14 -0
- package/dist/motion/components/text-reveal.d.ts.map +1 -0
- package/dist/motion/components/text-reveal.js +38 -0
- package/dist/motion/components/text-reveal.js.map +1 -0
- package/dist/motion/components/video-scrub.d.ts +9 -0
- package/dist/motion/components/video-scrub.d.ts.map +1 -0
- package/dist/motion/components/video-scrub.js +40 -0
- package/dist/motion/components/video-scrub.js.map +1 -0
- package/dist/motion/index.d.ts +14 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +30 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/providers/motion-provider.d.ts +7 -0
- package/dist/motion/providers/motion-provider.d.ts.map +1 -0
- package/dist/motion/providers/motion-provider.js +11 -0
- package/dist/motion/providers/motion-provider.js.map +1 -0
- package/dist/motion/providers/smooth-scroll-provider.d.ts +7 -0
- package/dist/motion/providers/smooth-scroll-provider.d.ts.map +1 -0
- package/dist/motion/providers/smooth-scroll-provider.js +27 -0
- package/dist/motion/providers/smooth-scroll-provider.js.map +1 -0
- package/dist/motion/types.d.ts +3 -0
- package/dist/motion/types.d.ts.map +1 -0
- package/dist/motion/types.js +3 -0
- package/dist/motion/types.js.map +1 -0
- package/package.json +30 -1
- package/src/index.ts +1 -0
- package/src/motion/components/canvas-scrub.tsx +110 -0
- package/src/motion/components/count-up.tsx +51 -0
- package/src/motion/components/horizontal-scroll.tsx +58 -0
- package/src/motion/components/logo-marquee.tsx +40 -0
- package/src/motion/components/navbar.tsx +151 -0
- package/src/motion/components/parallax-section.tsx +32 -0
- package/src/motion/components/reveal-on-scroll.tsx +48 -0
- package/src/motion/components/stacked-cards.tsx +82 -0
- package/src/motion/components/text-reveal.tsx +66 -0
- package/src/motion/components/video-scrub.tsx +60 -0
- package/src/motion/index.ts +16 -0
- package/src/motion/providers/motion-provider.tsx +15 -0
- package/src/motion/providers/smooth-scroll-provider.tsx +26 -0
- package/src/motion/types.ts +2 -0
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useState, useEffect } from "react"
|
|
3
|
+
import { motion, AnimatePresence } from "motion/react"
|
|
4
|
+
|
|
5
|
+
export interface NavLink {
|
|
6
|
+
label: string
|
|
7
|
+
href: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface NavbarCTA {
|
|
11
|
+
label: string
|
|
12
|
+
href: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
links: NavLink[]
|
|
17
|
+
logo: React.ReactNode
|
|
18
|
+
cta?: NavbarCTA
|
|
19
|
+
/** Padrão: "static" — nunca fixed a menos que explicitamente solicitado */
|
|
20
|
+
variant?: "static" | "fixed" | "sticky"
|
|
21
|
+
/** Cor do ring de foco — padrão: "#EA394E" (vermelho Trindtech) */
|
|
22
|
+
accentColor?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const variantClass: Record<NonNullable<Props["variant"]>, string> = {
|
|
26
|
+
static: "w-full",
|
|
27
|
+
fixed: "fixed top-0 left-0 right-0 z-50",
|
|
28
|
+
sticky: "sticky top-0 z-50",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Navbar responsiva — static por padrão. Mobile: drawer animado. */
|
|
32
|
+
export function Navbar({
|
|
33
|
+
links,
|
|
34
|
+
logo,
|
|
35
|
+
cta,
|
|
36
|
+
variant = "static",
|
|
37
|
+
accentColor = "#EA394E",
|
|
38
|
+
}: Props) {
|
|
39
|
+
const [scrolled, setScrolled] = useState(false)
|
|
40
|
+
const [open, setOpen] = useState(false)
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (variant === "static") return
|
|
44
|
+
const fn = () => setScrolled(window.scrollY > 60)
|
|
45
|
+
window.addEventListener("scroll", fn, { passive: true })
|
|
46
|
+
return () => window.removeEventListener("scroll", fn)
|
|
47
|
+
}, [variant])
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
<nav
|
|
52
|
+
className={`
|
|
53
|
+
${variantClass[variant]}
|
|
54
|
+
px-4 py-4 transition-all duration-300 md:px-10
|
|
55
|
+
${scrolled
|
|
56
|
+
? "border-b border-white/10 bg-black/90 backdrop-blur-md"
|
|
57
|
+
: "bg-transparent"}
|
|
58
|
+
`}
|
|
59
|
+
aria-label="Menu principal"
|
|
60
|
+
>
|
|
61
|
+
<div className="mx-auto flex max-w-6xl items-center justify-between">
|
|
62
|
+
<div className="text-lg font-bold">{logo}</div>
|
|
63
|
+
|
|
64
|
+
<ul className="hidden items-center gap-8 md:flex" role="list">
|
|
65
|
+
{links.map((link) => (
|
|
66
|
+
<li key={link.href}>
|
|
67
|
+
<a
|
|
68
|
+
href={link.href}
|
|
69
|
+
className="rounded-sm text-sm font-medium text-white/60 transition-colors duration-200 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
|
|
70
|
+
style={{ ["--tw-ring-color" as string]: accentColor }}
|
|
71
|
+
>
|
|
72
|
+
{link.label}
|
|
73
|
+
</a>
|
|
74
|
+
</li>
|
|
75
|
+
))}
|
|
76
|
+
</ul>
|
|
77
|
+
|
|
78
|
+
{cta && (
|
|
79
|
+
<a
|
|
80
|
+
href={cta.href}
|
|
81
|
+
className="hidden items-center justify-center rounded-full px-6 py-2 text-sm font-semibold text-white transition-all duration-300 hover:opacity-90 active:scale-95 md:inline-flex focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
|
|
82
|
+
style={{ background: accentColor }}
|
|
83
|
+
>
|
|
84
|
+
{cta.label}
|
|
85
|
+
</a>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<button
|
|
89
|
+
onClick={() => setOpen((v) => !v)}
|
|
90
|
+
className="flex min-h-11 min-w-11 items-center justify-center rounded-sm md:hidden focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2"
|
|
91
|
+
aria-label={open ? "Fechar menu" : "Abrir menu"}
|
|
92
|
+
aria-expanded={open}
|
|
93
|
+
>
|
|
94
|
+
<div className="flex w-5 flex-col gap-1.5">
|
|
95
|
+
<span className={`block h-0.5 bg-current transition-all duration-300 ${open ? "translate-y-2 rotate-45" : ""}`} />
|
|
96
|
+
<span className={`block h-0.5 bg-current transition-all duration-300 ${open ? "opacity-0" : ""}`} />
|
|
97
|
+
<span className={`block h-0.5 bg-current transition-all duration-300 ${open ? "-translate-y-2 -rotate-45" : ""}`} />
|
|
98
|
+
</div>
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
</nav>
|
|
102
|
+
|
|
103
|
+
<AnimatePresence>
|
|
104
|
+
{open && (
|
|
105
|
+
<motion.div
|
|
106
|
+
initial={{ opacity: 0, y: -8 }}
|
|
107
|
+
animate={{ opacity: 1, y: 0 }}
|
|
108
|
+
exit={{ opacity: 0, y: -8 }}
|
|
109
|
+
transition={{ duration: 0.2, ease: [0.22, 1, 0.36, 1] }}
|
|
110
|
+
className="fixed inset-0 z-40 flex flex-col items-center justify-center bg-black md:hidden"
|
|
111
|
+
>
|
|
112
|
+
<ul className="flex flex-col items-center gap-8" role="list">
|
|
113
|
+
{links.map((link, i) => (
|
|
114
|
+
<motion.li
|
|
115
|
+
key={link.href}
|
|
116
|
+
initial={{ opacity: 0, y: 16 }}
|
|
117
|
+
animate={{ opacity: 1, y: 0 }}
|
|
118
|
+
transition={{ delay: i * 0.06, duration: 0.4, ease: [0.22, 1, 0.36, 1] }}
|
|
119
|
+
>
|
|
120
|
+
<a
|
|
121
|
+
href={link.href}
|
|
122
|
+
onClick={() => setOpen(false)}
|
|
123
|
+
className="text-2xl font-bold transition-colors duration-200 hover:opacity-70"
|
|
124
|
+
>
|
|
125
|
+
{link.label}
|
|
126
|
+
</a>
|
|
127
|
+
</motion.li>
|
|
128
|
+
))}
|
|
129
|
+
{cta && (
|
|
130
|
+
<motion.li
|
|
131
|
+
initial={{ opacity: 0, y: 16 }}
|
|
132
|
+
animate={{ opacity: 1, y: 0 }}
|
|
133
|
+
transition={{ delay: links.length * 0.06, duration: 0.4 }}
|
|
134
|
+
>
|
|
135
|
+
<a
|
|
136
|
+
href={cta.href}
|
|
137
|
+
onClick={() => setOpen(false)}
|
|
138
|
+
className="rounded-full px-8 py-3 text-lg font-semibold text-white"
|
|
139
|
+
style={{ background: accentColor }}
|
|
140
|
+
>
|
|
141
|
+
{cta.label}
|
|
142
|
+
</a>
|
|
143
|
+
</motion.li>
|
|
144
|
+
)}
|
|
145
|
+
</ul>
|
|
146
|
+
</motion.div>
|
|
147
|
+
)}
|
|
148
|
+
</AnimatePresence>
|
|
149
|
+
</>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useRef } from "react"
|
|
3
|
+
import { motion, useScroll, useTransform } from "motion/react"
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
/** 0.1 sutil → 0.4 dramático */
|
|
8
|
+
speed?: number
|
|
9
|
+
className?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Wrapper com efeito parallax — conteúdo move em velocidade diferente do scroll */
|
|
13
|
+
export function ParallaxSection({ children, speed = 0.2, className }: Props) {
|
|
14
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
15
|
+
const { scrollYProgress } = useScroll({
|
|
16
|
+
target: ref,
|
|
17
|
+
offset: ["start end", "end start"],
|
|
18
|
+
})
|
|
19
|
+
const y = useTransform(
|
|
20
|
+
scrollYProgress,
|
|
21
|
+
[0, 1],
|
|
22
|
+
[`${speed * 100}%`, `-${speed * 100}%`]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div ref={ref} className={`overflow-hidden ${className ?? ""}`}>
|
|
27
|
+
<motion.div style={{ y }} className="h-full w-full">
|
|
28
|
+
{children}
|
|
29
|
+
</motion.div>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useRef } from "react"
|
|
3
|
+
import { motion, useInView } from "motion/react"
|
|
4
|
+
|
|
5
|
+
type Direction = "up" | "down" | "left" | "right"
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
/** Atraso em segundos antes de animar */
|
|
10
|
+
delay?: number
|
|
11
|
+
/** Direção de entrada */
|
|
12
|
+
direction?: Direction
|
|
13
|
+
className?: string
|
|
14
|
+
/** Margem para trigger — padrão: "-8% 0px" */
|
|
15
|
+
margin?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const directions: Record<Direction, { x: number; y: number }> = {
|
|
19
|
+
up: { y: 40, x: 0 },
|
|
20
|
+
down: { y: -40, x: 0 },
|
|
21
|
+
left: { x: 40, y: 0 },
|
|
22
|
+
right: { x: -40, y: 0 },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Anima filhos quando entram no viewport */
|
|
26
|
+
export function RevealOnScroll({
|
|
27
|
+
children,
|
|
28
|
+
delay = 0,
|
|
29
|
+
direction = "up",
|
|
30
|
+
className,
|
|
31
|
+
margin = "-8% 0px",
|
|
32
|
+
}: Props) {
|
|
33
|
+
const ref = useRef<HTMLDivElement>(null)
|
|
34
|
+
const isInView = useInView(ref, { once: true, margin: margin as any })
|
|
35
|
+
const { x, y } = directions[direction]
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<motion.div
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={className}
|
|
41
|
+
initial={{ opacity: 0, x, y }}
|
|
42
|
+
animate={isInView ? { opacity: 1, x: 0, y: 0 } : {}}
|
|
43
|
+
transition={{ duration: 0.6, delay, ease: [0.22, 1, 0.36, 1] }}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</motion.div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useRef } from "react"
|
|
3
|
+
import gsap from "gsap"
|
|
4
|
+
import { ScrollTrigger } from "gsap/ScrollTrigger"
|
|
5
|
+
import { useGSAP } from "@gsap/react"
|
|
6
|
+
|
|
7
|
+
gsap.registerPlugin(ScrollTrigger)
|
|
8
|
+
|
|
9
|
+
interface StackedCardsProps<T> {
|
|
10
|
+
items: T[]
|
|
11
|
+
renderItem: (item: T, index: number) => React.ReactNode
|
|
12
|
+
/** Altura de scroll por card em vh — padrão: 100 */
|
|
13
|
+
scrollPerCard?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Tela fica pinada enquanto cards aparecem um por um conforme o scroll.
|
|
18
|
+
* Após todos os cards aparecerem, o pin é liberado.
|
|
19
|
+
*/
|
|
20
|
+
export function StackedCards<T extends { id: string | number }>({
|
|
21
|
+
items,
|
|
22
|
+
renderItem,
|
|
23
|
+
scrollPerCard = 100,
|
|
24
|
+
}: StackedCardsProps<T>) {
|
|
25
|
+
const containerRef = useRef<HTMLDivElement>(null)
|
|
26
|
+
const wrapperRef = useRef<HTMLDivElement>(null)
|
|
27
|
+
|
|
28
|
+
useGSAP(() => {
|
|
29
|
+
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
30
|
+
const cardEls = wrapperRef.current?.querySelectorAll(".trind-stacked-card")
|
|
31
|
+
if (!cardEls?.length) return
|
|
32
|
+
|
|
33
|
+
if (prefersReduced) {
|
|
34
|
+
gsap.set(cardEls, { opacity: 1, y: 0, scale: 1 })
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
gsap.set(cardEls, { opacity: 0, y: 60, scale: 0.96 })
|
|
39
|
+
|
|
40
|
+
const tl = gsap.timeline({
|
|
41
|
+
scrollTrigger: {
|
|
42
|
+
trigger: containerRef.current,
|
|
43
|
+
start: "top top",
|
|
44
|
+
end: `+=${items.length * scrollPerCard}vh`,
|
|
45
|
+
scrub: 1,
|
|
46
|
+
pin: true,
|
|
47
|
+
anticipatePin: 1,
|
|
48
|
+
invalidateOnRefresh: true,
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
cardEls.forEach((card, i) => {
|
|
53
|
+
tl.to(card, {
|
|
54
|
+
opacity: 1, y: 0, scale: 1,
|
|
55
|
+
duration: 1,
|
|
56
|
+
ease: "power2.out",
|
|
57
|
+
}, i)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return () => ScrollTrigger.getAll().forEach((t) => t.kill())
|
|
61
|
+
}, { scope: containerRef })
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div
|
|
65
|
+
ref={containerRef}
|
|
66
|
+
style={{ height: `${(items.length + 1) * scrollPerCard}vh` }}
|
|
67
|
+
>
|
|
68
|
+
<div
|
|
69
|
+
ref={wrapperRef}
|
|
70
|
+
className="sticky top-0 flex h-screen items-center justify-center px-4 md:px-10"
|
|
71
|
+
>
|
|
72
|
+
<div className="grid w-full max-w-6xl grid-cols-1 gap-4 md:grid-cols-2 md:gap-6 lg:grid-cols-4 lg:gap-8">
|
|
73
|
+
{items.map((item, i) => (
|
|
74
|
+
<div key={item.id} className="trind-stacked-card">
|
|
75
|
+
{renderItem(item, i)}
|
|
76
|
+
</div>
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useRef } from "react"
|
|
3
|
+
import gsap from "gsap"
|
|
4
|
+
import { ScrollTrigger } from "gsap/ScrollTrigger"
|
|
5
|
+
import { useGSAP } from "@gsap/react"
|
|
6
|
+
|
|
7
|
+
gsap.registerPlugin(ScrollTrigger)
|
|
8
|
+
|
|
9
|
+
type Tag = "h1" | "h2" | "h3" | "h4" | "p" | "span"
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
text: string
|
|
13
|
+
as?: Tag
|
|
14
|
+
className?: string
|
|
15
|
+
/** Stagger entre caracteres em segundos */
|
|
16
|
+
stagger?: number
|
|
17
|
+
/** Onde o trigger inicia — padrão: "top 88%" */
|
|
18
|
+
start?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Anima headline caractere por caractere ao entrar no viewport */
|
|
22
|
+
export function TextReveal({
|
|
23
|
+
text,
|
|
24
|
+
as: Tag = "h2",
|
|
25
|
+
className,
|
|
26
|
+
stagger = 0.025,
|
|
27
|
+
start = "top 88%",
|
|
28
|
+
}: Props) {
|
|
29
|
+
const ref = useRef<HTMLElement>(null)
|
|
30
|
+
|
|
31
|
+
useGSAP(() => {
|
|
32
|
+
const chars = ref.current?.querySelectorAll(".trind-char")
|
|
33
|
+
if (!chars?.length) return
|
|
34
|
+
|
|
35
|
+
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
36
|
+
if (prefersReduced) {
|
|
37
|
+
gsap.set(chars, { opacity: 1, y: 0 })
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
gsap.from(chars, {
|
|
42
|
+
opacity: 0,
|
|
43
|
+
y: "110%",
|
|
44
|
+
stagger,
|
|
45
|
+
duration: 0.6,
|
|
46
|
+
ease: "power3.out",
|
|
47
|
+
scrollTrigger: { trigger: ref.current, start },
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return () => ScrollTrigger.getAll().forEach((t) => t.kill())
|
|
51
|
+
}, { scope: ref })
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Tag
|
|
55
|
+
ref={ref as React.RefObject<HTMLHeadingElement>}
|
|
56
|
+
className={`overflow-hidden ${className ?? ""}`}
|
|
57
|
+
aria-label={text}
|
|
58
|
+
>
|
|
59
|
+
{text.split("").map((char, i) => (
|
|
60
|
+
<span key={i} className="trind-char inline-block" aria-hidden="true">
|
|
61
|
+
{char === " " ? "\u00A0" : char}
|
|
62
|
+
</span>
|
|
63
|
+
))}
|
|
64
|
+
</Tag>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useEffect, useRef } from "react"
|
|
3
|
+
import gsap from "gsap"
|
|
4
|
+
import { ScrollTrigger } from "gsap/ScrollTrigger"
|
|
5
|
+
|
|
6
|
+
gsap.registerPlugin(ScrollTrigger)
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
src: string
|
|
10
|
+
scrollHeight?: string
|
|
11
|
+
fallbackSrc?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Scrub de vídeo mp4 — currentTime controlado pelo scroll */
|
|
15
|
+
export function VideoScrub({ src, scrollHeight = "250vh", fallbackSrc }: Props) {
|
|
16
|
+
const videoRef = useRef<HTMLVideoElement>(null)
|
|
17
|
+
const containerRef = useRef<HTMLDivElement>(null)
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
21
|
+
if (prefersReduced) return
|
|
22
|
+
|
|
23
|
+
const video = videoRef.current!
|
|
24
|
+
const init = () => {
|
|
25
|
+
gsap.to(video, {
|
|
26
|
+
currentTime: video.duration,
|
|
27
|
+
ease: "none",
|
|
28
|
+
scrollTrigger: {
|
|
29
|
+
trigger: containerRef.current,
|
|
30
|
+
start: "top top",
|
|
31
|
+
end: "bottom bottom",
|
|
32
|
+
scrub: 1,
|
|
33
|
+
invalidateOnRefresh: true,
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
video.readyState >= 1 ? init() : video.addEventListener("loadedmetadata", init)
|
|
39
|
+
return () => ScrollTrigger.getAll().forEach((t) => t.kill())
|
|
40
|
+
}, [])
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div ref={containerRef} style={{ height: scrollHeight }} className="relative">
|
|
44
|
+
{fallbackSrc && (
|
|
45
|
+
<div className="md:hidden sticky top-0 h-screen w-full">
|
|
46
|
+
<img src={fallbackSrc} alt="" className="h-full w-full object-cover" />
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
<video
|
|
50
|
+
ref={videoRef}
|
|
51
|
+
src={src}
|
|
52
|
+
muted
|
|
53
|
+
playsInline
|
|
54
|
+
preload="auto"
|
|
55
|
+
className="hidden md:block sticky top-0 h-screen w-full object-cover"
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Providers
|
|
2
|
+
export { SmoothScrollProvider } from "./providers/smooth-scroll-provider"
|
|
3
|
+
export { MotionProvider } from "./providers/motion-provider"
|
|
4
|
+
|
|
5
|
+
// Components
|
|
6
|
+
export { RevealOnScroll } from "./components/reveal-on-scroll"
|
|
7
|
+
export { TextReveal } from "./components/text-reveal"
|
|
8
|
+
export { ParallaxSection } from "./components/parallax-section"
|
|
9
|
+
export { HorizontalScroll } from "./components/horizontal-scroll"
|
|
10
|
+
export { StackedCards } from "./components/stacked-cards"
|
|
11
|
+
export { CanvasScrub } from "./components/canvas-scrub"
|
|
12
|
+
export { VideoScrub } from "./components/video-scrub"
|
|
13
|
+
export { CountUp } from "./components/count-up"
|
|
14
|
+
export { LogoMarquee } from "./components/logo-marquee"
|
|
15
|
+
export { Navbar } from "./components/navbar"
|
|
16
|
+
export type { NavLink, NavbarCTA } from "./components/navbar"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { MotionConfig } from "motion/react"
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Wraps app with MotionConfig — respeita prefers-reduced-motion automaticamente */
|
|
9
|
+
export function MotionProvider({ children }: Props) {
|
|
10
|
+
return (
|
|
11
|
+
<MotionConfig reducedMotion="user">
|
|
12
|
+
{children}
|
|
13
|
+
</MotionConfig>
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { useEffect } from "react"
|
|
3
|
+
import Lenis from "lenis"
|
|
4
|
+
import { gsap } from "gsap"
|
|
5
|
+
import { ScrollTrigger } from "gsap/ScrollTrigger"
|
|
6
|
+
|
|
7
|
+
gsap.registerPlugin(ScrollTrigger)
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
children: React.ReactNode
|
|
11
|
+
lerp?: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function SmoothScrollProvider({ children, lerp = 0.08 }: Props) {
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const lenis = new Lenis({ lerp, smoothWheel: true })
|
|
17
|
+
lenis.on("scroll", ScrollTrigger.update)
|
|
18
|
+
gsap.ticker.add((time) => lenis.raf(time * 1000))
|
|
19
|
+
gsap.ticker.lagSmoothing(0)
|
|
20
|
+
return () => {
|
|
21
|
+
lenis.destroy()
|
|
22
|
+
gsap.ticker.remove((time) => lenis.raf(time * 1000))
|
|
23
|
+
}
|
|
24
|
+
}, [lerp])
|
|
25
|
+
return <>{children}</>
|
|
26
|
+
}
|