Skip to content

Repository files navigation

Micro-interaction Lab Banner

VersionHonoCloudflareTypeScriptLicense

StarsForksIssuesLast CommitCode Size


Micro-interaction Lab

A premium micro-interaction component laboratory showcasing Apple-style motion design

Apple风格动效设计的高品质微交互组件实验室


View DemoReport BugRequest FeatureEnglish中文


6
Security Layers
安全层
20+
Components
组件
2K+
Lines of Code
代码行
60fps
Silk-smooth
丝滑动画
14KB
Hono Runtime
运行时
<50ms
Cold Start
冷启动

English

Table of Contents

Overview

Micro-interaction Lab is a curated showcase of premium UI micro-interactions built with obsessive attention to detail. Inspired by Apple's Human Interface Guidelines, Linear, and Vercel, every animation targets 60fps silk-smooth rendering with custom easing curves and spring physics.

The project is fully security-hardened with 6 layers of defense-in-depth protection, making it both a beautiful interactive demo and a reference implementation for secure edge-deployed web applications.

Tip

What makes it special?

  • Apple-style Motion — Custom cubic-bezier easing tokens for natural, physics-based animations
  • Zero Dependencies Frontend — Pure vanilla JS + Tailwind CDN + hand-crafted CSS
  • Security-First — CSP, HSTS, rate limiting, bot detection, anti-injection, source protection
  • Edge-Native — Built for Cloudflare Workers/Pages, globally distributed with <50ms cold start
  • Bilingual i18n — Full Chinese/English support with animated language switching
  • Dark Mode — System-aware theme toggle with smooth 500ms cross-fade transitions

Preview / 预览

Dark Mode / 暗色模式Light Mode / 亮色模式
Dark Mode HeroLight Mode Hero
Buttons / 魔法按钮Cards / 丝滑卡片
Buttons SectionCards Section

Features

1. Magical Buttons

ComponentEffectKey Technique
Aurora GlowGradient shimmer + gloss sweepbackground-size: 200% + animate-shimmer
Neon BorderRotating rainbow borderconic-gradient + animate-spin
Magnetic PullCursor-attracted movementmousemove + strength factor 0.3
Ripple EffectMaterial Design water rippleDynamic <span> insertion + scale(0->4)
Morphing ButtonSubmit -> Loading -> SuccessState machine with data-state + CSS transitions
SpotlightCursor-tracking light effectmousemove + radial gradient overlay

2. Smooth Cards

ComponentEffectKey Technique
3D TiltParallax depth on hoverperspective: 800px + rotateX/Y + preserve-3d
Glow BorderGradient border reveal1.5px inner offset + opacity transition
GlassmorphismFrosted glass overlaybackdrop-filter: blur(xl) + bg-white/30
Reveal CardBottom slide-in contenttranslate-y-full -> 0 with spring easing
Stacked LayersMulti-layer hover expand3 stacked elements with staggered translate-y
Spotlight CardCursor-tracking light300px radial gradient following mouse

3. Input Feedback

ComponentEffectKey Technique
Focus GlowGradient glow border on focusblur(2px) overlay + :focus-within
Float LabelLabel floats up on inputCSS peer selector + top transition
ValidationReal-time email checkingRegex + 300ms debounce + icon scale animation
Command SearchVercel-style search barCmd+K keyboard hint + icon color transition

4. Micro Loaders

8 distinct CSS-only loading animations: Orbit, Pulse, Wave, Morph, Bounce, Gradient, DNA Helix, Progress Bar

5. Global Features

  • Frosted Glass Navigation with sliding pill indicator
  • Scroll-Reveal System with IntersectionObserver + staggered 70ms delays
  • Floating Particles with 12 randomly colored dots
  • Back-to-Top Button with spring animation
  • Mobile Hamburger Menu with animated X toggle
  • Reduced Motion Support via prefers-reduced-motion

Security Architecture

The application implements 6 layers of defense-in-depth:

