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:
dong.nguyen committed 2026-10-06 23:42:49 +07:00
1 parent 1800fa7ceb
commit aa30aed903
20 files changed
+1301 -326

No files matched your search

+26 -3
View File
@@ -1,5 +1,7 @@
import { Link } from "react-router"
import { motion } from "motion/react"
import { forwardRef } from "react"
const MotionLink = motion.create(Link)
import type { ComponentPropsWithoutRef } from "react"
type ButtonVariant = "primary" | "secondary" | "ghost"
@@ -10,7 +12,7 @@ interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
size?: ButtonSize
href?: string
download?: boolean
children: React.ReactNode
target?: string
}
const variantClasses: Record<ButtonVariant, string> = {
@@ -43,12 +45,34 @@ export const Button = forwardRef<
const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim()
if (href) {
const isRoute = href.startsWith("/")
const safeProps = { ...props }
if (isRoute) {
delete (safeProps as Record<string, unknown>)["download"]
}
if (isRoute) {
return (
<MotionLink
to={href}
className={classes}
ref={ref as React.Ref<HTMLAnchorElement>}
whileTap={{ scale: 0.95 }}
{...(safeProps as Omit<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
keyof ButtonProps | "to"
>)}
>
{children}
</MotionLink>
)
}
return (
<motion.a
href={href}
className={classes}
ref={ref as React.Ref<HTMLAnchorElement>}
whileTap={{ scale: 0.95 }}
{...(props as Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof ButtonProps>)}
>
@@ -61,7 +85,6 @@ export const Button = forwardRef<
<motion.button
className={classes}
ref={ref as React.Ref<HTMLButtonElement>}
whileTap={{ scale: 0.95 }}
{...(props as Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>)}
>
-33
View File
@@ -1,33 +0,0 @@
import { motion } from "motion/react"
export function OpenToWorkBadge() {
return (
<motion.div
className="otw-container"
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.3, duration: 0.5 }}
role="status"
aria-label="Open to work"
>
<svg className="otw-spring" viewBox="0 0 60 120">
<motion.path
d="M 30 0 C 50 5, 50 15, 30 20 C 10 25, 10 35, 30 40 C 50 45, 50 55, 30 60 C 10 65, 10 75, 30 80 C 50 85, 50 95, 30 100 C 10 105, 10 115, 30 120 L 30 125"
stroke="var(--accent)"
fill="none"
strokeWidth="2"
strokeLinecap="round"
animate={{ rotate: [-8, 8, -8] }}
transition={{ duration: 3, repeat: Infinity, ease: "easeInOut" }}
/>
</svg>
<motion.div
className="otw-badge"
animate={{ rotate: [-8, 8, -8] }}
transition={{ duration: 3, repeat: Infinity, ease: "easeInOut" }}
>
<span>#OpenToWork</span>
</motion.div>
</motion.div>
)
}
+122
View File
@@ -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>
)
}