Astra —— 沉浸式太空旅行登陆页
源于 MIT 许可的
pulkitxm/claude-directory图库中的登陆页。
为“Astra”打造的单一页面太空旅行登陆网站,包含两个全高部分——英雄区和能力展示区——两者都覆盖在循环播放的背景视频上,视频通过自定义的 rAF 驱动的 JavaScript 例程实现交叉淡入淡出(无 CSS 过渡)。页面为所有镀铬元素(导航、标签、卡片、行动号召按钮)采用“液态玻璃”设计系统;所有文字均为白色,显示在全出血视频上,无暗色叠加层,对比度完全来自玻璃镀铬效果。
工作流程
- 将
example.html克隆到用户的工作区作为工作文件。 - 替换占位内容为用户真实的品牌名称、标题、正文内容、数字和图像。更换资源时保持图像尺寸一致。
- 保留设计系统。 下方构建规范中的调色板、字阶、间距节奏和动效是核心特征——不要替换字体、改变调色板或移除装饰元素。
- 通过复制现有部分来扩展,绝不要从其他模板导入布局。如果缺少某个部分,请用此模板自己的设计语言从头开始设计。
- 保持动效可访问。 根据构建规范要求,每个动画都必须遵守
prefers-reduced-motion。
输出约定
在 <artifact> 标签之间输出:
<artifact identifier="space-voyage-landing" type="text/html" title="Astra —— 沉浸式太空旅行登陆页">
<!doctype html>
<html>...</html>
</artifact>
构建规范
以下是生成此设计的原始提示,逐字呈现。
Astra —— 沉浸式太空旅行登陆页
概述
构建一个单一页面的太空旅行登陆网站,包含两个全高部分——英雄区和能力展示区——两者都覆盖在循环播放的背景视频上,视频通过自定义的 rAF 驱动的 JavaScript 例程实现交叉淡入淡出(无 CSS 过渡)。页面为所有镀铬元素(导航、标签、卡片、行动号召按钮)采用“液态玻璃”设计系统,并使用 Motion(Framer Motion)实现入场动画,包括逐词模糊进入的标题。所有文字均为白色,显示在全出血视频上,无暗色叠加层;对比度完全来自液态玻璃镀铬效果。
技术栈
- 运行时 / 框架: React 18.3.1(UMD 开发构建,从 CDN 加载——无打包器)。
- JSX 编译: 通过 Babel Standalone 7.29.0 在浏览器中进行;每个组件都是一个
<script type="text/babel">文件,将自身导出到window.X = X。 - 动画: Framer Motion 11.11.17(UMD 构建,暴露为
window.Motion)。 - 样式: Tailwind CSS 通过 CDN
<script>(https://cdn.tailwindcss.com)加载,带有内联的tailwind.config,外加一个手写的<style>块用于液态玻璃工具类。 - 字体: Google Fonts —— 标题使用 Instrument Serif(
ital@0;1),正文使用 Barlow(wght@300;400;500;600)。 - 挂载点: 通过
ReactDOM.createRoot将 React 应用挂载到#root上。 - 显著技术: 自定义 rAF 交叉淡入淡出循环视频、IntersectionObserver 触发的模糊进入文字、通过遮罩
::before伪元素实现的液态玻璃渐变边框。
全局设置
index.html
<html lang="en">,charset UTF-8,响应式 viewport meta。<title>:astra —— Venture Past Our Sky。- Favicon:一个内联的 SVG data URI —— 一个黑色
rounded矩形(rx='16')内居中放置一个白色的斜体 Georgia 衬线小写字母a。 - Body:
<body class="bg-black antialiased">仅包含<div id="root"></div>,后跟所有 script 标签。 html, body { background: #000; }设置在<style>块中。
CDN 脚本(固定版本,仅 CDN)
按以下顺序加载在 <head> 内部:
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/[email protected]/umd/react.development.js" integrity="sha384-hD6/rw4ppMLGNu3tX5cjIb+uRZ7UkRJ6BPkLpg4hAu/6onKUg4lLsHAs9EBPT82L" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js" integrity="sha384-u6aeetuaXnQ38mYT8rp6sbXaQe3NL9t+IBXmnYxwkUI2Hw4bsp2Wvmx4yRQF1uAm" crossorigin="anonymous"></script>
<script src="https://unpkg.com/@babel/[email protected]/babel.min.js" integrity="sha384-m08KidiNqLdpJqLq95G/LEi8Qvjl/xUYll3QILypMoQ65QorJ9Lvtp2RXYGBFj1y" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/framer-motion.js"></script>
<script>window.Motion = window.FramerMotion;</script>
字体
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Barlow:wght@300;400;500;600&display=swap" rel="stylesheet" />
Tailwind 配置
在组件之前内联,扩展主题:
tailwind.config = {
theme: {
extend: {
fontFamily: {
heading: ['"Instrument Serif"', 'serif'],
body: ['Barlow', 'sans-serif'],
},
borderRadius: {
DEFAULT: '9999px',
},
},
},
};
font-heading→'Instrument Serif', serif(始终使用斜体)。font-body→'Barlow', sans-serif。- 默认 border-radius 覆盖
DEFAULT: '9999px',使得单独使用rounded变成药丸形。
Framer Motion 开发警告抑制
Framer Motion 关于列表键的开发警告是无害的,使用 console.error 包装器过滤掉:
(function () {
var origError = console.error;
console.error = function () {
var first = arguments[0];
if (typeof first === 'string' && (first.indexOf('unique "key" prop') !== -1 || first.indexOf('Each child in a list') !== -1)) return;
origError.apply(console, arguments);
};
})();
组件脚本加载顺序
在 <body> 末尾,按顺序加载每个 Babel 组件文件:
<script type="text/babel" src="js/icons.js"></script>
<script type="text/babel" src="js/FadingVideo.js"></script>
<script type="text/babel" src="js/BlurText.js"></script>
<script type="text/babel" src="js/Navbar.js"></script>
<script type="text/babel" src="js/Hero.js"></script>
<script type="text/babel" src="js/Capabilities.js"></script>
<script type="text/babel" src="js/App.js"></script>
液态玻璃工具类
在 <style> 块中有两种变体 —— .liquid-glass(细腻,用于导航 / 标签 / 卡片)和 .liquid-glass-strong(更重的模糊,用于主要行动号召按钮)。每个变体都通过遮罩的 ::before 伪元素绘制渐变边框。
.liquid-glass {
background: rgba(255,255,255,0.01);
background-blend-mode: luminosity;
backdrop-filter: blur(4px);
-webkit-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-composite: exclude;
pointer-events: none;
}
.liquid-glass-strong {
background: rgba(255,255,255,0.01);
background-blend-mode: luminosity;
backdrop-filter: blur(50px);
-webkit-backdrop-filter: blur(50px);
border: none;
box-shadow: 4px 4px 4px rgba(0,0,0,0.05), inset 0 1px 1px rgba(255,255,255,0.15);
position: relative;
overflow: hidden;
}
.liquid-glass-strong::before {
content: "";
position: absolute; inset: 0;
border-radius: inherit;
padding: 1.4px;
background: linear-gradient(180deg,
rgba(255,255,255,0.5) 0%,
rgba(255,255,255,0.2) 20%,
rgba(255,255,255,0) 40%,
rgba(255,255,255,0) 60%,
rgba(255,255,255,0.2) 80%,
rgba(255,255,255,0.5) 100%);
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
-webkit-mask-composite: xor;
mask-composite: exclude;
pointer-events: none;
}
- 强变体与细腻变体完全相同,除了:
backdrop-filter: blur(50px),box-shadow(4px 4px 4px rgba(0,0,0,0.05), inset 0 1px 1px rgba(255,255,255,0.15)),以及::before渐变停止点(0.5 / 0.2 / 0 / 0 / 0.2 / 0.5)。
图标 —— js/icons.js
内联的类似 Lucide 的 SVG 图标(currentColor 描边)加上 Material 图标字形。每个都分配给 window。将所有内容包装在 IIFE 中。
ArrowUpRight({ className })——24×24,viewBox="0 0 24 24",fill="none",stroke="currentColor",strokeWidth="2",圆头端点/连接,aria-hidden。两条路径:M7 17L17 7和M7 7h10v10。PlayIcon({ className })——24×24,viewBox="0 0 24 24",fill="currentColor",stroke="none",aria-hidden。填充多边形points="6 4 20 12 6 20 6 4"。ClockIcon—— 一个白色28×28轮廓 SVG 图标(时钟),用于统计卡片 1。GlobeIcon—— 一个白色28×28轮廓 SVG 图标(地球),用于统计卡片 2。- Material Icons SVG —— 一个白色 Material Icons SVG(
fill currentColor,h-6 w-6 text-white),用于能力卡片内部。
FadingVideo —— js/FadingVideo.js
自定义 JS 交叉淡入淡出循环视频。无 CSS 过渡:每个淡入淡出都由 rAF 驱动,循环通过 ended 事件手动实现(原生 loop 属性关闭)。
- 常量:
FADE_MS = 500,FADE_OUT_LEAD = 0.55(结束前开始淡出的秒数)。 FadingVideo({ src, className, style })渲染<video ref muted autoPlay playsInline preload="auto" />,带有style={{ opacity: 0, ...style }}(从opacity: 0开始)。- 通过
React.useRef使用的引用:videoRef,rafRef(当前 rAF id),fadingOutRef(布尔值)。 - 所有逻辑都在
React.useEffect(..., [src])中。
fadeTo(target, duration = FADE_MS):
- 如果
rafRef.current !== null,在开始前调用cancelAnimationFrame(rafRef.current)(这样新的淡入淡出会打断之前的)。 - 使用
parseFloat(video.style.opacity || '0')读取起始值,以便每个新的淡入淡出从上一个结束的地方继续。 - 使用
performance.now()获取开始时间;在每个requestAnimationFrame滴答中计算t = Math.min((now - start) / duration, 1),设置video.style.opacity = String(from + (target - from) * t),并继续请求帧直到t >= 1,然后设置rafRef.current = null。
事件处理器:
loadeddata:设置opacity = '0',video.play().catch(() => {}),然后fadeTo(1)。timeupdate:remaining = video.duration - video.currentTime;如果!fadingOutRef.current && remaining <= FADE_OUT_LEAD && remaining > 0,设置fadingOutRef.current = true并fadeTo(0)。ended:设置opacity = '0',然后经过setTimeout(..., 100)后重置currentTime = 0,play(),清除fadingOutRef.current = false,并fadeTo(1)。- 如果在附加监听器时
video.readyState >= 2,立即调用onLoadedData()。
卸载时清理: 取消 rAF(cancelAnimationFrame(rafRef.current))并移除所有三个监听器。
BlurText —— js/BlurText.js
逐词模糊进入的标题,在 10% 可见度时触发。引入 const { motion } = window.Motion。常量 STEP_DURATION = 0.35。
BlurText({ text, className, delay = 100 })。- 一个 IntersectionObserver,使用
{ threshold: 0.1 },在首次交叉时设置inView = true,然后observer.unobserve(el);清理时断开连接。 - 按空格分割文本:
const words = text.split(' ')。 - 渲染一个
<p ref className>,样式为display: flex; flexWrap: wrap; justifyContent: center; rowGap: 0.1em。 - 每个单词是一个
motion.span,带有key={${word}-${i}}:initial={{ filter: 'blur(10px)', opacity: 0, y: 50 }}。- 当可见时,动画关键帧:
否则保持{ filter: ['blur(10px)', 'blur(5px)', 'blur(0px)'], opacity: [0, 0.5, 1], y: [50, -5, 0], }{ filter: 'blur(10px)', opacity: 0, y: 50 }。 transition={{ duration: STEP_DURATION * 2, times: [0, 0.5, 1], ease: 'easeOut', delay: (i * delay) / 1000 }}。style={{ display: 'inline-block', marginRight: '0.28em' }}—— 使用marginRight而不是不换行空格,因为-4px的字母间距会吃掉不换行空格。
Navbar —— js/Navbar.js
浮动的液态玻璃镀铬元素。引入 const { ArrowUpRight } = window。NAV_LINKS = ['Home', 'Voyages', 'Worlds', 'Innovation', 'Plan Launch']。
<nav>类:fixed top-4 left-0 right-0 z-50 px-8 lg:px-16 flex items-center justify-between。- Logo(左侧): 一个
<a href="#" aria-label="astra home">,带有liquid-glass rounded-full w-12 h-12 flex items-center justify-center shrink-0。内部:<span class="font-heading italic text-white text-2xl leading-none -translate-y-px">a</span>(斜体衬线小写字母“a”)。 - 中心药丸(仅桌面端):
<div class="hidden md:flex items-center liquid-glass rounded-full px-1.5 py-1.5">包含:- 5 个导航链接,每个
<a href="#" key={link}>,带有px-3 py-2 text-sm font-medium text-white/90 font-body whitespace-nowrap hover:text-white。 - 一个白色药丸按钮:
<a href="#" class="flex items-center gap-1.5 bg-white text-black rounded-full px-4 py-2 text-sm font-medium font-body whitespace-nowrap">,文本为Claim a Spot,后跟<ArrowUpRight className="h-4 w-4" />。
- 5 个导航链接,每个
- 右侧: 一个不可见的 48×48 间隔元素用于平衡 logo ——
<div class="w-12 h-12 invisible shrink-0" aria-hidden="true" />。
第 1 部分 —— 英雄区(js/Hero.js)
全视口部分:交叉淡入淡出视频、导航栏、模糊进入标题、行动号召按钮、统计卡片、合作伙伴行。引入 const { motion } = window.Motion 和 const { FadingVideo, BlurText, Navbar, ArrowUpRight, PlayIcon, ClockIcon, GlobeIcon } = window。
HERO_VIDEO = 'assets/hf_20260418_080021_d598092b-c4c2-4e53-8e46-94cf9064cd50.mp4'。
入场动画辅助: 所有英雄内容使用 Motion 进行动画,使用:
const HIDDEN = { filter: 'blur(10px)'
...
const VISIBLE = { filter: 'blur(0px)' }(稍后在代码中实际使用)。
- 布局:
<section class="relative h-screen w-full overflow-hidden">。<FadingVideo src={HERO_VIDEO} className="absolute inset-0 w-full h-full object-cover" />。<Navbar />。- 标题(居中):
<div class="relative z-10 flex flex-col items-center justify-center h-full text-center px-4">。<BlurText text="Venture Past Our Sky" className="text-6xl lg:text-8xl font-heading italic text-white leading-tight" />。<p class="mt-6 text-lg lg:text-xl text-white/80 font-body max-w-2xl">Embark on a journey beyond the stars. Book your seat on the next voyage to the unknown.</p>。- 行动号召按钮:
<div class="mt-10 flex items-center gap-6">。<a href="#" class="liquid-glass-strong rounded-full px-8 py-4 text-white text-lg font-medium font-body flex items-center gap-2 hover:bg-white/10 transition-colors">带有文本Watch the Trailer和<PlayIcon className="h-5 w-5" />。<a href="#" class="text-white/80 font-body text-sm flex items-center gap-2 hover:text-white transition-colors">带有文本Explore Voyages和<ArrowUpRight className="h-4 w-4" />。
- 统计卡片(底部):
<div class="absolute bottom-8 left-0 right-0 flex justify-center gap-6 px-4">。<div class="liquid-glass rounded-2xl px-6 py-4 flex items-center gap-4">。<ClockIcon />。<div><p class="text-2xl font-heading italic text-white">2.5M</p><p class="text-sm text-white/60 font-body">Light Years Traveled</p></div>。
<div class="liquid-glass rounded-2xl px-6 py-4 flex items-center gap-4">。<GlobeIcon />。<div><p class="text-2xl font-heading italic text-white">1,247</p><p class="text-sm text-white/60 font-body">Worlds Explored</p></div>。
<div class="liquid-glass rounded-2xl px-6 py-4 flex items-center gap-4">。<div><p class="text-2xl font-heading italic text-white">99.8%</p><p class="text-sm text-white/60 font-body">Safety Rating</p></div>。
- 合作伙伴行(底部,统计卡片下方):
<div class="absolute bottom-4 left-0 right-0 flex justify-center gap-8 px-4 opacity-50">。- 5 个
<span class="text-white/40 text-sm font-body tracking-widest uppercase">Partner Logo</span>。
- 5 个
第 2 部分 —— 能力展示区(js/Capabilities.js)
第二个全视口部分:交叉淡入淡出视频、标题、能力网格。引入 const { motion } = window.Motion 和 const { FadingVideo, BlurText, ArrowUpRight } = window。
CAPABILITIES_VIDEO = 'assets/hf_20260418_080021_d598092b-c4c2-4e53-8e46-94cf9064cd50.mp4'(与英雄区视频相同,但可以不同)。CAPABILITIES = [...]—— 数组包含 6 个能力对象,每个具有{ title, description, icon }。
能力定义:
- Interstellar Navigation —— Advanced AI-driven navigation systems that chart the safest routes through unknown galaxies. 图标 Material Icons:
nearby_error。 - Quantum Communication —— Instantaneous communication across light-years using quantum entanglement technology. 图标 Material Icons:
cell_tower。 - Gravity Generation —— Artificial gravity systems that ensure comfort and safety during extended space voyages. 图标 Material Icons:
gravity。 - Life Support Systems —— Self-sustaining ecosystems that provide air, water, and food for long-duration missions. 图标 Material Icons:
ecosystem。 - Shield Technology —— Advanced energy shields that protect against cosmic radiation and space debris. 图标 Material Icons:
shield。 - Warp Drive —— Revolutionary propulsion technology enabling faster-than-light travel across the cosmos. 图标 Material Icons:
speed。
- 布局: 英雄区之后的
<section class="relative h-screen w-full overflow-hidden">。<FadingVideo src={CAPABILITIES_VIDEO} className="absolute inset-0 w-full h-full object-cover" />。- 内容:
<div class="relative z-10 flex flex-col items-center justify-center h-full px-8 lg:px-16">。<BlurText text="Capabilities" className="text-5xl lg:text-7xl font-heading italic text-white mb-12" />。<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 max-w-6xl w-full">。- 对于每个能力,
<div class="liquid-glass rounded-2xl p-6 flex flex-col items-start text-left">。<div class="w-12 h-12 rounded-full bg-white/10 flex items-center justify-center mb-4">,内部包含 Material Icons SVG(<svg class="h-6 w-6 text-white" fill="currentColor" viewBox="0 0 24 24">...</svg>)或者一个占位符。<h3 class="text-2xl font-heading italic text-white mb-2">{title}</h3>。<p class="text-sm text-white/70 font-body leading-relaxed">{description}</p>。<a href="#" class="mt-4 text-white/60 font-body text-sm flex items-center gap-1 hover:text-white transition-colors">Learn More <ArrowUpRight className="h-3 w-3" /></a>。
- 对于每个能力,
App —— js/App.js
根组件,导入 Hero 和 Capabilities,渲染它们。引入 const { Hero, Capabilities } = window。
function App() { return <><Hero /><Capabilities /></>; }。- 导出:
window.App = App。
index.html 结构(用于渲染)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>astra — Venture Past Our Sky</title>
<!-- Favicon (内联 SVG data URI) -->
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='16' fill='black'/%3E%3Ctext x='50%25' y='50%25' dominant-baseline='central' text-anchor='middle' font-family='Georgia' font-style='italic' font-weight='400' font-size='20' fill='white'%3Ea%3C/text%3E%3C/svg%3E" />
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- React -->
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
<!-- Babel Standalone -->
<script src="https://unpkg.com/@babel/[email protected]/babel.min.js"></script>
<!-- Framer Motion -->
<script src="https://unpkg.com/[email protected]/dist/framer-motion.js"></script>
<script>window.Motion = window.FramerMotion;</script>
<!-- 字体 -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Barlow:wght@300;400;500;600&display=swap" rel="stylesheet" />
<!-- 全局样式 -->
<style>
html, body { background: #000; margin: 0; }
/* 液态玻璃样式 ... */
</style>
<!-- Tailwind 配置 -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
heading: ['"Instrument Serif"', 'serif'],
body: ['Barlow', 'sans-serif'],
},
borderRadius: {
DEFAULT: '9999px',
},
},
},
};
// Framer Motion 警告抑制
(function () {
var origError = console.error;
console.error = function () {
var first = arguments[0];
if (typeof first === 'string' && (first.indexOf('unique "key" prop') !== -1 || first.indexOf('Each child in a list') !== -1)) return;
origError.apply(console, arguments);
};
})();
</script>
</head>
<body class="bg-black antialiased">
<div id="root"></div>
<!-- 组件脚本 -->
<script type="text/babel" src="js/icons.js"></script>
<script type="text/babel" src="js/FadingVideo.js"></script>
<script type="text/babel" src="js/BlurText.js"></script>
<script type="text/babel" src="js/Navbar.js"></script>
<script type="text/babel" src="js/Hero.js"></script>
<script type="text/babel" src="js/Capabilities.js"></script>
<script type="text/babel" src="js/App.js"></script>
<script type="text/babel">
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(React.createElement(window.App));
</script>
</body>
</html>
此结构是输出的模板。所有组件脚本应直接内联在 HTML 文件中以保持自包含。