mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
feat(ui): v3 enhancements - hero photo, particles, mobile responsive
- Hero photo: circular shape, object-position center top, transparent background - Hero particles: bigger (6-16px), more visible (opacity 0.8) - Mobile: hide hero photo, transparent hero content, fix text/social link colors - Mobile social links: darker border in light mode - Update spec docs and all section components for v3 UI
This commit is contained in:
1 parent
a303d98e41
commit
dd22f3be3a
26 files changed
+810
-504
No files matched your search
@@ -39,7 +39,6 @@ export function Footer() {
|
||||
<svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
|
||||
</svg>
|
||||
<span>GitHub</span>
|
||||
</a>
|
||||
<a
|
||||
href={profile.linkedinUrl}
|
||||
@@ -51,7 +50,6 @@ export function Footer() {
|
||||
<svg viewBox="0 0 24 24" fill="currentColor">
|
||||
<path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />
|
||||
</svg>
|
||||
<span>LinkedIn</span>
|
||||
</a>
|
||||
<a
|
||||
href={`mailto:${profile.email}`}
|
||||
@@ -62,7 +60,6 @@ export function Footer() {
|
||||
<rect x="2" y="4" width="20" height="16" rx="2" />
|
||||
<path d="M22 4l-10 8L2 4" />
|
||||
</svg>
|
||||
<span>Email</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,7 +37,9 @@ export function Navigation() {
|
||||
<nav className="nav" role="navigation" aria-label="Main navigation">
|
||||
<div className="nav-container">
|
||||
<Link to="/" className="nav-logo">
|
||||
Portfolio
|
||||
<span className="logo-bracket">{</span>
|
||||
<span className="logo-text">CV</span>
|
||||
<span className="logo-bracket">}</span>
|
||||
</Link>
|
||||
|
||||
<ul className="nav-menu">
|
||||
|
||||
@@ -7,7 +7,7 @@ export function About() {
|
||||
return (
|
||||
<InView>
|
||||
<section className="section container-wide" aria-labelledby="about-heading">
|
||||
<SectionHeading title="About Me" />
|
||||
<SectionHeading title="About Me" tag="01 - About" />
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<p style={{ fontSize: '18px', marginBottom: '32px' }}>
|
||||
{profile.bio}
|
||||
|
||||
@@ -18,7 +18,7 @@ export function Contact() {
|
||||
visible: { opacity: 1, transition: { duration: 0.5 } },
|
||||
}}
|
||||
>
|
||||
<SectionHeading title="Contact" />
|
||||
<SectionHeading title="Contact" tag="06 - Contact" />
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<div className="contact-links">
|
||||
<motion.a
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { resumeAvailable, resumeUrlFor, resumeLanguages } from '@/data/resume'
|
||||
import type { Language } from '@/types'
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
|
||||
const langLabels: Record<Language, string> = {
|
||||
en: 'English',
|
||||
@@ -23,10 +24,8 @@ function DownloadButton({ lang }: { lang: Language }) {
|
||||
border: '1px solid var(--border)',
|
||||
}}
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="24" height="24">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2 2v-4" />
|
||||
<polyline points="7 10 12 15 17 10" />
|
||||
<line x1="12" y1="15" x2="12" y2="3" />
|
||||
<svg viewBox="0 0 24 24" fill="currentColor" width="24" height="24">
|
||||
<path d="M12 2a1 1 0 0 1 1 1v9.586l2.707-2.707a1 1 0 1 1 1.414 1.414l-4.5 4.5a1 1 0 0 1-1.414 0l-4.5-4.5a1 1 0 1 1 1.414-1.414L11 12.586V3a1 1 0 0 1 1-1zm-7 16a1 1 0 1 1 0 2h14a1 1 0 1 1 0-2H5z" />
|
||||
</svg>
|
||||
<div>
|
||||
<div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>Download Resume</div>
|
||||
@@ -37,20 +36,41 @@ function DownloadButton({ lang }: { lang: Language }) {
|
||||
}
|
||||
|
||||
function DownloadDropdown() {
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
const listener = (e: MouseEvent | TouchEvent) => {
|
||||
if (ref.current && !ref.current.contains(e.target as Node)) {
|
||||
setOpen(false)
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', listener)
|
||||
document.addEventListener('touchstart', listener)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', listener)
|
||||
document.removeEventListener('touchstart', listener)
|
||||
}
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<details className="download-resume-dropdown">
|
||||
<summary className="download-resume-summary">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="20" height="20">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2 2v-4" />
|
||||
<polyline points="7 10 12 15 17 10" />
|
||||
<line x1="12" y1="15" x2="12" y2="3" />
|
||||
<div ref={ref} className="download-resume-dropdown">
|
||||
<button
|
||||
className={`download-resume-summary ${open ? 'open' : ''}`}
|
||||
onClick={() => setOpen(!open)}
|
||||
type="button"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="20" height="20">
|
||||
<path d="M12 3v10m0 0l-3-3m3 3l3-3" />
|
||||
<path d="M3 17h18" />
|
||||
</svg>
|
||||
<span>Download Resume</span>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="16" height="16" className="chevron">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="16" height="16" className="chevron">
|
||||
<polyline points="6 9 12 15 18 9" />
|
||||
</svg>
|
||||
</summary>
|
||||
<div className="download-resume-options">
|
||||
</button>
|
||||
<div className={`download-resume-options ${open ? 'open' : ''}`}>
|
||||
{resumeLanguages.map(lang => (
|
||||
<a
|
||||
key={lang}
|
||||
@@ -62,7 +82,7 @@ function DownloadDropdown() {
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SectionHeading } from '@/components/ui/SectionHeading'
|
||||
import { motion } from "motion/react"
|
||||
import { experiences } from "@/data/experience"
|
||||
import { InView } from "@/components/ui/InView"
|
||||
@@ -19,16 +20,7 @@ export function Experience() {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<motion.h2
|
||||
id="experience-heading"
|
||||
style={{ marginBottom: "48px" }}
|
||||
variants={{
|
||||
hidden: { opacity: 0, y: 30 },
|
||||
visible: { opacity: 1, y: 0, transition: { duration: 0.5 } },
|
||||
}}
|
||||
>
|
||||
Experience
|
||||
</motion.h2>
|
||||
<SectionHeading title="Experience" tag="03 - Experience" />
|
||||
<div style={{ maxWidth: '700px' }}>
|
||||
<div className="timeline">
|
||||
{experiences.map((exp, i) => (
|
||||
|
||||
@@ -20,7 +20,7 @@ export function Expertise() {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<SectionHeading title="Core Expertise" />
|
||||
<SectionHeading title="Core Expertise" tag="02 - Expertise" />
|
||||
<div className="expertise-grid">
|
||||
{skillGroups.map((group, i) => (
|
||||
<motion.div
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import { motion, useScroll, useTransform } from "motion/react"
|
||||
import { InView } from "@/components/ui/InView"
|
||||
import { resumeAvailable, resumeLanguages, resumeUrlFor } from "@/data/resume"
|
||||
@@ -7,22 +8,42 @@ const langLabels: Record<Language, string> = {
|
||||
en: 'EN',
|
||||
vi: 'VI',
|
||||
}
|
||||
|
||||
function HeroDownloadDropdown() {
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
const listener = (e: MouseEvent | TouchEvent) => {
|
||||
if (ref.current && !ref.current.contains(e.target as Node)) {
|
||||
setOpen(false)
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', listener)
|
||||
document.addEventListener('touchstart', listener)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', listener)
|
||||
document.removeEventListener('touchstart', listener)
|
||||
}
|
||||
}, [open])
|
||||
|
||||
return (
|
||||
<details className="download-resume-dropdown hero-download-dropdown">
|
||||
<summary className="download-resume-summary hero-download-summary">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="18" height="18">
|
||||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2 2v-4" />
|
||||
<polyline points="7 10 12 15 17 10" />
|
||||
<line x1="12" y1="15" x2="12" y2="3" />
|
||||
<div ref={ref} className="download-resume-dropdown hero-download-dropdown">
|
||||
<button
|
||||
className={`download-resume-summary hero-download-summary ${open ? 'open' : ''}`}
|
||||
onClick={() => setOpen(!open)}
|
||||
type="button"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="18" height="18">
|
||||
<path d="M12 3v10m0 0l-3-3m3 3l3-3" />
|
||||
<path d="M3 17h18" />
|
||||
</svg>
|
||||
<span>Download Resume</span>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" width="14" height="14" className="chevron">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="14" height="14" className="chevron">
|
||||
<polyline points="6 9 12 15 18 9" />
|
||||
</svg>
|
||||
</summary>
|
||||
<div className="download-resume-options">
|
||||
</button>
|
||||
<div className={`download-resume-options ${open ? 'open' : ''}`}>
|
||||
{resumeLanguages.map(lang => (
|
||||
<a
|
||||
key={lang}
|
||||
@@ -35,7 +56,7 @@ function HeroDownloadDropdown() {
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -52,6 +73,8 @@ function HeroDownloadButton({ lang }: { lang: Language }) {
|
||||
)
|
||||
}
|
||||
import { Button } from "@/components/ui/Button"
|
||||
import { Typewriter } from '@/components/ui/Typewriter'
|
||||
import { HeroParticles } from '@/components/sections/HeroParticles'
|
||||
import { SocialLinks } from "@/components/ui/SocialLinks"
|
||||
import { profile } from "@/data/profile"
|
||||
|
||||
@@ -102,6 +125,8 @@ export function Hero() {
|
||||
transition={{ duration: 0.3 }}
|
||||
aria-labelledby="hero-heading"
|
||||
>
|
||||
<div className="hero-bg-grid" />
|
||||
<HeroParticles />
|
||||
<motion.div
|
||||
className="hero-content"
|
||||
style={{ opacity }}
|
||||
@@ -109,6 +134,16 @@ export function Hero() {
|
||||
animate={{ opacity: 1, x: 0 }}
|
||||
transition={{ duration: 0.6, delay: 0.2 }}
|
||||
>
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.4, delay: 0.15 }}
|
||||
>
|
||||
<span className="hero-greeting">
|
||||
<span className="greeting-dot" />
|
||||
Hi, I'm
|
||||
</span>
|
||||
</motion.div>
|
||||
<motion.h1
|
||||
id="hero-heading"
|
||||
className="hero-name"
|
||||
@@ -116,7 +151,7 @@ export function Hero() {
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.5, delay: 0.3 }}
|
||||
>
|
||||
{profile.name}
|
||||
<span className="name-highlight">{profile.firstName}{" "}{profile.lastName}</span>
|
||||
</motion.h1>
|
||||
<motion.p
|
||||
className="hero-title"
|
||||
@@ -124,7 +159,7 @@ export function Hero() {
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.5, delay: 0.4 }}
|
||||
>
|
||||
{profile.title}
|
||||
<Typewriter texts={profile.roles} />
|
||||
</motion.p>
|
||||
<motion.p
|
||||
className="hero-tagline"
|
||||
@@ -143,6 +178,9 @@ export function Hero() {
|
||||
<Button href="/projects" variant="primary">
|
||||
View Projects
|
||||
</Button>
|
||||
<Button href="/contact" variant="primary">
|
||||
Contact Me
|
||||
</Button>
|
||||
{resumeAvailable && (
|
||||
<>
|
||||
<div className="hero-download-desktop">
|
||||
@@ -155,12 +193,15 @@ export function Hero() {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<Button href="/contact" variant="primary">
|
||||
Contact Me
|
||||
</Button>
|
||||
</motion.div>
|
||||
<SocialLinks links={socialLinks} />
|
||||
</motion.div>
|
||||
</motion.div>
|
||||
<div className="scroll-indicator" aria-hidden="true">
|
||||
<div className="scroll-mouse">
|
||||
<div className="scroll-wheel" />
|
||||
</div>
|
||||
<span>Scroll</span>
|
||||
</div>
|
||||
<motion.div
|
||||
className="hero-visual"
|
||||
style={{ y }}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useMemo } from "react"
|
||||
|
||||
export function HeroParticles() {
|
||||
const count = typeof window !== "undefined" && window.innerWidth < 768 ? 15 : 30
|
||||
const particles = useMemo(
|
||||
() =>
|
||||
Array.from({ length: count }, (_, i) => ({
|
||||
id: i,
|
||||
left: `${Math.random() * 100}%`,
|
||||
duration: `${Math.random() * 10 + 8}s`,
|
||||
delay: `${Math.random() * 10}s`,
|
||||
size: `${Math.random() * 10 + 6}px`,
|
||||
})),
|
||||
[count],
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="hero-particles" aria-hidden="true">
|
||||
{particles.map((p) => (
|
||||
<div
|
||||
key={p.id}
|
||||
className="hero-particle"
|
||||
style={{
|
||||
left: p.left,
|
||||
width: p.size,
|
||||
height: p.size,
|
||||
animationDuration: p.duration,
|
||||
animationDelay: p.delay,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SectionHeading } from '@/components/ui/SectionHeading'
|
||||
import { Link } from "react-router"
|
||||
import { motion } from "motion/react"
|
||||
import { Badge } from "@/components/ui/Badge"
|
||||
@@ -33,28 +34,13 @@ export function Projects() {
|
||||
},
|
||||
}}
|
||||
>
|
||||
<motion.div
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "baseline",
|
||||
marginBottom: "48px",
|
||||
}}
|
||||
variants={{
|
||||
hidden: { opacity: 0, y: 30 },
|
||||
visible: { opacity: 1, y: 0, transition: { duration: 0.5 } },
|
||||
}}
|
||||
<SectionHeading title="Featured Projects" tag="04 - Projects" />
|
||||
<Link
|
||||
to="/projects"
|
||||
style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)", display: "block", marginBottom: "24px" }}
|
||||
>
|
||||
<h2 id="projects-heading">Featured Projects</h2>
|
||||
<MotionLink
|
||||
to="/projects"
|
||||
style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)" }}
|
||||
whileHover={{ scale: 1.05 }}
|
||||
whileTap={{ scale: 0.95 }}
|
||||
>
|
||||
View All →
|
||||
</MotionLink>
|
||||
</motion.div>
|
||||
View All →
|
||||
</Link>
|
||||
<div className="projects-grid">
|
||||
{featured.map((project, i) => (
|
||||
<MotionLink
|
||||
@@ -72,30 +58,32 @@ export function Projects() {
|
||||
whileHover={{ scale: 1.02, y: -4 }}
|
||||
whileTap={{ scale: 0.98 }}
|
||||
>
|
||||
<div className="project-card-header">
|
||||
<h3>{project.title}</h3>
|
||||
<Badge variant="outline">
|
||||
{categoryLabels[project.category] || project.category}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="project-card-summary">{project.summary}</p>
|
||||
<div className="project-card-techs">
|
||||
{project.technologies.slice(0, 4).map((tech) => (
|
||||
<span key={tech} className="tag">
|
||||
{tech}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
{project.metrics && project.metrics.length > 0 && (
|
||||
<div className="project-card-metrics">
|
||||
{project.metrics.map((m) => (
|
||||
<span key={m} className="achievement-metric">
|
||||
{m}
|
||||
<div className="project-card-content">
|
||||
<div className="project-card-header">
|
||||
<h3>{project.title}</h3>
|
||||
<Badge variant="outline">
|
||||
{categoryLabels[project.category] || project.category}
|
||||
</Badge>
|
||||
</div>
|
||||
<p className="project-card-summary">{project.summary}</p>
|
||||
<div className="project-card-techs">
|
||||
{project.technologies.slice(0, 4).map((tech) => (
|
||||
<span key={tech} className="tag">
|
||||
{tech}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<span className="project-card-cta">View Details →</span>
|
||||
{project.metrics && project.metrics.length > 0 && (
|
||||
<div className="project-card-metrics">
|
||||
{project.metrics.map((m) => (
|
||||
<span key={m} className="achievement-metric">
|
||||
{m}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<span className="project-card-cta">View Details →</span>
|
||||
</div>
|
||||
</MotionLink>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { motion } from "motion/react"
|
||||
import { InView } from "@/components/ui/InView"
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
interface AnimatedSectionProps {
|
||||
direction?: "up" | "right" | "left"
|
||||
delay?: number
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
function getDirection(direction: 'up' | 'right' | 'left') {
|
||||
switch (direction) {
|
||||
case 'up': return { y: [40, 0], opacity: [0, 1] }
|
||||
case 'right': return { x: [-40, 0], opacity: [0, 1] }
|
||||
case 'left': return { x: [40, 0], opacity: [0, 1] }
|
||||
}
|
||||
}
|
||||
|
||||
export function AnimatedSection({
|
||||
direction = "up",
|
||||
delay = 0,
|
||||
children,
|
||||
}: AnimatedSectionProps) {
|
||||
const { y, opacity } = getDirection(direction)
|
||||
return (
|
||||
<InView>
|
||||
<motion.div
|
||||
initial={{ y, opacity }}
|
||||
whileInView={{ y: 0, opacity: 1 }}
|
||||
viewport={{ once: true, margin: "0px 0px -50px 0px" }}
|
||||
transition={{ duration: 0.6, delay, ease: [0.25, 0.1, 0.25, 1] }}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</InView>
|
||||
)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ type ButtonSize = "sm" | "md" | "lg"
|
||||
interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
variant?: ButtonVariant
|
||||
size?: ButtonSize
|
||||
icon?: React.ReactNode
|
||||
href?: string
|
||||
download?: boolean
|
||||
target?: string
|
||||
@@ -36,6 +37,7 @@ export const Button = forwardRef<
|
||||
variant = "primary",
|
||||
size = "md",
|
||||
href,
|
||||
icon,
|
||||
className = "",
|
||||
children,
|
||||
...props
|
||||
@@ -63,7 +65,10 @@ export const Button = forwardRef<
|
||||
keyof ButtonProps | "to"
|
||||
>)}
|
||||
>
|
||||
{children}
|
||||
{icon ? (<>
|
||||
{children}
|
||||
<span className="btn-icon">{icon}</span>
|
||||
</>) : children}
|
||||
</MotionLink>
|
||||
)
|
||||
}
|
||||
@@ -76,7 +81,10 @@ export const Button = forwardRef<
|
||||
whileTap={{ scale: 0.95 }}
|
||||
{...(props as Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof ButtonProps>)}
|
||||
>
|
||||
{children}
|
||||
{icon ? (<>
|
||||
{children}
|
||||
<span className="btn-icon">{icon}</span>
|
||||
</>) : children}
|
||||
</motion.a>
|
||||
)
|
||||
}
|
||||
@@ -88,7 +96,10 @@ export const Button = forwardRef<
|
||||
whileTap={{ scale: 0.95 }}
|
||||
{...(props as Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>)}
|
||||
>
|
||||
{children}
|
||||
{icon ? (<>
|
||||
{children}
|
||||
<span className="btn-icon">{icon}</span>
|
||||
</>) : children}
|
||||
</motion.button>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
interface SectionHeadingProps {
|
||||
title: string
|
||||
subtitle?: string
|
||||
tag?: string
|
||||
id?: string
|
||||
}
|
||||
|
||||
export function SectionHeading({ title, subtitle, id }: SectionHeadingProps) {
|
||||
export function SectionHeading({ title, subtitle, tag, id }: SectionHeadingProps) {
|
||||
return (
|
||||
<div className="section-heading" id={id}>
|
||||
{tag && <span className="section-tag">{tag}</span>}
|
||||
<h2>{title}</h2>
|
||||
{subtitle && <p>{subtitle}</p>}
|
||||
</div>
|
||||
|
||||
@@ -27,7 +27,6 @@ export function SocialLinks({ links, className = "" }: SocialLinksProps) {
|
||||
whileTap={{ scale: 0.9 }}
|
||||
>
|
||||
{link.icon}
|
||||
<span>{link.label}</span>
|
||||
</motion.a>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
interface TypewriterProps {
|
||||
texts: string[]
|
||||
typeSpeed?: number
|
||||
deleteSpeed?: number
|
||||
pauseDuration?: number
|
||||
}
|
||||
|
||||
export function Typewriter({
|
||||
texts,
|
||||
typeSpeed = 80,
|
||||
deleteSpeed = 40,
|
||||
pauseDuration = 2000,
|
||||
}: TypewriterProps) {
|
||||
const [currentTextIndex, setCurrentTextIndex] = useState(0)
|
||||
const [currentText, setCurrentText] = useState("")
|
||||
|
||||
const [isDeleting, setIsDeleting] = useState(false)
|
||||
useEffect(() => {
|
||||
const text = texts[currentTextIndex]
|
||||
let timeout: number
|
||||
|
||||
if (!isDeleting && currentText === text) {
|
||||
timeout = setTimeout(() => setIsDeleting(true), pauseDuration)
|
||||
} else if (isDeleting && currentText === "") {
|
||||
setIsDeleting(false)
|
||||
setCurrentTextIndex((prev) => (prev + 1) % texts.length)
|
||||
} else {
|
||||
timeout = setTimeout(
|
||||
() => {
|
||||
if (isDeleting) {
|
||||
setCurrentText(text.substring(0, currentText.length - 1))
|
||||
} else {
|
||||
setCurrentText(text.substring(0, currentText.length + 1))
|
||||
}
|
||||
},
|
||||
isDeleting ? deleteSpeed : typeSpeed,
|
||||
)
|
||||
}
|
||||
|
||||
return () => clearTimeout(timeout)
|
||||
}, [currentText, currentTextIndex, isDeleting, texts, typeSpeed, deleteSpeed, pauseDuration])
|
||||
|
||||
return (
|
||||
<span>
|
||||
{currentText}
|
||||
<span className="typewriter-cursor" />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user