Request -> [Path Block] -> [Security Headers] -> [Rate Limit] -> [Bot Filter] -> [Input Validation] -> [Honeypot] -> App
Layer 1: Sensitive Path Blocking
/_worker.js -> 404 /src/* -> 404 /.git/* -> 404
/.env -> 404 /package.json -> 404 /wrangler.* -> 404
/node_modules -> 404 /tsconfig* -> 404 /vite.config* -> 404
Layer 2: Security Response Headers
HeaderValuePurpose
Content-Security-PolicyStrict whitelistPrevent XSS, injection
X-Frame-OptionsDENYPrevent clickjacking
Strict-Transport-Securitymax-age=31536000; includeSubDomains; preloadForce HTTPS
X-Content-Type-OptionsnosniffPrevent MIME sniffing
X-XSS-Protection1; mode=blockLegacy XSS filter
Referrer-Policystrict-origin-when-cross-originControl referrer leakage
Permissions-PolicyDisable camera/mic/geo/payment/usbRestrict browser APIs
Layer 3: Rate Limiting
  • 120 requests per 60-second window per IP address
  • Auto-cleanup when map exceeds 10,000 entries
  • X-RateLimit-Limit and X-RateLimit-Remaining headers
  • Returns 429 Too Many Requests when exceeded
Layer 4: Bot Detection

Blocked user agents: scrapy, python-requests, curl, wget, spider, crawler, headlesschrome, phantomjs, selenium, puppeteer

Layer 5: Content-Type Enforcement

POST, PUT, PATCH to /api/* must include valid Content-Type:

  • Allowed: application/json, application/x-www-form-urlencoded, multipart/form-data
  • Other: 415 Unsupported Media Type
Layer 6: Honeypot Traps

Common attack paths silently return 404: /admin, /wp-admin, /wp-login.php, /.env, /phpinfo.php, /config.php

Client-Side Source Protection
ProtectionMethod
Disable right-clickcontextmenu event blocked
Block shortcutsCtrl+U, Ctrl+S, F12, Ctrl+Shift+I/J/C, Ctrl+P
Disable selectionselectstart blocked on non-input elements
Disable dragdragstart blocked on all elements
DevTools detectionTiming-based detection with performance.now()
Console watermarkBranded messages with copyright notice
DOM watermarkCanvas-rendered invisible watermark with MutationObserver self-repair

Tech Stack

LayerTechnologyRole
RuntimeCloudflare WorkersEdge computing platform
FrameworkHono v4Ultrafast web framework (14KB)
BuildViteFrontend tooling
StylingTailwind CSS (CDN)Utility-first CSS
FontsInter + JetBrains MonoTypography
LanguageTypeScript + JSXType-safe server rendering
DeployCloudflare PagesGlobal CDN deployment
Dev ToolsWrangler + PM2Local dev & process management

Quick Start

Prerequisites

  • Node.js >= 18
  • npm >= 9

Installation

# Clone the repository
git clone https://github.com/zhuj3188-ship-it/prospective.git
cd prospective
# Install dependencies
npm install

Development

# Start Vite dev server (with hot reload)
npm run dev
# Or start with Wrangler (simulates Cloudflare Pages)
npm run build && npm run preview

Production

npm run build # Build for production
npm run deploy # Build + deploy to Cloudflare Pages

Project Structure

micro-interaction-lab/
├── src/
│ ├── index.tsx # Main app — routes + security middleware + JSX UI (~726 lines)
│ └── renderer.tsx # HTML shell — meta, fonts, Tailwind config (~73 lines)
├── public/static/
│ ├── app.js # Client engine — i18n, interactions, source protection (~737 lines)
│ └── style.css # Master stylesheet — easing tokens, animations, dark mode (~485 lines)
├── .github/
│ ├── workflows/ # CI/CD workflows
│ ├── ISSUE_TEMPLATE/ # Bug report & feature request templates
│ └── social-preview.png # Open Graph social image
├── dist/ # Build output (generated)
├── ecosystem.config.cjs # PM2 process configuration
├── wrangler.jsonc # Cloudflare Workers configuration
├── vite.config.ts # Vite build configuration
├── tsconfig.json # TypeScript configuration
└── package.json # Dependencies and scripts

API Reference

EndpointMethodDescriptionResponse
/GETFull HTML page with all components200 HTML
/api/infoGETApplication metadata200 JSON
/api/healthGETHealth check200 JSON
Response Examples

GET /api/info

{
"name": "Micro-interaction Lab",
"version": "3.0.0",
"components": ["Magical Buttons", "Smooth Cards", "Input Feedback", "Micro Loaders"],
"security": ["CSP", "HSTS", "Rate-Limiting", "Bot-Detection", "XSS-Protection", "Anti-Injection"]
}

GET /api/health

{
"status": "ok",
"timestamp": "2026-03-21T07:00:47.431Z"
}

Error Codes: 403 Bot detected | 404 Not found / blocked path | 415 Invalid Content-Type | 429 Rate limited | 500 Server error


Architecture

Client Request
│
▼
┌─────────────────────┐
│ Path Blocker │ ← Blocks /_worker.js, /src/*, /.git/*
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Security Headers │ ← CSP, HSTS, X-Frame-Options
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Rate Limiter │ ← 120 req/min per IP -> 429
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Bot Detector │ ← UA pattern matching -> 403
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Content-Type Guard │ ← POST/PUT/PATCH validation -> 415
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Honeypot Traps │ ← /admin, /wp-admin -> 404
└──────────┬──────────┘
▼
┌─────────────────────┐
│ JSX Renderer │ ← HTML document shell
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Route Handler │ ← GET / (page) | GET /api/* (JSON)
└──────────┬──────────┘
▼
Response
CSS Easing System
--ease-out-expo:cubic-bezier(0.16,1,0.3,1); /* Dramatic deceleration */--ease-out-quart:cubic-bezier(0.25,1,0.5,1); /* Smooth deceleration */--ease-spring:cubic-bezier(0.23,1,0.32,1); /* Spring overshoot */--ease-smooth:cubic-bezier(0.4,0,0.2,1); /* Material standard */--ease-bounce:cubic-bezier(0.34,1.56,0.64,1); /* Playful bounce */
i18n System

