Asme — 電影級暗色英雄登陸頁面
此登陸頁面取自 MIT 授權的
pulkitxm/claude-directory展示庫。
全螢幕、單一視口(100vh,無捲動)的暗色英雄登陸頁面,用於展示 Asme,一個虛構的無程式碼 AI 應用平台。全螢幕背景為來自 Mux 的 HLS 影片串流,在 Safari 上原生播放,其他瀏覽器則透過 hls.js MediaSource 播放。一個液態玻璃藥丸形導覽列(使用 luminosity-blend 玻璃效果,並以遮罩的 ::before 漸層邊框作為裝飾)浮在 Instrument Serif 字體的英雄標題和一個動態電子郵件擷取 Call-to-Action (CTA) 之上 — 「取得早期存取權」會展開成一個表單,其中包含每秒 60 個字元的打字機效果佔位符,提交時會將 ArrowRight 圖標翻轉為 Check 圖標,並在 4 秒後自動重設。所有元素在頁面載入時都會透過 Motion(Framer Motion)觸發動畫。
工作流程
- 將
example.html複製到使用者的工作區,作為工作檔案。 - 替換預留位置內容,改為使用者真實的品牌名稱、標題、內文、數字和圖像。在替換素材時,請保持與原始圖像相同的尺寸。
- 保留設計系統。 下方建構規範中的調色板、字體級數、間距節奏和動畫效果是此設計的核心識別 — 不要更換字體、重新配色或移除裝飾元素。
- 透過複製區塊來擴展,切勿從其他模板匯入佈局。如果某個區塊缺失,請使用此模板本身的設計語言從頭開始設計。
- 保持動畫的可及性。 根據建構規範的要求,每個動畫都必須遵循
prefers-reduced-motion設定。
輸出合約
在 <artifact> 標籤之間輸出:
<artifact identifier="asme-hero-landing" type="text/html" title="Asme — 電影級暗色英雄登陸頁面">
<!doctype html>
<html>...</html>
</artifact>
建構規範
以下是產生此設計的原始提示,逐字保留。
Asme — 電影級暗色英雄登陸頁面
概述
為「Asme」建立一個全螢幕、暗色、單螢幕(100vh,無捲動)的英雄登陸頁面。頁面具有黑色背景、全螢幕循環背景影片、玻璃擬態導覽列,以及一個帶有動畫電子郵件擷取 CTA 的居中英雄區塊。標題使用優雅的襯線顯示字體,並且大部分元素會在載入時透過 Motion 觸發動畫。
技術棧
- 框架: React 19(
react^19.2.7,react-dom^19.2.7)搭配 Vite(vite^8.0.16)和@vitejs/plugin-react^6.0.2。 - 樣式: Tailwind CSS v4(
tailwindcss^4.3.0),透過@tailwindcss/vite^4.3.0整合(使用@import "tailwindcss";+@theme方式,無需tailwind.config.js)。 - 動畫: Motion (Framer Motion)
motion^12.40.0,從motion/react匯入(motion,AnimatePresence)。 - 圖標: Lucide(
lucide-react^1.17.0)—Globe,ArrowRight,Check。 - 影片: 透過 HLS.js(
hls.js^1.6.16)播放 HLS,並為 Safari 提供原生 HLS 備援方案。 - 字體: Inter(基本無襯線字體)和 Instrument Serif(英雄標題字體),從 Google Fonts 載入。
- 值得注意的技術: 帶有遮罩漸層邊框的玻璃擬態、漸層剪裁文字、打字機效果佔位符、用於按鈕和電子郵件表單之間狀態切換的
AnimatePresence。
全域設定
入口 HTML (index.html)
-
<html lang="en">,<meta charset="UTF-8" />,<meta name="viewport" content="width=device-width, initial-scale=1.0" /> -
<title>:Asme — A new way to think and create with computers -
<meta name="description" content="Build a no-code AI app in minutes. Get early access to Asme." /> -
Favicon 是一個白色地球圖標的內聯 SVG data URI:
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20'/%3E%3Cpath d='M2 12h20'/%3E%3C/svg%3E" /> -
<body>包含<div id="root"></div>和<script type="module" src="/src/main.jsx"></script>。
React 入口 (src/main.jsx)
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App.jsx";
createRoot(document.getElementById("root")).render(
<StrictMode>
<App />
</StrictMode>,
);
樣式 (src/index.css)
匯入順序:先放兩個 Google Fonts 的 URL,然後是 Tailwind,最後是主題/基本規則。
-
字體 (Google Fonts):
- Inter,字重 300, 400, 500, 600 — 基本無襯線字體。
- Instrument Serif,常規和斜體 — 用於英雄標題。
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap"); @import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&display=swap"); @import "tailwindcss"; -
主題:
@theme { --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif; } -
根變數與主體:
:root { --background: #000000; --foreground: #ffffff; } body { background-color: var(--background); color: var(--foreground); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; } -
.liquid-glass— 帶有透過::before實現的遮罩漸層邊框的玻璃擬態表面:.liquid-glass { background: rgba(255, 255, 255, 0.01); background-blend-mode: luminosity; /* 將前綴寫在前面:確保在 LightningCSS 合併期間,標準屬性能成為最終生效的宣告。 */ -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); border: none; box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1); position: relative; overflow: hidden; } .liquid-glass::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1.4px; background: linear-gradient( 180deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.15) 20%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.15) 80%, rgba(255, 255, 255, 0.45) 100% ); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); mask-composite: exclude; pointer-events: none; } -
.glass-pill— 藥丸形狀的玻璃表面(為完整性而定義):.glass-pill { background: rgba(255, 255, 255, 0.04); -webkit-backdrop-filter: blur(16px) saturate(180%); backdrop-filter: blur(16px) saturate(180%); border-radius: 9999px; box-shadow: none !important; }
應用程式根佈局 (src/App.jsx)
<main>使用類別relative bg-black h-screen w-screen flex flex-col overflow-hidden selection:bg-white selection:text-black shrink-0。- 文字選取樣式為白色背景搭配黑色文字(
selection:bg-white selection:text-black)。 - 渲染順序:
BackgroundVideo,Navbar,Hero。
import BackgroundVideo from "./components/BackgroundVideo.jsx";
import Navbar from "./components/Navbar.jsx";
import Hero from "./components/Hero.jsx";
export default function App() {
return (
<main className="relative bg-black h-screen w-screen flex flex-col overflow-hidden selection:bg-white selection:text-black shrink-0">
<BackgroundVideo />
<Navbar />
<Hero />
</main>
);
}
背景影片 (src/components/BackgroundVideo.jsx)
- 渲染一個絕對定位的
<div>,覆蓋整個父級容器:absolute inset-0 overflow-hidden pointer-events-none。 - 包含一個具有
autoPlay,muted,loop,playsInline屬性的<video>元素,類別為w-full h-full object-cover opacity-100,並帶有一個ref。 - 影片來源 URL(一個托管在 Mux 上的 HLS 串流 — 注意:這是一個 Mux
.m3u8串流,不是 CloudFront URL):https://stream.mux.com/kimF2ha9zLrX64H00UgLGPflCzNtl1T0215MlAmeOztv8.m3u8 - 使用 HLS.js 的播放邏輯: 在
useEffect中,如果瀏覽器原生支援 HLS(video.canPlayType("application/vnd.apple.mpegurl")),則直接設定video.src。否則,如果Hls.isSupported(),則實例化new Hls(),呼叫loadSource,然後attachMedia,並在清理時使用hls.destroy()。.m3u8格式在非 Safari 瀏覽器上需要 HLS.js。
import { useEffect, useRef } from "react";
import Hls from "hls.js";
const VIDEO_SRC =
"https://stream.mux.com/kimF2ha9zLrX64H00UgLGPflCzNtl1T0215MlAmeOztv8.m3u8";
export default function BackgroundVideo() {
const videoRef = useRef(null);
useEffect(() => {
const video = videoRef.current;
if (!video) return undefined;
if (video.canPlayType("application/vnd.apple.mpegurl")) {
video.src = VIDEO_SRC;
return undefined;
}
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(VIDEO_SRC);
hls.attachMedia(video);
return () => hls.destroy();
}
return undefined;
}, []);
return (
<div className="absolute inset-0 overflow-hidden pointer-events-none">
<video
ref={videoRef}
autoPlay
muted
loop
playsInline
className="w-full h-full object-cover opacity-100"
/>
</div>
);
}
導覽列 (src/components/Navbar.jsx)
- 使用
motion.nav播放進入動畫:initial={{ y: -20, opacity: 0 }},animate={{ y: 0, opacity: 1 }}。 - 外部
motion.nav類別:relative z-20 px-6 py-6 w-full。 - 內部容器:
liquid-glass rounded-full px-6 py-3 flex items-center justify-between max-w-5xl mx-auto。 - 左側(
flex items-center gap-8):- Logo: Lucide 的
Globe圖標(w-6 h-6 text-white)+ 品牌文字 "Asme"(text-white font-semibold text-lg),包在一個flex items-center gap-2容器內。 - 導覽連結: "Features", "Pricing", "About" — 定義為
NAV_LINKS陣列並進行映射。在行動裝置上隱藏(hidden md:flex items-center gap-8 text-white/80 text-sm font-medium)。每個<a>使用href={#${link.toLowerCase()}}和類別hover:text-white transition-colors duration-300。
- Logo: Lucide 的
- 右側(
flex items-center gap-4):- "Sign Up" 純文字按鈕:
text-white hover:text-white/80 transition-colors text-sm font-medium cursor-pointer。 - "Login" 玻璃擬態按鈕:
liquid-glass rounded-full px-6 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity cursor-pointer。
- "Sign Up" 純文字按鈕:
import { motion } from "motion/react";
import { Globe } from "lucide-react";
const NAV_LINKS = ["Features", "Pricing", "About"];
export default function Navbar() {
return (
<motion.nav
initial={{ y: -20, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
className="relative z-20 px-6 py-6 w-full"
>
<div className="liquid-glass rounded-full px-6 py-3 flex items-center justify-between max-w-5xl mx-auto">
<div className="flex items-center gap-8">
<div className="flex items-center gap-2">
<Globe className="w-6 h-6 text-white" />
<span className="text-white font-semibold text-lg">Asme</span>
</div>
<div className="hidden md:flex items-center gap-8 text-white/80 text-sm font-medium">
{NAV_LINKS.map((link) => (
<a
key={link}
href={`#${link.toLowerCase()}`}
className="hover:text-white transition-colors duration-300"
>
{link}
</a>
))}
</div>
</div>
<div className="flex items-center gap-4">
<button
type="button"
className="text-white hover:text-white/80 transition-colors text-sm font-medium cursor-pointer"
>
Sign Up
</button>
<button
type="button"
className="liquid-glass rounded-full px-6 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity cursor-pointer"
>
Login
</button>
</div>
</div>
</motion.nav>
);
}
英雄區塊 (src/components/Hero.jsx)
佈局
<section>使用relative flex-1 flex flex-col items-center justify-center px-6。- 內容包裝器:
relative z-10 text-center max-w-5xl mx-auto flex flex-col items-center justify-center w-full gap-12。
標語 (motion.p)
- 文字:"Build a no-code AI app in minutes"。
- 類別:
text-white/80 text-[10px] md:text-[11px] font-medium tracking-[0.2em] uppercase mb-4。 - 動畫:
initial={{ opacity: 0, y: 10 }},animate={{ opacity: 1, y: 0 }},transition={{ delay: 0.1 }}。
標題 (motion.h1)
- 文字:"A new way to think and create with computers",在 "create" 之後插入一個
<br className="hidden md:block" />(即A new way to think and create{" "}後接<br />,再接with computers)。 - 透過內聯樣式設定字體:
style={{ fontFamily: "'Instrument Serif', serif" }}。 - 類別:
text-4xl md:text-[64px] font-medium tracking-[-0.01em] leading-[1.1] mb-6 bg-gradient-to-b from-white via-white/95 to-white/70 bg-clip-text text-transparent max-w-4xl。 - 動畫:
initial={{ opacity: 0, y: 20 }},animate={{ opacity: 1, y: 0 }},transition={{ duration: 1, ease: [0.16, 1, 0.3, 1] }}。
CTA 區域 (motion.div)
-
包裝器類別:
min-h-[50px] mt-2 w-full flex items-center justify-center。 -
動畫:
initial={{ opacity: 0, y: 10 }},animate={{ opacity: 1, y: 0 }},transition={{ delay: 0.4 }}。 -
使用
AnimatePresence mode="wait"在兩種狀態之間切換。兩種狀態都使用initial={{ opacity: 0, scale: 0.95 }},animate={{ opacity: 1, scale: 1 }},exit={{ opacity: 0, scale: 0.95 }},transition={{ duration: 0.2 }}。 -
按鈕狀態(
motion.button,key="cta-button"):文字 "Get early access"。類別px-10 py-3 text-[14px] font-medium border border-white/10 rounded-full hover:bg-white hover:text-black transition-colors duration-300 flex items-center gap-2 text-white。在span中包含ArrowRight圖標(className="w-5 h-5")。 -
表單狀態(
motion.div,key="cta-form"):類別flex items-center gap-3 w-full max-w-md mx-auto。包含:- 一個
<div className="relative flex-1">,內部有一個<input>,類型為email,預留位置為 "[email protected]"(使用useState和useEffect實現打字機效果:逐字顯示,間隔 60ms,然後保持不變)。輸入框類別:w-full px-5 py-3 bg-white/10 border border-white/20 rounded-full text-sm text-white placeholder:text-white/40 focus:outline-none focus:border-white/50 transition-colors。 - 一個
<button type="submit">,類別p-3 bg-white rounded-full text-black hover:bg-white/90 transition-colors shrink-0。 - 狀態管理:
CTAState:"button"|"form"|"submitted"。email:表單輸入值。displayedPlaceholder:打字機效果的目前字串。
- 點擊 "Get early access" 按鈕時將狀態設為
"form"。 - 提交表單時(
onSubmit防止預設行為):將狀態設為"submitted",並將按鈕圖標從ArrowRight切換為Check。 - 4 秒後,將狀態重設為
"button"並清除電子郵件 (`email = "")。
- 一個
import { useState, useEffect, useCallback } from "react";
import { motion, AnimatePresence } from "motion/react";
import { ArrowRight, Check } from "lucide-react";
export default function Hero() {
const [ctaState, setCtaState] = useState("button");
const [email, setEmail] = useState("");
const [displayedPlaceholder, setDisplayedPlaceholder] = useState("");
const PLACEHOLDER_TEXT = "[email protected]";
const TYPE_INTERVAL = 60;
useEffect(() => {
if (ctaState !== "form") {
setDisplayedPlaceholder("");
return;
}
let i = 0;
const timer = setInterval(() => {
i++;
setDisplayedPlaceholder(PLACEHOLDER_TEXT.slice(0, i));
if (i >= PLACEHOLDER_TEXT.length) {
clearInterval(timer);
}
}, TYPE_INTERVAL);
return () => clearInterval(timer);
}, [ctaState]);
const handleSubmit = useCallback(
(e) => {
e.preventDefault();
setCtaState("submitted");
setTimeout(() => {
setCtaState("button");
setEmail("");
setDisplayedPlaceholder("");
}, 4000);
},
[],
);
return (
<section className="relative flex-1 flex flex-col items-center justify-center px-6">
<div className="relative z-10 text-center max-w-5xl mx-auto flex flex-col items-center justify-center w-full gap-12">
<div>
<motion.p
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
className="text-white/80 text-[10px] md:text-[11px] font-medium tracking-[0.2em] uppercase mb-4"
>
Build a no-code AI app in minutes
</motion.p>
<motion.h1
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 1, ease: [0.16, 1, 0.3, 1] }}
style={{ fontFamily: "'Instrument Serif', serif" }}
className="text-4xl md:text-[64px] font-medium tracking-[-0.01em] leading-[1.1] mb-6 bg-gradient-to-b from-white via-white/95 to-white/70 bg-clip-text text-transparent max-w-4xl"
>
A new way to think and create{" "}
<br className="hidden md:block" />
with computers
</motion.h1>
</div>
<motion.div
initial={{ opacity: 0, y: 10 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.4 }}
className="min-h-[50px] mt-2 w-full flex items-center justify-center"
>
<AnimatePresence mode="wait">
{ctaState === "button" && (
<motion.button
key="cta-button"
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.2 }}
type="button"
onClick={() => setCtaState("form")}
className="px-10 py-3 text-[14px] font-medium border border-white/10 rounded-full hover:bg-white hover:text-black transition-colors duration-300 flex items-center gap-2 text-white"
>
Get early access
<ArrowRight className="w-5 h-5" />
</motion.button>
)}
{ctaState === "form" && (
<motion.div
key="cta-form"
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.2 }}
className="flex items-center gap-3 w-full max-w-md mx-auto"
>
<form
onSubmit={handleSubmit}
className="flex items-center gap-3 w-full"
>
<div className="relative flex-1">
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder={displayedPlaceholder}
className="w-full px-5 py-3 bg-white/10 border border-white/20 rounded-full text-sm text-white placeholder:text-white/40 focus:outline-none focus:border-white/50 transition-colors"
/>
</div>
<button
type="submit"
className="p-3 bg-white rounded-full text-black hover:bg-white/90 transition-colors shrink-0"
>
<ArrowRight className="w-5 h-5" />
</button>
</form>
</motion.div>
)}
{ctaState === "submitted" && (
<motion.div
key="cta-submitted"
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.2 }}
className="flex items-center gap-2"
>
<span className="text-white text-sm">Thanks! We'll be in touch.</span>
<Check className="w-5 h-5 text-white" />
</motion.div>
)}
</AnimatePresence>
</motion.div>
</div>
</section>
);
}
色彩調色板
| Token | 值 | 用途 |
|---|---|---|
--background | #000000 | 頁面背景 |
--foreground | #ffffff | 文字顏色 |
white/80 | rgba(255,255,255,0.8) | 次要文字、連結 |
white/10 | rgba(255,255,255,0.1) | 邊框、表面 |
white/04 | rgba(255,255,255,0.04) | 藥丸形玻璃背景 |
排版
| 元素 | 字體 | 大小 | 字重 | 行高 |
|---|---|---|---|---|
| 標題 | Instrument Serif | 64px (桌面) / 36px (行動) | 500 | 1.1 |
| 標語 | Inter | 11px (桌面) / 10px (行動) | 500 | 正常 |
| CTA 按鈕 | Inter | 14px | 500 | 正常 |
| 導覽列連結 | Inter | 14px | 500 | 正常 |
| 品牌 | Inter | 18px | 600 | 正常 |
間距
- 導覽列水平內邊距: 24px(桌面)/ 24px(行動)
- 導覽列垂直內邊距: 12px
- 標語底部外邊距: 16px
- 標題底部外邊距: 24px
- 英雄區塊間距: 48px(gap-12)
- CTA 內部間距(按鈕): 水平 40px,垂直 12px
- 表單輸入框內邊距: 水平 20px,垂直 12px
- 圖標尺寸: 20x20px(導覽列圖標)/ 24x24px(導覽列 Logo)
動畫
| 元素 | 類型 | 持續時間 | 延遲 | 緩動函數 |
|---|---|---|---|---|
| 導覽列 | 位移 + 透明度 | 0.3s | 0s | 預設 |
| 標語 | 位移 + 透明度 | 0.3s | 0.1s | 預設 |
| 標題 | 位移 + 透明度 | 1s | 0s | [0.16, 1, 0.3, 1] |
| CTA | 位移 + 透明度 | 0.3s | 0.4s | 預設 |
| 狀態切換 | 縮放 + 透明度 | 0.2s | 0s | 預設 |
可及性
-
prefers-reduced-motion: 每個 Motion 組件必須加上whileInView={{ ... }}或animate={{ ... }},並包裹在符合prefers-reduced-motion查詢的條件中,或者使用 Motion 的useReducedMotion鉤子來禁用動畫。在此實作中,所有初始動畫都發生在載入時,如果使用者偏好減少動畫,應完全跳過。實作方式:import { useReducedMotion } from "motion/react"; function Component() { const prefersReducedMotion = useReducedMotion(); const animation = prefersReducedMotion ? {} : { initial: { opacity: 0 }, animate: { opacity: 1 } }; return <motion.div {...animation}>Content</motion.div>; }
或者,如果使用者偏好減少動畫,則不渲染 Motion 組件,而是渲染靜態 HTML。