Figma 作品集 - Next.js 开发者作品集
技能由 ara.so 提供 — 设计技能集。
适用于开发者和设计师的个人作品集模板,构建于 Next.js 16、TypeScript 和 TailwindCSS 之上。具有简洁的深色主题 UI,搭配紫色渐变强调色、打字动画效果、响应式布局,以及用于展示项目、工作经历和创意技能的各部分。
安装
# 克隆仓库
git clone [email protected]:ibrahimmemonn/Figma_Portfolio.git
# 进入项目目录
cd Figma_Portfolio/
# 安装依赖
npm install
# 运行开发服务器
npm run dev
开发服务器启动在 http://localhost:3000。
项目结构
Figma_Portfolio/
├── app/
│ ├── page.tsx # 主登录页面
│ ├── layout.tsx # 根布局与字体配置
│ └── globals.css # 包含 Tailwind 的全局样式
├── components/
│ ├── Hero.tsx # 带有打字动画的英雄区域
│ ├── Projects.tsx # 项目展示区域
│ ├── Experience.tsx # 工作经历时间轴
│ ├── Skills.tsx # 技能展示
│ └── Contact.tsx # 联系区域
├── public/
│ ├── projects/ # 项目图片
│ └── assets/ # 图标和媒体资源
└── tailwind.config.ts # Tailwind 配置
关键特性与配置
字体配置
该作品集使用通过 next/font 优化的 Poppins 字体:
// app/layout.tsx
import { Poppins } from 'next/font/google';
const poppins = Poppins({
subsets: ['latin'],
weight: ['300', '400', '500', '600', '700', '800', '900'],
variable: '--font-poppins',
});
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" className={poppins.variable}>
<body>{children}</body>
</html>
);
}
带有打字动画的英雄区域
// components/Hero.tsx
'use client';
import { useState, useEffect } from 'react';
export default function Hero() {
const [text, setText] = useState('');
const [isDeleting, setIsDeleting] = useState(false);
const [loopNum, setLoopNum] = useState(0);
const [typingSpeed, setTypingSpeed] = useState(150);
const roles = ['软件工程师', 'UI/UX 设计师', '全栈开发者'];
useEffect(() => {
const handleType = () => {
const i = loopNum % roles.length;
const fullText = roles[i];
setText(
isDeleting
? fullText.substring(0, text.length - 1)
: fullText.substring(0, text.length + 1)
);
setTypingSpeed(isDeleting ? 50 : 150);
if (!isDeleting && text === fullText) {
setTimeout(() => setIsDeleting(true), 1000);
} else if (isDeleting && text === '') {
setIsDeleting(false);
setLoopNum(loopNum + 1);
}
};
const timer = setTimeout(handleType, typingSpeed);
return () => clearTimeout(timer);
}, [text, isDeleting, loopNum, typingSpeed, roles]);
return (
<section className="min-h-screen flex items-center justify-center px-4">
<div className="max-w-4xl mx-auto text-center">
<h1 className="text-5xl md:text-7xl font-bold mb-6">
你好,我是 <span className="bg-gradient-to-r from-purple-400 to-pink-600 bg-clip-text text-transparent">你的名字</span>
</h1>
<h2 className="text-2xl md:text-4xl mb-8">
<span className="text-gray-400">{text}</span>
<span className="animate-pulse">|</span>
</h2>
<p className="text-gray-300 text-lg max-w-2xl mx-auto">
打造结合美学设计与强大功能的数字体验。
</p>
</div>
</section>
);
}
添加项目
// components/Projects.tsx
interface Project {
title: string;
description: string;
image: string;
link: string;
github?: string;
tags: string[];
}
const projects: Project[] = [
{
title: '电子商务平台',
description: '使用 Next.js、Stripe 和 MongoDB 的全栈电子商务解决方案',
image: '/projects/ecommerce.png',
link: 'https://example.com',
github: 'https://github.com/username/project',
tags: ['Next.js', 'TypeScript', 'Stripe', 'MongoDB'],
},
{
title: '作品集面板',
description: '跟踪作品集指标的仪表盘',
image: '/projects/dashboard.png',
link: 'https://example.com',
tags: ['React', 'Chart.js', 'TailwindCSS'],
},
];
export default function Projects() {
return (
<section className="py-20 px-4">
<h2 className="text-4xl font-bold text-center mb-12">
精选 <span className="bg-gradient-to-r from-purple-400 to-pink-600 bg-clip-text text-transparent">项目</span>
</h2>
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8 max-w-6xl mx-auto">
{projects.map((project, index) => (
<div key={index} className="bg-gray-800/50 rounded-lg overflow-hidden hover:transform hover:scale-105 transition-all duration-300">
<img src={project.image} alt={project.title} className="w-full h-48 object-cover" />
<div className="p-6">
<h3 className="text-xl font-semibold mb-2">{project.title}</h3>
<p className="text-gray-400 mb-4">{project.description}</p>
<div className="flex flex-wrap gap-2 mb-4">
{project.tags.map((tag, i) => (
<span key={i} className="px-3 py-1 bg-purple-500/20 text-purple-300 rounded-full text-sm">
{tag}
</span>
))}
</div>
<div className="flex gap-4">
<a href={project.link} className="text-purple-400 hover:text-purple-300">
在线演示 →
</a>
{project.github && (
<a href={project.github} className="text-gray-400 hover:text-gray-300">
GitHub →
</a>
)}
</div>
</div>
</div>
))}
</div>
</section>
);
}
自定义主题颜色
// tailwind.config.ts
import type { Config } from 'tailwindcss';
const config: Config = {
content: [
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
colors: {
primary: {
50: '#faf5ff',
100: '#f3e8ff',
500: '#a855f7',
600: '#9333ea',
700: '#7e22ce',
},
},
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
'gradient-conic': 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
},
},
plugins: [],
};
export default config;
添加分析工具
// app/layout.tsx
import { Analytics } from '@vercel/analytics/react';
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>
{children}
<Analytics />
</body>
</html>
);
}
部署
部署到 Vercel
# 安装 Vercel CLI
npm i -g vercel
# 部署
vercel
# 部署到生产环境
vercel --prod
或者将你的 GitHub 仓库连接到 Vercel,以便每次推送到 main 分支时自动部署。
环境变量
# .env.local(不提交到 git)
NEXT_PUBLIC_SITE_URL=https://your-domain.com
NEXT_PUBLIC_GA_ID=your-google-analytics-id
常见自定义模式
添加联系表单
// components/Contact.tsx
'use client';
import { useState } from 'react';
export default function Contact() {
const [formData, setFormData] = useState({
name: '',
email: '',
message: '',
});
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// 与你首选的邮件服务集成
const response = await fetch('/api/contact', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(formData),
});
if (response.ok) {
alert('消息发送成功!');
setFormData({ name: '', email: '', message: '' });
}
};
return (
<section className="py-20 px-4">
<div className="max-w-2xl mx-auto">
<h2 className="text-4xl font-bold text-center mb-12">联系我</h2>
<form onSubmit={handleSubmit} className="space-y-6">
<input
type="text"
placeholder="你的姓名"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
className="w-full px-4 py-3 bg-gray-800 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500"
required
/>
<input
type="email"
placeholder="你的邮箱"
value={formData.email}
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
className="w-full px-4 py-3 bg-gray-800 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500"
required
/>
<textarea
placeholder="你的消息"
value={formData.message}
onChange={(e) => setFormData({ ...formData, message: e.target.value })}
rows={5}
className="w-full px-4 py-3 bg-gray-800 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500"
required
/>
<button
type="submit"
className="w-full py-3 bg-gradient-to-r from-purple-500 to-pink-600 rounded-lg font-semibold hover:opacity-90 transition-opacity"
>
发送消息
</button>
</form>
</div>
</section>
);
}
平滑滚动导航
// components/Navigation.tsx
export default function Navigation() {
const scrollToSection = (id: string) => {
const element = document.getElementById(id);
element?.scrollIntoView({ behavior: 'smooth' });
};
return (
<nav className="fixed top-0 w-full bg-gray-900/80 backdrop-blur-sm z-50">
<div className="max-w-6xl mx-auto px-4 py-4 flex justify-between items-center">
<div className="text-xl font-bold">作品集</div>
<div className="flex gap-6">
<button onClick={() => scrollToSection('projects')} className="hover:text-purple-400">
项目
</button>
<button onClick={() => scrollToSection('experience')} className="hover:text-purple-400">
经历
</button>
<button onClick={() => scrollToSection('contact')} className="hover:text-purple-400">
联系
</button>
</div>
</div>
</nav>
);
}
故障排除
图片无法加载
确保图片位于 public 目录中,并使用绝对路径引用:
<img src="/projects/myproject.png" alt="项目" />
打字动画不工作
检查组件是否标记为 'use client' 以实现客户端交互:
'use client';
import { useState, useEffect } from 'react';
Tailwind 样式未应用
确保 tailwind.config.ts 中的 content 路径包含所有组件目录:
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
],
构建错误
清除 Next.js 缓存并重建:
rm -rf .next
npm run build
