mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
feat: homepage enhancements - mobile padding, scroll animations, parallax, background gradient
- Fix mobile padding: add media queries for container and hero-content padding - Add InView wrapper to Hero and About for scroll-triggered animations - Add Hero parallax effect: photo moves on scroll, content fades out - Add section background gradient for smooth visual flow between sections - Unify section containers to container-wide for title alignment - Add maxWidth wrappers for text-heavy sections (About, Experience, Contact) - Replace OpenToWorkBadge with RollingTextLink component - Update nav router links and profile data - Add spec docs for v2 homepage enhancements and nav rolling text
This commit is contained in:
1 parent
1800fa7ceb
commit
aa30aed903
20 files changed
+1301
-326
No files matched your search
@@ -0,0 +1,122 @@
|
||||
import { Link } from "react-router"
|
||||
import { motion, useReducedMotion } from "motion/react"
|
||||
import { useRef, useState } from "react"
|
||||
|
||||
const outgoingVariants = {
|
||||
rest: { transform: "translateY(0%)" },
|
||||
active: { transform: "translateY(100%)" },
|
||||
}
|
||||
|
||||
const incomingVariants = {
|
||||
rest: { transform: "translateY(-100%)" },
|
||||
active: { transform: "translateY(0%)" },
|
||||
}
|
||||
|
||||
const transition = {
|
||||
duration: 0.3,
|
||||
ease: [0.338, 0.015, 0.395, 0.959] as const,
|
||||
}
|
||||
|
||||
interface RollingTextLinkProps {
|
||||
to: string
|
||||
className?: string
|
||||
onClick?: () => void
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export function RollingTextLink({ to, className, onClick, children }: RollingTextLinkProps) {
|
||||
const reduceMotion = useReducedMotion()
|
||||
const [active, setActive] = useState(false)
|
||||
const activeRef = useRef(false)
|
||||
const animating = useRef(false)
|
||||
const pendingRequest = useRef<boolean | null>(null)
|
||||
const hovered = useRef(false)
|
||||
const focused = useRef(false)
|
||||
|
||||
const updateActive = (next: boolean) => {
|
||||
activeRef.current = next
|
||||
setActive(next)
|
||||
}
|
||||
|
||||
const requestActive = (next: boolean) => {
|
||||
if (reduceMotion) return
|
||||
|
||||
if (next === activeRef.current) {
|
||||
pendingRequest.current = null
|
||||
return
|
||||
}
|
||||
|
||||
if (animating.current) {
|
||||
pendingRequest.current = next
|
||||
return
|
||||
}
|
||||
|
||||
animating.current = true
|
||||
updateActive(next)
|
||||
}
|
||||
|
||||
const completeAnimation = () => {
|
||||
if (!animating.current) return
|
||||
animating.current = false
|
||||
|
||||
if (pendingRequest.current !== null && pendingRequest.current !== activeRef.current) {
|
||||
const next = pendingRequest.current
|
||||
pendingRequest.current = null
|
||||
animating.current = true
|
||||
updateActive(next)
|
||||
} else {
|
||||
pendingRequest.current = null
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={to}
|
||||
className={className}
|
||||
onClick={onClick}
|
||||
onPointerEnter={() => {
|
||||
hovered.current = true
|
||||
requestActive(true)
|
||||
}}
|
||||
onPointerLeave={() => {
|
||||
hovered.current = false
|
||||
requestActive(focused.current)
|
||||
}}
|
||||
onFocus={() => {
|
||||
focused.current = true
|
||||
requestActive(true)
|
||||
}}
|
||||
onBlur={() => {
|
||||
focused.current = false
|
||||
requestActive(hovered.current)
|
||||
}}
|
||||
>
|
||||
<span style={{ position: "relative", display: "inline-block", overflow: "hidden" }}>
|
||||
<motion.span
|
||||
style={{ display: "block", whiteSpace: "nowrap" }}
|
||||
variants={outgoingVariants}
|
||||
initial="rest"
|
||||
animate={active ? "active" : "rest"}
|
||||
onAnimationComplete={completeAnimation}
|
||||
transition={transition}
|
||||
>
|
||||
{children}
|
||||
</motion.span>
|
||||
<motion.span
|
||||
style={{
|
||||
display: "block",
|
||||
whiteSpace: "nowrap",
|
||||
position: "absolute",
|
||||
inset: 0,
|
||||
}}
|
||||
variants={incomingVariants}
|
||||
initial="rest"
|
||||
animate={active ? "active" : "rest"}
|
||||
transition={transition}
|
||||
>
|
||||
{children}
|
||||
</motion.span>
|
||||
</span>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user