70+ translation keys across all UI components. Language toggle with animated switch:

currentLang=currentLang==='zh' ? 'en' : 'zh';// Elements fade out (150ms) -> text swap -> fade in (150ms)

Stored in localStorage as micro-lab-lang.


Animations Reference

AnimationDurationEasingUsage
hero-enter0.9s--ease-out-expoHero section entrance
orb-float20sease-in-outBackground gradient orbs
particle-float8-16sease-in-outFloating particles
scroll-dot1.5sease-in-outScroll indicator
wave-bar1.2sease-in-outWave loader bars
morph-square2sease-in-outMorphing square loader
bounce-loader0.6sease-in-outBouncing dots
dna-helix1.5sease-in-outDNA helix dots
progress-bar2sease-in-outProgress bar fill
gradient-shift8seaseHero title gradient
shimmer2.5slinearButton gloss sweep
menu-enter0.3s--ease-springMobile menu open
menu-exit0.2s--ease-smoothMobile menu close
ripple-expand0.6s--ease-out-expoButton ripple

Browser Support

BrowserVersionNotes
Chrome90+Full support
Firefox90+Full support
Safari15+Full support
Edge90+Full support
Mobile Safari15+Touch adapted
Chrome Android90+Touch adapted

Requires backdrop-filter support for glass effects. Graceful degradation on older browsers via prefers-reduced-motion.


Performance

MetricValue
Bundle size~104 KB (compiled worker)
Static assets~42 KB (CSS + JS)
Dependencies1 runtime (Hono 14KB)
Cold start<50ms (Cloudflare Workers)
Animation target60fps with will-change-transform
Lighthouse Score90+ (Performance, Accessibility)

Version History

VersionDateHighlights
v3.02026-03-21Security hardening: CSP, HSTS, rate limiting, bot detection, anti-injection, source protection, honeypot traps. UI: favicon, back-to-top, security badge.
v2.02026-03-21UI overhaul: frosted glass nav, hero particles, scroll reveal, glow dividers, mobile menu, footer redesign.
v1.02026-03-21Initial release: 4 component sections, i18n (zh/en), dark mode, responsive design.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

Scripts

npm run dev # Start Vite dev server with HMR
npm run build # Build for production (-> dist/)
npm run preview # Preview with Wrangler local server
npm run deploy # Build + deploy to Cloudflare Pages
npm run dev:sandbox # Run Wrangler on 0.0.0.0:3000
npm run clean-port # Kill process on port 3000
npm run cf-typegen # Generate Cloudflare bindings types


中文

目录

项目简介

Micro-interaction Lab 是一个精心策划的高品质 UI 微交互组件展示实验室,以极致的细节打造每一个交互。灵感源自 Apple 人机交互指南(HIG)、Linear 和 Vercel,所有动画均以 60fps 丝滑渲染为目标,采用自定义缓动曲线和弹簧物理模型。

项目拥有完整的 6 层纵深安全防护体系,既是一个精美的交互演示,也是安全边缘应用部署的参考实现。

Tip

为什么它与众不同?

  • Apple 风格动效 — 自定义 cubic-bezier 缓动令牌,实现自然的物理动画
  • 零前端依赖 — 纯原生 JS + Tailwind CDN + 手工精调 CSS
  • 安全至上 — CSP、HSTS、速率限制、Bot 检测、防注入、源码保护
  • 边缘原生 — 专为 Cloudflare Workers/Pages 打造,冷启动 <50ms
  • 中英双语 — 完整的中英文切换支持,带动画过渡效果
  • 暗色模式 — 系统感知主题切换,500ms 平滑渐变过渡

