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
@@ -1,6 +1,7 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link, NavLink, useLocation } from 'react-router'
|
||||
import { Link, useLocation } from 'react-router'
|
||||
import { useTheme } from '@/hooks/useTheme'
|
||||
import { RollingTextLink } from '@/components/ui/RollingTextLink'
|
||||
|
||||
const navItems = [
|
||||
{ label: 'Home', path: '/' },
|
||||
@@ -42,14 +43,12 @@ export function Navigation() {
|
||||
<ul className="nav-menu">
|
||||
{navItems.map((item) => (
|
||||
<li key={item.path}>
|
||||
<NavLink
|
||||
<RollingTextLink
|
||||
to={item.path}
|
||||
className={({ isActive }) =>
|
||||
isActive ? 'nav-link active' : 'nav-link'
|
||||
}
|
||||
className={item.path === location.pathname ? 'nav-link active' : 'nav-link'}
|
||||
>
|
||||
{item.label}
|
||||
</NavLink>
|
||||
</RollingTextLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -97,15 +96,13 @@ export function Navigation() {
|
||||
<ul className="mobile-menu-list">
|
||||
{navItems.map((item) => (
|
||||
<li key={item.path}>
|
||||
<NavLink
|
||||
<RollingTextLink
|
||||
to={item.path}
|
||||
className={({ isActive }) =>
|
||||
isActive ? 'mobile-menu-link active' : 'mobile-menu-link'
|
||||
}
|
||||
className={item.path === location.pathname ? 'mobile-menu-link active' : 'mobile-menu-link'}
|
||||
onClick={() => setMobileOpen(false)}
|
||||
>
|
||||
{item.label}
|
||||
</NavLink>
|
||||
</RollingTextLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { SectionHeading } from '@/components/ui/SectionHeading'
|
||||
import { InView } from '@/components/ui/InView'
|
||||
import { Tag } from '@/components/ui/Tag'
|
||||
import { profile } from '@/data/profile'
|
||||
|
||||
export function About() {
|
||||
return (
|
||||
<section className="section container-content" aria-labelledby="about-heading">
|
||||
<InView>
|
||||
<section className="section container-wide" aria-labelledby="about-heading">
|
||||
<SectionHeading title="About Me" />
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<p style={{ fontSize: '18px', marginBottom: '32px' }}>
|
||||
@@ -41,5 +43,6 @@ export function About() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</InView>
|
||||
)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ export function Contact() {
|
||||
return (
|
||||
<InView>
|
||||
<motion.section
|
||||
className="section container-content"
|
||||
className="section container-wide"
|
||||
aria-labelledby="contact-heading"
|
||||
initial="hidden"
|
||||
whileInView="visible"
|
||||
@@ -19,6 +19,7 @@ export function Contact() {
|
||||
}}
|
||||
>
|
||||
<SectionHeading title="Contact" />
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<div className="contact-links">
|
||||
<motion.a
|
||||
href={`mailto:${profile.email}`}
|
||||
@@ -97,6 +98,7 @@ export function Contact() {
|
||||
</div>
|
||||
</motion.a>
|
||||
</div>
|
||||
</div>
|
||||
<DownloadResume />
|
||||
</motion.section>
|
||||
</InView>
|
||||
|
||||
@@ -6,7 +6,7 @@ export function Experience() {
|
||||
return (
|
||||
<InView>
|
||||
<motion.section
|
||||
className="section container-content"
|
||||
className="section container-wide"
|
||||
aria-labelledby="experience-heading"
|
||||
initial="hidden"
|
||||
whileInView="visible"
|
||||
@@ -29,6 +29,7 @@ export function Experience() {
|
||||
>
|
||||
Experience
|
||||
</motion.h2>
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<div className="timeline">
|
||||
{experiences.map((exp, i) => (
|
||||
<motion.div
|
||||
@@ -98,6 +99,7 @@ export function Experience() {
|
||||
</motion.div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</motion.section>
|
||||
</InView>
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { motion } from "motion/react"
|
||||
import { OpenToWorkBadge } from "@/components/ui/OpenToWorkBadge"
|
||||
import { motion, useScroll, useTransform } from "motion/react"
|
||||
import { InView } from "@/components/ui/InView"
|
||||
import { resumeAvailable } from "@/data/resume"
|
||||
import { Button } from "@/components/ui/Button"
|
||||
import { SocialLinks } from "@/components/ui/SocialLinks"
|
||||
@@ -40,7 +40,11 @@ const socialLinks = [
|
||||
]
|
||||
|
||||
export function Hero() {
|
||||
const { scrollY } = useScroll()
|
||||
const y = useTransform(scrollY, [0, 300], [0, -80])
|
||||
const opacity = useTransform(scrollY, [0, 200], [1, 0.3])
|
||||
return (
|
||||
<InView>
|
||||
<motion.section
|
||||
className="hero container-wide"
|
||||
initial={{ opacity: 0 }}
|
||||
@@ -50,6 +54,7 @@ export function Hero() {
|
||||
>
|
||||
<motion.div
|
||||
className="hero-content"
|
||||
style={{ opacity }}
|
||||
initial={{ opacity: 0, x: -30 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ duration: 0.6, delay: 0.2 }}
|
||||
@@ -89,7 +94,7 @@ export function Hero() {
|
||||
View Projects
|
||||
</Button>
|
||||
{resumeAvailable && (
|
||||
<Button href="/resume.pdf" variant="secondary" download>
|
||||
<Button href="/resume.pdf" variant="secondary" target="_blank">
|
||||
Download Resume
|
||||
</Button>
|
||||
)}
|
||||
@@ -101,6 +106,7 @@ export function Hero() {
|
||||
</motion.div>
|
||||
<motion.div
|
||||
className="hero-visual"
|
||||
style={{ y }}
|
||||
initial={{ opacity: 0, x: 30 }}
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ duration: 0.6, delay: 0.4 }}
|
||||
@@ -110,8 +116,8 @@ export function Hero() {
|
||||
alt="Profile photo"
|
||||
className="hero-photo"
|
||||
/>
|
||||
<OpenToWorkBadge />
|
||||
</motion.div>
|
||||
</motion.section>
|
||||
</InView>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Link } from "react-router"
|
||||
import { motion } from "motion/react"
|
||||
import { Badge } from "@/components/ui/Badge"
|
||||
import { projects } from "@/data/projects"
|
||||
import { InView } from "@/components/ui/InView"
|
||||
const MotionLink = motion.create(Link)
|
||||
|
||||
const categoryLabels: Record<string, string> = {
|
||||
"software-engineering": "Software Engineering",
|
||||
@@ -44,20 +46,20 @@ export function Projects() {
|
||||
}}
|
||||
>
|
||||
<h2 id="projects-heading">Featured Projects</h2>
|
||||
<motion.a
|
||||
href="/projects"
|
||||
<MotionLink
|
||||
to="/projects"
|
||||
style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }}
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
>
|
||||
View All →
|
||||
</motion.a>
|
||||
</MotionLink>
|
||||
</motion.div>
|
||||
<div className="projects-grid">
|
||||
{featured.map((project, i) => (
|
||||
<motion.a
|
||||
<MotionLink
|
||||
key={project.id}
|
||||
href={`/projects/${project.id}`}
|
||||
to={`/projects/${project.id}`}
|
||||
className="project-card"
|
||||
variants={{
|
||||
hidden: { opacity: 0, y: 30 },
|
||||
@@ -94,7 +96,7 @@ export function Projects() {
|
||||
</div>
|
||||
)}
|
||||
<span className="project-card-cta">View Details →</span>
|
||||
</motion.a>
|
||||
</MotionLink>
|
||||
))}
|
||||
</div>
|
||||
</motion.section>
|
||||
|
||||
@@ -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>)}
|
||||
>
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
@@ -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