|
| 1 | +# Frontend Design Skill |
| 2 | + |
| 3 | +为 MetaHuman Engine 项目提供前端设计指导和规范。 |
| 4 | + |
| 5 | +## 设计系统 |
| 6 | + |
| 7 | +### 色彩系统 |
| 8 | + |
| 9 | +项目采用深色主题为主,强调科技感和未来感。 |
| 10 | + |
| 11 | +```css |
| 12 | +/* 主色调 - 蓝紫渐变 */ |
| 13 | +--primary-gradient: linear-gradient(135deg, #3080ff, #625fff); |
| 14 | + |
| 15 | +/* 强调色 */ |
| 16 | +--accent-blue: oklch(0.6 0.2 250); /* 主蓝色 */ |
| 17 | +--accent-indigo: oklch(0.5 0.23 277); /* 靛蓝色 */ |
| 18 | +--accent-purple: oklch(0.6 0.25 292); /* 紫色 */ |
| 19 | + |
| 20 | +/* 背景色 */ |
| 21 | +--bg-primary: #0a0a0a; /* 主背景 */ |
| 22 | +--bg-secondary: #050508; /* 次级背景 */ |
| 23 | +--bg-elevated: #0d1117; /* 提升背景 */ |
| 24 | + |
| 25 | +/* 文本色 */ |
| 26 | +--text-primary: #fafafa; /* 主文本 */ |
| 27 | +--text-secondary: #a1a1aa; /* 次级文本 */ |
| 28 | +--text-muted: #71717a; /* 弱化文本 */ |
| 29 | +``` |
| 30 | + |
| 31 | +### 字体系统 |
| 32 | + |
| 33 | +使用 Inter 作为主字体,避免过度使用系统字体。 |
| 34 | + |
| 35 | +```css |
| 36 | +/* 主字体栈 */ |
| 37 | +font-family: |
| 38 | + 'Inter', |
| 39 | + -apple-system, |
| 40 | + BlinkMacSystemFont, |
| 41 | + 'Segoe UI', |
| 42 | + sans-serif; |
| 43 | + |
| 44 | +/* 等宽字体 */ |
| 45 | +font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; |
| 46 | + |
| 47 | +/* 字体大小比例 */ |
| 48 | +--text-xs: 0.75rem; /* 12px */ |
| 49 | +--text-sm: 0.875rem; /* 14px */ |
| 50 | +--text-base: 1rem; /* 16px */ |
| 51 | +--text-lg: 1.125rem; /* 18px */ |
| 52 | +--text-xl: 1.25rem; /* 20px */ |
| 53 | +--text-2xl: 1.5rem; /* 24px */ |
| 54 | +--text-3xl: 1.875rem; /* 30px */ |
| 55 | +--text-4xl: 2.25rem; /* 36px */ |
| 56 | +--text-5xl: 3rem; /* 48px */ |
| 57 | +--text-6xl: 3.75rem; /* 60px */ |
| 58 | +``` |
| 59 | + |
| 60 | +### 间距系统 |
| 61 | + |
| 62 | +使用 4px 基准的间距系统。 |
| 63 | + |
| 64 | +```css |
| 65 | +--spacing-1: 0.25rem; /* 4px */ |
| 66 | +--spacing-2: 0.5rem; /* 8px */ |
| 67 | +--spacing-3: 0.75rem; /* 12px */ |
| 68 | +--spacing-4: 1rem; /* 16px */ |
| 69 | +--spacing-6: 1.5rem; /* 24px */ |
| 70 | +--spacing-8: 2rem; /* 32px */ |
| 71 | +--spacing-12: 3rem; /* 48px */ |
| 72 | +--spacing-16: 4rem; /* 64px */ |
| 73 | +--spacing-24: 6rem; /* 96px */ |
| 74 | +``` |
| 75 | + |
| 76 | +### 圆角系统 |
| 77 | + |
| 78 | +```css |
| 79 | +--radius-sm: 0.25rem; /* 4px */ |
| 80 | +--radius-md: 0.375rem; /* 6px */ |
| 81 | +--radius-lg: 0.5rem; /* 8px */ |
| 82 | +--radius-xl: 0.75rem; /* 12px */ |
| 83 | +--radius-2xl: 1rem; /* 16px */ |
| 84 | +--radius-3xl: 1.5rem; /* 24px */ |
| 85 | +--radius-full: 9999px; /* 完全圆角 */ |
| 86 | +``` |
| 87 | + |
| 88 | +### 阴影系统 |
| 89 | + |
| 90 | +深色主题下的阴影需要配合模糊和透明度。 |
| 91 | + |
| 92 | +```css |
| 93 | +/* 发光阴影 */ |
| 94 | +--glow-blue: 0 0 20px rgba(48, 128, 255, 0.3); |
| 95 | +--glow-purple: 0 0 20px rgba(164, 75, 255, 0.3); |
| 96 | + |
| 97 | +/* 提升阴影 */ |
| 98 | +--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5); |
| 99 | +--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5); |
| 100 | +--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5); |
| 101 | +--shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.5); |
| 102 | +``` |
| 103 | + |
| 104 | +## 组件设计规范 |
| 105 | + |
| 106 | +### 按钮样式 |
| 107 | + |
| 108 | +```tsx |
| 109 | +// 主要按钮 |
| 110 | +<button className="px-6 py-3 bg-blue-600 hover:bg-blue-500 text-white font-semibold rounded-xl transition-all hover:shadow-xl hover:shadow-blue-600/20"> |
| 111 | + |
| 112 | +// 次要按钮 |
| 113 | +<button className="px-6 py-3 bg-white/5 hover:bg-white/10 text-white font-semibold rounded-xl border border-white/10 hover:border-white/20 transition-all"> |
| 114 | + |
| 115 | +// 图标按钮 |
| 116 | +<button className="p-2 text-gray-400 hover:text-white transition-colors rounded-lg hover:bg-white/5"> |
| 117 | +``` |
| 118 | + |
| 119 | +### 卡片样式 |
| 120 | + |
| 121 | +```tsx |
| 122 | +// 基础卡片 |
| 123 | +<div className="p-6 rounded-2xl border border-white/10 bg-white/[0.02] backdrop-blur-sm"> |
| 124 | + |
| 125 | +// 带图标的功能卡片 |
| 126 | +<div className="group relative p-6 rounded-2xl border border-blue-500/20 bg-blue-500/10 backdrop-blur-sm transition-all duration-300 hover:scale-[1.02] hover:shadow-xl"> |
| 127 | +``` |
| 128 | + |
| 129 | +### 输入框样式 |
| 130 | + |
| 131 | +```tsx |
| 132 | +// 文本输入 |
| 133 | +<input className="w-full px-4 py-3 bg-white/5 border border-white/10 rounded-xl text-white placeholder-white/30 focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-transparent transition-all" /> |
| 134 | + |
| 135 | +// 带图标的输入框 |
| 136 | +<div className="flex items-center gap-2 p-3 rounded-xl bg-black/40 backdrop-blur border border-white/10"> |
| 137 | + <SearchIcon className="w-5 h-5 text-gray-400" /> |
| 138 | + <input className="flex-1 bg-transparent border-none outline-none text-white" /> |
| 139 | +</div> |
| 140 | +``` |
| 141 | + |
| 142 | +### 导航栏样式 |
| 143 | + |
| 144 | +```tsx |
| 145 | +// 固定导航栏 |
| 146 | +<nav className="fixed top-0 left-0 right-0 z-50 bg-black/80 backdrop-blur-lg border-b border-white/10"> |
| 147 | + <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">{/* 导航内容 */}</div> |
| 148 | +</nav> |
| 149 | +``` |
| 150 | + |
| 151 | +## 布局规范 |
| 152 | + |
| 153 | +### 容器最大宽度 |
| 154 | + |
| 155 | +```tsx |
| 156 | +// 主容器 |
| 157 | +<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
| 158 | + |
| 159 | +// 内容容器 |
| 160 | +<div className="max-w-3xl mx-auto"> |
| 161 | + |
| 162 | +// 全宽容器 |
| 163 | +<div className="w-full"> |
| 164 | +``` |
| 165 | + |
| 166 | +### 响应式断点 |
| 167 | + |
| 168 | +```css |
| 169 | +/* Tailwind 默认断点 */ |
| 170 | +sm: 640px /* 手机横屏 */ |
| 171 | +md: 768px /* 平板竖屏 */ |
| 172 | +lg: 1024px /* 平板横屏/小屏电脑 */ |
| 173 | +xl: 1280px /* 桌面 */ |
| 174 | +2xl: 1536px /* 大屏桌面 */ |
| 175 | +``` |
| 176 | + |
| 177 | +### 网格布局 |
| 178 | + |
| 179 | +```tsx |
| 180 | +// 两列网格 |
| 181 | +<div className="grid md:grid-cols-2 gap-6"> |
| 182 | + |
| 183 | +// 三列网格 |
| 184 | +<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-6"> |
| 185 | + |
| 186 | +// 四列网格 |
| 187 | +<div className="grid grid-cols-2 md:grid-cols-4 gap-8"> |
| 188 | +``` |
| 189 | + |
| 190 | +## 动画规范 |
| 191 | + |
| 192 | +### 过渡动画 |
| 193 | + |
| 194 | +```tsx |
| 195 | +// 基础过渡 |
| 196 | +<div className="transition-all duration-300"> |
| 197 | + |
| 198 | +// 颜色过渡 |
| 199 | +<div className="transition-colors duration-200"> |
| 200 | + |
| 201 | +// 变换过渡 |
| 202 | +<div className="transition-transform duration-300"> |
| 203 | +``` |
| 204 | + |
| 205 | +### 悬停效果 |
| 206 | + |
| 207 | +```tsx |
| 208 | +// 上浮效果 |
| 209 | +<div className="hover:-translate-y-0.5 transition-transform"> |
| 210 | + |
| 211 | +// 缩放效果 |
| 212 | +<div className="hover:scale-[1.02] transition-transform"> |
| 213 | + |
| 214 | +// 发光效果 |
| 215 | +<div className="hover:shadow-xl hover:shadow-blue-600/20 transition-shadow"> |
| 216 | +``` |
| 217 | + |
| 218 | +### 加载动画 |
| 219 | + |
| 220 | +```tsx |
| 221 | +// 脉冲动画 |
| 222 | +<div className="animate-pulse"> |
| 223 | + |
| 224 | +// 旋转动画 |
| 225 | +<div className="animate-spin"> |
| 226 | + |
| 227 | +// 弹跳动画 |
| 228 | +<div className="animate-bounce"> |
| 229 | +``` |
| 230 | + |
| 231 | +## 特殊效果 |
| 232 | + |
| 233 | +### 玻璃拟态 |
| 234 | + |
| 235 | +```tsx |
| 236 | +<div className="bg-white/5 backdrop-blur-lg border border-white/10 rounded-2xl"> |
| 237 | +``` |
| 238 | + |
| 239 | +### 渐变背景 |
| 240 | + |
| 241 | +```tsx |
| 242 | +// 线性渐变 |
| 243 | +<div className="bg-gradient-to-r from-blue-500 via-indigo-500 to-purple-500"> |
| 244 | + |
| 245 | +// 径向渐变 |
| 246 | +<div className="bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-blue-600/10 to-transparent"> |
| 247 | +``` |
| 248 | + |
| 249 | +### 模糊光晕 |
| 250 | + |
| 251 | +```tsx |
| 252 | +// 背景光晕 |
| 253 | +<div className="absolute w-[800px] h-[800px] bg-blue-600/10 rounded-full blur-[120px]" /> |
| 254 | +``` |
| 255 | + |
| 256 | +## 可访问性 |
| 257 | + |
| 258 | +### 焦点状态 |
| 259 | + |
| 260 | +```tsx |
| 261 | +// 可见焦点环 |
| 262 | +<button className="focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-black"> |
| 263 | +``` |
| 264 | + |
| 265 | +### 减少动画 |
| 266 | + |
| 267 | +```tsx |
| 268 | +// 自动适配用户偏好 |
| 269 | +@media (prefers-reduced-motion: reduce) { |
| 270 | + * { |
| 271 | + animation-duration: 0.01ms !important; |
| 272 | + transition-duration: 0.01ms !important; |
| 273 | + } |
| 274 | +} |
| 275 | +``` |
| 276 | + |
| 277 | +### 屏幕阅读器 |
| 278 | + |
| 279 | +```tsx |
| 280 | +// 仅视觉隐藏 |
| 281 | +<span className="sr-only">描述性文本</span> |
| 282 | + |
| 283 | +// ARIA 标签 |
| 284 | +<button aria-label="关闭菜单"> |
| 285 | + <XIcon className="w-5 h-5" /> |
| 286 | +</button> |
| 287 | +``` |
| 288 | + |
| 289 | +## 设计原则 |
| 290 | + |
| 291 | +1. **一致性** - 保持视觉元素的一致性,使用统一的设计系统 |
| 292 | +2. **层次感** - 通过颜色、大小、间距建立清晰的视觉层次 |
| 293 | +3. **留白** - 合理使用负空间,避免界面过于拥挤 |
| 294 | +4. **反馈** - 为用户操作提供即时的视觉反馈 |
| 295 | +5. **性能** - 避免过度使用动画和效果,保持流畅体验 |
| 296 | +6. **可访问性** - 确保所有用户都能正常使用界面 |
| 297 | + |
| 298 | +## 避免的设计模式 |
| 299 | + |
| 300 | +1. **过度使用渐变** - 不要每个元素都使用渐变,保持克制 |
| 301 | +2. **过多阴影** - 深色主题下过多阴影会显得杂乱 |
| 302 | +3. **过小的点击区域** - 移动端点击区域至少 44x44px |
| 303 | +4. **低对比度文本** - 确保文本可读性,对比度至少 4.5:1 |
| 304 | +5. **动画滥用** - 动画应该有意义,不是为了炫技 |
0 commit comments