预览

暗色模式亮色模式
暗色模式首页亮色模式首页
魔法按钮丝滑卡片
按钮区域卡片区域

功能特性

1. 魔法按钮

组件效果核心技术
极光流光渐变流光 + 光泽扫过background-size: 200% + animate-shimmer
霓虹边框旋转彩虹边框conic-gradient + animate-spin
磁力吸附鼠标靠近时的吸附位移mousemove + 强度系数 0.3
水波纹Material Design 水波纹扩散动态 <span> 插入 + scale(0->4)
变形按钮提交 -> 加载中 -> 完成data-state 状态机 + CSS 过渡
聚光灯鼠标追踪的聚光效果mousemove + 径向渐变叠加

2. 丝滑卡片

组件效果核心技术
3D 倾斜悬浮视差深度perspective: 800px + rotateX/Y + preserve-3d
发光边框悬浮时渐变边框显现1.5px 内偏移 + opacity 过渡
毛玻璃拟态磨砂玻璃覆层backdrop-filter: blur(xl) + bg-white/30
揭示卡片底部滑入隐藏内容translate-y-full -> 0 + 弹簧缓动
层叠卡片多层悬浮展开3 层堆叠 + 阶梯式 translate-y
聚光灯卡片鼠标追踪柔光300px 径向渐变跟随鼠标

3. 灵动输入

组件效果核心技术
聚焦光晕聚焦时外发光渐变边框blur(2px) 叠加层 + :focus-within
浮动标签输入时标签上浮CSS peer 选择器 + top 过渡
实时验证实时邮箱格式检查正则 + 300ms 防抖 + 图标缩放
命令搜索Vercel 风格搜索框Cmd+K 提示 + 图标变色过渡

4. 微加载动画

8 种纯 CSS 加载动画:轨道旋转脉冲波浪变形方块弹跳渐变DNA 螺旋进度条

5. 全局特性

  • 毛玻璃导航栏 + 滑动药丸指示器
  • 滚动渐现系统 + 70ms 阶梯延迟
  • 浮动粒子 — 12 个彩色圆点
  • 回到顶部按钮 — 弹簧动画
  • 移动端汉堡菜单 — 动画 X 切换
  • 减少动画支持prefers-reduced-motion

安全架构

应用实现了 6 层纵深防御

