@trindtech/utils 1.3.0 → 1.4.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 +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +26 -1
- package/src/index.ts +0 -4
- package/src/mailer/index.ts +0 -87
- package/src/mailer/templates.ts +0 -48
- package/src/motion/components/canvas-scrub.tsx +0 -110
- package/src/motion/components/count-up.tsx +0 -51
- package/src/motion/components/horizontal-scroll.tsx +0 -58
- package/src/motion/components/logo-marquee.tsx +0 -40
- package/src/motion/components/navbar.tsx +0 -151
- package/src/motion/components/parallax-section.tsx +0 -32
- package/src/motion/components/reveal-on-scroll.tsx +0 -48
- package/src/motion/components/stacked-cards.tsx +0 -82
- package/src/motion/components/text-reveal.tsx +0 -66
- package/src/motion/components/video-scrub.tsx +0 -60
- package/src/motion/index.ts +0 -16
- package/src/motion/providers/motion-provider.tsx +0 -15
- package/src/motion/providers/smooth-scroll-provider.tsx +0 -26
- package/src/motion/types.ts +0 -2
- package/src/s3/index.ts +0 -241
- package/src/validators/countries.ts +0 -94
- package/src/validators/index.ts +0 -257
- package/tsconfig.json +0 -18
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./mailer"), exports);
|
|
18
18
|
__exportStar(require("./validators"), exports);
|
|
19
19
|
__exportStar(require("./s3"), exports);
|
|
20
|
-
__exportStar(require("./motion"), exports);
|
|
21
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,uCAAqB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,uCAAqB"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trindtech/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./motion": {
|
|
12
|
+
"types": "./dist/motion/index.d.ts",
|
|
13
|
+
"default": "./dist/motion/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./s3": {
|
|
16
|
+
"types": "./dist/s3/index.d.ts",
|
|
17
|
+
"default": "./dist/s3/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./mailer": {
|
|
20
|
+
"types": "./dist/mailer/index.d.ts",
|
|
21
|
+
"default": "./dist/mailer/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./validators": {
|
|
24
|
+
"types": "./dist/validators/index.d.ts",
|
|
25
|
+
"default": "./dist/validators/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
6
31
|
"publishConfig": {
|
|
7
32
|
"registry": "https://registry.npmjs.org",
|
|
8
33
|
"access": "public"
|
package/src/index.ts
DELETED
package/src/mailer/index.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
|
|
2
|
-
import { verificationTemplate, resetPasswordTemplate } from "./templates";
|
|
3
|
-
|
|
4
|
-
export interface MailerCredentials {
|
|
5
|
-
accessKeyId: string;
|
|
6
|
-
secretAccessKey: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface MailerConfig {
|
|
10
|
-
region: string;
|
|
11
|
-
from: string;
|
|
12
|
-
appName: string;
|
|
13
|
-
credentials: MailerCredentials;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface SendOptions {
|
|
17
|
-
to: string;
|
|
18
|
-
subject: string;
|
|
19
|
-
html: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function createMailer(config: MailerConfig) {
|
|
23
|
-
const client = new SESClient({
|
|
24
|
-
region: config.region,
|
|
25
|
-
credentials: {
|
|
26
|
-
accessKeyId: config.credentials.accessKeyId,
|
|
27
|
-
secretAccessKey: config.credentials.secretAccessKey,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
async function send({ to, subject, html }: SendOptions): Promise<void> {
|
|
32
|
-
const command = new SendEmailCommand({
|
|
33
|
-
Source: config.from,
|
|
34
|
-
Destination: {
|
|
35
|
-
ToAddresses: [to],
|
|
36
|
-
},
|
|
37
|
-
Message: {
|
|
38
|
-
Subject: {
|
|
39
|
-
Data: subject,
|
|
40
|
-
Charset: "UTF-8",
|
|
41
|
-
},
|
|
42
|
-
Body: {
|
|
43
|
-
Html: {
|
|
44
|
-
Data: html,
|
|
45
|
-
Charset: "UTF-8",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await client.send(command);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async function sendVerificationEmail(
|
|
55
|
-
to: string,
|
|
56
|
-
code: string,
|
|
57
|
-
customTemplate?: (code: string, appName: string) => string
|
|
58
|
-
): Promise<void> {
|
|
59
|
-
const html = customTemplate
|
|
60
|
-
? customTemplate(code, config.appName)
|
|
61
|
-
: verificationTemplate(code, config.appName);
|
|
62
|
-
|
|
63
|
-
await send({
|
|
64
|
-
to,
|
|
65
|
-
subject: `Seu código de verificação — ${config.appName}`,
|
|
66
|
-
html,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function sendResetPasswordEmail(
|
|
71
|
-
to: string,
|
|
72
|
-
resetUrl: string,
|
|
73
|
-
customTemplate?: (resetUrl: string, appName: string) => string
|
|
74
|
-
): Promise<void> {
|
|
75
|
-
const html = customTemplate
|
|
76
|
-
? customTemplate(resetUrl, config.appName)
|
|
77
|
-
: resetPasswordTemplate(resetUrl, config.appName);
|
|
78
|
-
|
|
79
|
-
await send({
|
|
80
|
-
to,
|
|
81
|
-
subject: `Redefinição de senha — ${config.appName}`,
|
|
82
|
-
html,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return { send, sendVerificationEmail, sendResetPasswordEmail };
|
|
87
|
-
}
|
package/src/mailer/templates.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function verificationTemplate(code: string, appName: string): string {
|
|
2
|
-
return `
|
|
3
|
-
<div style="font-family: sans-serif; max-width: 480px; margin: 0 auto;">
|
|
4
|
-
<h2>Verifique seu e-mail — ${appName}</h2>
|
|
5
|
-
<p>Use o código abaixo para confirmar seu cadastro:</p>
|
|
6
|
-
<div style="
|
|
7
|
-
font-size: 32px;
|
|
8
|
-
font-weight: bold;
|
|
9
|
-
letter-spacing: 8px;
|
|
10
|
-
padding: 16px;
|
|
11
|
-
background: #f4f4f4;
|
|
12
|
-
border-radius: 8px;
|
|
13
|
-
text-align: center;
|
|
14
|
-
">
|
|
15
|
-
${code}
|
|
16
|
-
</div>
|
|
17
|
-
<p style="color: #666; font-size: 13px; margin-top: 16px;">
|
|
18
|
-
Este código expira em 60 minutos. Não compartilhe com ninguém.
|
|
19
|
-
</p>
|
|
20
|
-
</div>
|
|
21
|
-
`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function resetPasswordTemplate(
|
|
25
|
-
resetUrl: string,
|
|
26
|
-
appName: string
|
|
27
|
-
): string {
|
|
28
|
-
return `
|
|
29
|
-
<div style="font-family: sans-serif; max-width: 480px; margin: 0 auto;">
|
|
30
|
-
<h2>Redefinição de senha — ${appName}</h2>
|
|
31
|
-
<p>Clique no botão abaixo para redefinir sua senha:</p>
|
|
32
|
-
<a href="${resetUrl}" style="
|
|
33
|
-
display: inline-block;
|
|
34
|
-
padding: 12px 24px;
|
|
35
|
-
background: #000;
|
|
36
|
-
color: #fff;
|
|
37
|
-
text-decoration: none;
|
|
38
|
-
border-radius: 6px;
|
|
39
|
-
margin: 16px 0;
|
|
40
|
-
">
|
|
41
|
-
Redefinir senha
|
|
42
|
-
</a>
|
|
43
|
-
<p style="color: #666; font-size: 13px;">
|
|
44
|
-
Este link expira em 1 hora. Se você não solicitou isso, ignore este e-mail.
|
|
45
|
-
</p>
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
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
|
-
/** Total de frames na sequência */
|
|
10
|
-
frameCount: number
|
|
11
|
-
/** Função que retorna a URL de cada frame pelo índice */
|
|
12
|
-
getFrameUrl: (index: number) => string
|
|
13
|
-
/** Altura total de scroll para a animação — padrão: "300vh" */
|
|
14
|
-
scrollHeight?: string
|
|
15
|
-
/** Imagem de fallback para mobile e prefers-reduced-motion */
|
|
16
|
-
fallbackSrc?: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Scrub de sequência de imagens ao estilo Apple.
|
|
21
|
-
* No mobile e com prefers-reduced-motion, exibe fallbackSrc estático.
|
|
22
|
-
*
|
|
23
|
-
* Convenção de frames: /public/frames/frame-001.webp ... frame-NNN.webp
|
|
24
|
-
* Ferramenta para extrair frames de vídeo: https://frame-extractor.com
|
|
25
|
-
* Recomendado: 60–120 frames, 1280×720, webp, <50kb cada
|
|
26
|
-
*/
|
|
27
|
-
export function CanvasScrub({
|
|
28
|
-
frameCount,
|
|
29
|
-
getFrameUrl,
|
|
30
|
-
scrollHeight = "300vh",
|
|
31
|
-
fallbackSrc,
|
|
32
|
-
}: Props) {
|
|
33
|
-
const canvasRef = useRef<HTMLCanvasElement>(null)
|
|
34
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
35
|
-
const frameRef = useRef({ frame: 0 })
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
const isMobile = window.innerWidth < 768
|
|
39
|
-
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
40
|
-
if (isMobile || prefersReduced) return
|
|
41
|
-
|
|
42
|
-
const canvas = canvasRef.current!
|
|
43
|
-
const ctx = canvas.getContext("2d")!
|
|
44
|
-
const images: HTMLImageElement[] = []
|
|
45
|
-
let loaded = 0
|
|
46
|
-
|
|
47
|
-
const resize = () => {
|
|
48
|
-
canvas.width = window.innerWidth
|
|
49
|
-
canvas.height = window.innerHeight
|
|
50
|
-
}
|
|
51
|
-
resize()
|
|
52
|
-
window.addEventListener("resize", resize)
|
|
53
|
-
|
|
54
|
-
function draw(index: number) {
|
|
55
|
-
const img = images[Math.min(Math.round(index), frameCount - 1)]
|
|
56
|
-
if (!img?.complete) return
|
|
57
|
-
const scale = Math.max(canvas.width / img.width, canvas.height / img.height)
|
|
58
|
-
const x = (canvas.width - img.width * scale) / 2
|
|
59
|
-
const y = (canvas.height - img.height * scale) / 2
|
|
60
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
61
|
-
ctx.drawImage(img, x, y, img.width * scale, img.height * scale)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function start() {
|
|
65
|
-
draw(0)
|
|
66
|
-
gsap.to(frameRef.current, {
|
|
67
|
-
frame: frameCount - 1,
|
|
68
|
-
snap: "frame",
|
|
69
|
-
ease: "none",
|
|
70
|
-
scrollTrigger: {
|
|
71
|
-
trigger: containerRef.current,
|
|
72
|
-
start: "top top",
|
|
73
|
-
end: "bottom bottom",
|
|
74
|
-
scrub: 1,
|
|
75
|
-
invalidateOnRefresh: true,
|
|
76
|
-
onUpdate: () => draw(frameRef.current.frame),
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
for (let i = 0; i < frameCount; i++) {
|
|
82
|
-
const img = new Image()
|
|
83
|
-
img.src = getFrameUrl(i)
|
|
84
|
-
img.onload = () => { if (++loaded === frameCount) start() }
|
|
85
|
-
images.push(img)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return () => {
|
|
89
|
-
window.removeEventListener("resize", resize)
|
|
90
|
-
ScrollTrigger.getAll().forEach((t) => t.kill())
|
|
91
|
-
}
|
|
92
|
-
}, [frameCount, getFrameUrl])
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<div ref={containerRef} style={{ height: scrollHeight }} className="relative">
|
|
96
|
-
{/* Mobile / reduced-motion fallback */}
|
|
97
|
-
{fallbackSrc && (
|
|
98
|
-
<div className="md:hidden sticky top-0 h-screen w-full">
|
|
99
|
-
<img src={fallbackSrc} alt="" className="h-full w-full object-cover" />
|
|
100
|
-
</div>
|
|
101
|
-
)}
|
|
102
|
-
{/* Desktop canvas */}
|
|
103
|
-
<canvas
|
|
104
|
-
ref={canvasRef}
|
|
105
|
-
className="hidden md:block sticky top-0 h-screen w-full"
|
|
106
|
-
aria-hidden="true"
|
|
107
|
-
/>
|
|
108
|
-
</div>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import { useEffect, useRef, useState } from "react"
|
|
3
|
-
import { useInView } from "motion/react"
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
/** Valor final */
|
|
7
|
-
end: number
|
|
8
|
-
/** Duração em ms — padrão: 2000 */
|
|
9
|
-
duration?: number
|
|
10
|
-
prefix?: string
|
|
11
|
-
suffix?: string
|
|
12
|
-
className?: string
|
|
13
|
-
/** Locale para formatação — padrão: "pt-BR" */
|
|
14
|
-
locale?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** Contador animado que dispara quando entra no viewport */
|
|
18
|
-
export function CountUp({
|
|
19
|
-
end,
|
|
20
|
-
duration = 2000,
|
|
21
|
-
prefix = "",
|
|
22
|
-
suffix = "",
|
|
23
|
-
className,
|
|
24
|
-
locale = "pt-BR",
|
|
25
|
-
}: Props) {
|
|
26
|
-
const ref = useRef<HTMLSpanElement>(null)
|
|
27
|
-
const isInView = useInView(ref, { once: true, margin: "-10% 0px" })
|
|
28
|
-
const [value, setValue] = useState(0)
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (!isInView) return
|
|
32
|
-
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
33
|
-
if (prefersReduced) { setValue(end); return }
|
|
34
|
-
|
|
35
|
-
const start = performance.now()
|
|
36
|
-
const step = (now: number) => {
|
|
37
|
-
const progress = Math.min((now - start) / duration, 1)
|
|
38
|
-
const eased = 1 - Math.pow(1 - progress, 3)
|
|
39
|
-
setValue(Math.floor(eased * end))
|
|
40
|
-
if (progress < 1) requestAnimationFrame(step)
|
|
41
|
-
else setValue(end)
|
|
42
|
-
}
|
|
43
|
-
requestAnimationFrame(step)
|
|
44
|
-
}, [isInView, end, duration])
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<span ref={ref} className={className}>
|
|
48
|
-
{prefix}{value.toLocaleString(locale)}{suffix}
|
|
49
|
-
</span>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
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 Props {
|
|
10
|
-
children: React.ReactNode
|
|
11
|
-
className?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Cards scrollam horizontalmente enquanto o usuário scrolla para baixo.
|
|
16
|
-
* Tela fica pinada até o último card passar.
|
|
17
|
-
*/
|
|
18
|
-
export function HorizontalScroll({ children, className }: Props) {
|
|
19
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
20
|
-
const trackRef = useRef<HTMLDivElement>(null)
|
|
21
|
-
|
|
22
|
-
useGSAP(() => {
|
|
23
|
-
const prefersReduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
24
|
-
if (prefersReduced) return
|
|
25
|
-
|
|
26
|
-
const track = trackRef.current!
|
|
27
|
-
const getWidth = () => track.scrollWidth - window.innerWidth
|
|
28
|
-
|
|
29
|
-
const ctx = gsap.context(() => {
|
|
30
|
-
gsap.to(track, {
|
|
31
|
-
x: () => -getWidth(),
|
|
32
|
-
ease: "none",
|
|
33
|
-
scrollTrigger: {
|
|
34
|
-
trigger: containerRef.current,
|
|
35
|
-
start: "top top",
|
|
36
|
-
end: () => `+=${getWidth()}`,
|
|
37
|
-
scrub: 1,
|
|
38
|
-
pin: true,
|
|
39
|
-
anticipatePin: 1,
|
|
40
|
-
invalidateOnRefresh: true,
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
return () => ctx.revert()
|
|
46
|
-
}, { scope: containerRef })
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<div ref={containerRef} className={`overflow-hidden ${className ?? ""}`}>
|
|
50
|
-
<div
|
|
51
|
-
ref={trackRef}
|
|
52
|
-
className="flex w-max gap-6 px-4 md:gap-8 md:px-10"
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
children: React.ReactNode
|
|
5
|
-
speed?: "slow" | "normal" | "fast"
|
|
6
|
-
direction?: "left" | "right"
|
|
7
|
-
className?: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const speedMap = { slow: "60s", normal: "40s", fast: "20s" }
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Strip infinito de logos/itens com scroll automático.
|
|
14
|
-
* Pausa no hover.
|
|
15
|
-
*
|
|
16
|
-
* Requer no tailwind.config.ts:
|
|
17
|
-
* animation: { marquee: "marquee linear infinite" }
|
|
18
|
-
* keyframes: { marquee: { from: { transform: "translateX(0)" }, to: { transform: "translateX(-50%)" } } }
|
|
19
|
-
*/
|
|
20
|
-
export function LogoMarquee({
|
|
21
|
-
children,
|
|
22
|
-
speed = "normal",
|
|
23
|
-
direction = "left",
|
|
24
|
-
className,
|
|
25
|
-
}: Props) {
|
|
26
|
-
return (
|
|
27
|
-
<div className={`overflow-hidden ${className ?? ""}`}>
|
|
28
|
-
<div
|
|
29
|
-
className="flex w-max gap-8 animate-marquee hover:[animation-play-state:paused] md:gap-12"
|
|
30
|
-
style={{
|
|
31
|
-
animationDuration: speedMap[speed],
|
|
32
|
-
animationDirection: direction === "right" ? "reverse" : "normal",
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
{children}
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|