added animation for home page

This commit is contained in:
dong.nguyen committed 2026-10-06 19:29:13 +07:00
1 parent 531c70e13a
commit 1800fa7ceb
15 files changed
+1289 -249

No files matched your search

+50 -24
View File
@@ -1,10 +1,11 @@
import { forwardRef } from 'react'
import type { ComponentPropsWithoutRef } from 'react'
import { motion } from "motion/react"
import { forwardRef } from "react"
import type { ComponentPropsWithoutRef } from "react"
type ButtonVariant = 'primary' | 'secondary' | 'ghost'
type ButtonSize = 'sm' | 'md' | 'lg'
type ButtonVariant = "primary" | "secondary" | "ghost"
type ButtonSize = "sm" | "md" | "lg"
interface ButtonProps extends ComponentPropsWithoutRef<'button'> {
interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
variant?: ButtonVariant
size?: ButtonSize
href?: string
@@ -13,36 +14,61 @@ interface ButtonProps extends ComponentPropsWithoutRef<'button'> {
}
const variantClasses: Record<ButtonVariant, string> = {
primary: 'btn btn-primary',
secondary: 'btn btn-secondary',
ghost: 'btn btn-ghost',
primary: "btn btn-primary",
secondary: "btn btn-secondary",
ghost: "btn btn-ghost",
}
const sizeClasses: Record<ButtonSize, string> = {
sm: 'btn-sm',
md: '',
lg: 'btn-lg',
sm: "btn-sm",
md: "",
lg: "btn-lg",
}
export const Button = forwardRef<
HTMLButtonElement | HTMLAnchorElement,
ButtonProps
>(({ variant = 'primary', size = 'md', href, className = '', children, ...props }, ref) => {
const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim()
>(
(
{
variant = "primary",
size = "md",
href,
className = "",
children,
...props
},
ref
) => {
const classes = `${variantClasses[variant]} ${sizeClasses[size]} ${className}`.trim()
if (href) {
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>)}
>
{children}
</motion.a>
)
}
if (href) {
return (
<a href={href} className={classes} ref={ref as React.Ref<HTMLAnchorElement>} {...(props as React.AnchorHTMLAttributes<HTMLAnchorElement>)}>
<motion.button
className={classes}
ref={ref as React.Ref<HTMLButtonElement>}
whileTap={{ scale: 0.95 }}
{...(props as Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof ButtonProps>)}
>
{children}
</a>
</motion.button>
)
}
)
return (
<button className={classes} ref={ref as React.Ref<HTMLButtonElement>} {...props}>
{children}
</button>
)
})
Button.displayName = 'Button'
Button.displayName = "Button"
+30
View File
@@ -0,0 +1,30 @@
import { motion, type MotionProps } from "motion/react"
import type { ReactNode } from "react"
interface InViewProps extends Omit<MotionProps, "children"> {
children: ReactNode
delay?: number
threshold?: number
className?: string
}
export function InView({
children,
delay = 0,
threshold = 0.1,
className,
...props
}: InViewProps) {
return (
<motion.div
className={className}
initial={{ opacity: 0, y: 30 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, amount: threshold }}
transition={{ duration: 0.5, delay }}
{...props}
>
{children}
</motion.div>
)
}
+27 -17
View File
@@ -1,23 +1,33 @@
import { profile } from '@/data/profile'
import { motion } from "motion/react"
export function OpenToWorkBadge() {
return (
<div className="otw-badge" role="status" aria-label="Open to work">
<svg
className="otw-icon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2.5"
strokeLinecap="round"
strokeLinejoin="round"
width="16"
height="16"
>
<polyline points="20 6 9 17 4 12" />
<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>
<span className="otw-title">Open to Work</span>
<span className="otw-subtitle">{profile.title}</span>
</div>
<motion.div
className="otw-badge"
animate={{ rotate: [-8, 8, -8] }}
transition={{ duration: 3, repeat: Infinity, ease: "easeInOut" }}
>
<span>#OpenToWork</span>
</motion.div>
</motion.div>
)
}
+9 -5
View File
@@ -1,8 +1,10 @@
import { motion } from "motion/react"
interface SocialLink {
label: string
href: string
icon: React.ReactNode
'aria-label': string
"aria-label": string
}
interface SocialLinksProps {
@@ -10,21 +12,23 @@ interface SocialLinksProps {
className?: string
}
export function SocialLinks({ links, className = '' }: SocialLinksProps) {
export function SocialLinks({ links, className = "" }: SocialLinksProps) {
return (
<div className={`social-links ${className}`}>
{links.map((link) => (
<a
<motion.a
key={link.label}
href={link.href}
target="_blank"
rel="noopener noreferrer"
className="social-link"
aria-label={link['aria-label']}
aria-label={link["aria-label"]}
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.9 }}
>
{link.icon}
<span>{link.label}</span>
</a>
</motion.a>
))}
</div>
)