请求 -> [路径拦截] -> [安全响应头] -> [速率限制] -> [Bot过滤] -> [输入验证] -> [蜜罐陷阱] -> 应用
第 1 层:敏感路径拦截
/_worker.js -> 404 /src/* -> 404 /.git/* -> 404
/.env -> 404 /package.json -> 404 /wrangler.* -> 404
第 2 层:安全响应头
头部用途
Content-Security-Policy严格白名单防止 XSS 和注入
X-Frame-OptionsDENY防止点击劫持
Strict-Transport-Securitymax-age=31536000强制 HTTPS
X-Content-Type-Optionsnosniff防止 MIME 嗅探
Referrer-Policystrict-origin-when-cross-origin控制 Referrer
Permissions-Policy禁用摄像头/麦克风/地理位置等限制浏览器 API
第 3 层:速率限制

每 IP 60 秒内最多 120 次请求,超限返回 429

第 4 层:Bot 检测

拦截已知爬虫 UA:scrapy, python-requests, curl, wget, spider, puppeteer

第 5 层:Content-Type 强制

POST/PUT/PATCH 必须包含合法 Content-Type,否则返回 415

第 6 层:蜜罐陷阱

/admin, /wp-admin, /wp-login.php, /phpinfo.php 等攻击路径静默返回 404

客户端源码保护
保护措施实现方式
禁用右键拦截 contextmenu
快捷键拦截Ctrl+U/S, F12, Ctrl+Shift+I/J/C
禁止选择非输入框拦截 selectstart
DevTools 检测performance.now() 计时检测
控制台水印品牌标识 + 版权声明
DOM 水印Canvas 渲染 + MutationObserver 自修复

技术栈

层级技术用途
运行时Cloudflare Workers边缘计算平台
框架Hono v4超轻量 Web 框架 (14KB)
构建Vite前端构建工具
样式Tailwind CSS (CDN)原子化 CSS
字体Inter + JetBrains Mono排版字体
语言TypeScript + JSX类型安全渲染
部署Cloudflare Pages全球 CDN 部署

快速开始

# 克隆仓库
git clone https://github.com/zhuj3188-ship-it/prospective.git
cd prospective
# 安装依赖
npm install
# 开发模式
npm run dev
# 或使用 Wrangler(模拟 Cloudflare Pages)
npm run build && npm run preview
# 部署
npm run deploy

项目结构

micro-interaction-lab/
├── src/
│ ├── index.tsx # 主应用 — 路由 + 安全中间件 + JSX (~726 行)
│ └── renderer.tsx # HTML 外壳 — meta、字体、Tailwind (~73 行)
├── public/static/
│ ├── app.js # 客户端引擎 — i18n、交互、源码保护 (~737 行)
│ └── style.css # 主样式表 — 缓动、动画、暗色模式 (~485 行)
├── .github/ # GitHub 社区文件和工作流
├── dist/ # 构建输出(自动生成)
├── wrangler.jsonc # Cloudflare 配置
├── vite.config.ts # Vite 构建配置
└── package.json # 依赖和脚本

API 参考

端点方法说明响应
/GET完整组件页面200 HTML
/api/infoGET应用元数据200 JSON
/api/healthGET健康检查200 JSON

错误码: 403 Bot 检测 | 404 路径拦截 | 415 Content-Type 错误 | 429 速率限制 | 500 服务器错误


架构设计

客户端请求
│
▼
┌─────────────────────┐
│ 路径拦截器 │ ← 拦截 /_worker.js, /src/*, /.git/*
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 安全响应头 │ ← CSP, HSTS, X-Frame-Options
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 速率限制器 │ ← 每 IP 120次/分 -> 429
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Bot 检测器 │ ← UA 匹配 -> 403
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Content-Type 守卫 │ ← POST/PUT/PATCH -> 415
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 蜜罐陷阱 │ ← /admin, /wp-admin -> 404
└──────────┬──────────┘
▼
┌─────────────────────┐
│ JSX 渲染器 │ ← HTML 文档外壳
└──────────┬──────────┘
▼
┌─────────────────────┐
│ 路由处理器 │ ← GET / | GET /api/*
└──────────┬──────────┘
▼
响应返回

动画参考

动画持续时间缓动用途
hero-enter0.9s--ease-out-expo首屏入场
orb-float20sease-in-out背景光球
particle-float8-16sease-in-out浮动粒子
wave-bar1.2sease-in-out波浪加载
morph-square2sease-in-out变形方块
bounce-loader0.6sease-in-out弹跳圆点
dna-helix1.5sease-in-outDNA 螺旋
shimmer2.5slinear光泽扫过
ripple-expand0.6s--ease-out-expo按钮水波纹

浏览器支持

浏览器版本备注
Chrome90+完整支持
Firefox90+完整支持
Safari15+完整支持
Edge90+完整支持
Mobile Safari15+触摸适配
Chrome Android90+触摸适配

性能指标

指标数值
构建包~104 KB
静态资源~42 KB
运行时依赖Hono 14KB
冷启动<50ms
动画目标60fps
Lighthouse90+

版本历史

版本日期更新亮点
v3.02026-03-21安全加固:CSP、HSTS、速率限制、Bot 检测、防注入、源码保护、蜜罐
v2.02026-03-21UI 改版:毛玻璃导航、首屏粒子、滚动渐现、移动菜单
v1.02026-03-21首版:4 大组件区、中英双语、暗色模式、响应式设计

参与贡献

欢迎贡献代码!请参阅 CONTRIBUTING.md 了解详情。

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feat/amazing-feature)
  3. 提交更改 (git commit -m 'feat: add amazing feature')
  4. 推送分支 (git push origin feat/amazing-feature)
  5. 发起 Pull Request

可用脚本

npm run dev # 启动 Vite 开发服务器
npm run build # 构建生产版本
npm run preview # Wrangler 本地预览
npm run deploy # 构建 + 部署到 Cloudflare Pages
npm run dev:sandbox # 沙箱模式 (0.0.0.0:3000)
npm run clean-port # 终止端口 3000
npm run cf-typegen # 生成 Cloudflare 类型

License / 许可

MIT License © 2026 Micro Lab


Built with using Hono + Cloudflare Pages


If you found this useful, please consider giving it a star!

如果你觉得这个项目有帮助,请给一个 Star 支持!

Star History

About

⚡ Micro-interaction Lab — Apple-style 60fps micro-interaction showcase with 6-layer security | 微交互实验室 — Apple 风格 60fps 微交互组件展示,6层纵深安全防护

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages