feat: redesign docs landing hero with Tailwind migration
- Migrate landing CSS from raw classes to Tailwind v4 utilities (~1180 → ~680 lines) - Add @theme block with landing design tokens - Shrink download button, add OS auto-detection - Nav bar transparent at top, glass effect on scroll - Adjust hero spacing, title size, background color - Remove white background from logo and favicon - Force subtitle to single line on desktop
This commit is contained in:
@@ -1,21 +1,76 @@
|
||||
'use client';
|
||||
|
||||
import { motion } from 'motion/react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
const productSlides = [
|
||||
{
|
||||
src: '/screenshot-dark.png',
|
||||
alt: 'DBX data grid and AI assistant screenshot',
|
||||
label: 'Data grid',
|
||||
},
|
||||
{
|
||||
src: '/screenshot-connections.jpg',
|
||||
alt: 'DBX connection management screenshot',
|
||||
label: 'Connections',
|
||||
},
|
||||
{
|
||||
src: '/screenshot-grid.png',
|
||||
alt: 'DBX table data grid screenshot',
|
||||
label: 'Tables',
|
||||
},
|
||||
{
|
||||
src: '/screenshot-ai.jpg',
|
||||
alt: 'DBX AI assistant screenshot',
|
||||
label: 'AI',
|
||||
},
|
||||
];
|
||||
|
||||
export function HeroProductStage() {
|
||||
const [activeSlide, setActiveSlide] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = window.setInterval(() => {
|
||||
setActiveSlide((current) => (current + 1) % productSlides.length);
|
||||
}, 4200);
|
||||
|
||||
return () => window.clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className="landing-product"
|
||||
initial={{ opacity: 0, y: 28, rotateX: 4, rotateY: -6 }}
|
||||
animate={{ opacity: 1, y: 0, rotateX: 0, rotateY: 0 }}
|
||||
transition={{ duration: 0.9, delay: 0.12, ease: [0.16, 1, 0.3, 1] }}
|
||||
className="landing-product relative w-full mt-16 mb-12 overflow-hidden rounded-2xl max-[1040px]:max-w-[900px] max-[1040px]:mt-14 max-[760px]:mt-10 max-[760px]:mb-7 max-[760px]:rounded-xl"
|
||||
initial={{ opacity: 0, y: 36, scale: 0.985 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={{ duration: 0.9, delay: 0.18, ease: [0.16, 1, 0.3, 1] }}
|
||||
>
|
||||
<div className="landing-window-bar">
|
||||
<span />
|
||||
<span />
|
||||
<span />
|
||||
<div className="relative aspect-[16/10] overflow-hidden">
|
||||
{productSlides.map((slide, index) => (
|
||||
<img
|
||||
alt={slide.alt}
|
||||
aria-hidden={index !== activeSlide}
|
||||
className="landing-product-slide absolute inset-0 z-[1] w-full h-full object-cover object-left-top"
|
||||
data-active={index === activeSlide}
|
||||
key={slide.src}
|
||||
src={slide.src}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<div className="landing-product-dots absolute right-[18px] bottom-4 z-[5] flex gap-[7px] items-center rounded-full p-1.5 max-[760px]:right-3 max-[760px]:bottom-[11px]" aria-label="DBX product screenshots">
|
||||
{productSlides.map((slide, index) => (
|
||||
<button
|
||||
aria-current={index === activeSlide}
|
||||
aria-label={`Show ${slide.label} screenshot`}
|
||||
key={slide.src}
|
||||
onClick={() => setActiveSlide(index)}
|
||||
title={slide.label}
|
||||
type="button"
|
||||
className="block w-[9px] h-[9px] border-0 rounded-full p-0 cursor-pointer"
|
||||
>
|
||||
<span>{slide.label}</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<img src="/screenshot-dark.png" alt="DBX product screenshot" />
|
||||
</motion.div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,22 +18,22 @@ export function InfiniteMovingCards({ items, direction = 'left', speed = 'normal
|
||||
|
||||
return (
|
||||
<div
|
||||
className="landing-testimonial-marquee"
|
||||
className="landing-testimonial-marquee flex overflow-hidden select-none"
|
||||
data-direction={direction}
|
||||
data-speed={speed}
|
||||
aria-label="Testimonials"
|
||||
>
|
||||
<div className="landing-testimonial-track">
|
||||
<div className="landing-testimonial-track flex w-max min-w-full gap-3.5 px-[7px]">
|
||||
{repeatedItems.map((item, index) => (
|
||||
<figure className="landing-testimonial-card" key={`${item.name}-${index}`}>
|
||||
<div className="landing-testimonial-author">
|
||||
<img className="landing-testimonial-avatar" src={item.avatar} alt="" width={42} height={42} />
|
||||
<figure className="landing-testimonial-card flex-[0_0_340px] min-h-[188px] rounded-[9px] m-0 p-[22px] max-[760px]:flex-[0_0_286px] max-[760px]:min-h-[210px] max-[760px]:p-[18px]" key={`${item.name}-${index}`}>
|
||||
<div className="flex gap-3 items-center">
|
||||
<img className="w-[42px] h-[42px] shrink-0 border border-[rgba(178,200,230,0.18)] rounded-full bg-[rgba(255,255,255,0.04)] object-cover" src={item.avatar} alt="" width={42} height={42} />
|
||||
<figcaption>
|
||||
<strong>{item.name}</strong>
|
||||
<span>{item.role}</span>
|
||||
<strong className="block text-landing-ink text-[15px] font-[740] leading-[1.25]">{item.name}</strong>
|
||||
<span className="block mt-[3px] text-landing-muted text-xs leading-[1.35]">{item.role}</span>
|
||||
</figcaption>
|
||||
</div>
|
||||
<blockquote>{item.quote}</blockquote>
|
||||
<blockquote className="mt-[18px] text-sm font-[560] leading-[1.58] text-[color-mix(in_srgb,var(--color-landing-ink)_88%,var(--color-landing-muted))]">{item.quote}</blockquote>
|
||||
</figure>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,127 +1,127 @@
|
||||
'use client';
|
||||
|
||||
import { Check, Copy, ExternalLink } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { ChevronDown, Download, Server } from 'lucide-react';
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
|
||||
type InstallTabsProps = {
|
||||
lang: 'en' | 'cn';
|
||||
};
|
||||
|
||||
const releaseUrl = 'https://github.com/t8y2/dbx/releases/latest';
|
||||
type InstallOption = {
|
||||
id: string;
|
||||
label: string;
|
||||
href: string;
|
||||
};
|
||||
|
||||
const installOptions = {
|
||||
const allOptions: Record<string, InstallOption[]> = {
|
||||
en: [
|
||||
{
|
||||
id: 'macos',
|
||||
label: 'macOS',
|
||||
note: 'Homebrew',
|
||||
command: 'brew install --cask t8y2/tap/dbx',
|
||||
linkText: 'GitHub Releases',
|
||||
},
|
||||
{
|
||||
id: 'windows',
|
||||
label: 'Windows',
|
||||
note: 'Scoop',
|
||||
command: 'scoop bucket add dbx https://github.com/t8y2/scoop-bucket; scoop install dbx',
|
||||
linkText: 'GitHub Releases',
|
||||
},
|
||||
{
|
||||
id: 'linux',
|
||||
label: 'Linux',
|
||||
note: '.deb / AppImage',
|
||||
command: 'chmod +x DBX*.AppImage',
|
||||
linkText: 'Download packages',
|
||||
},
|
||||
{
|
||||
id: 'docker',
|
||||
label: 'Docker',
|
||||
note: 'Self-hosted',
|
||||
command: 'docker run -d --name dbx -p 4224:4224 -v dbx-data:/app/data t8y2/dbx',
|
||||
linkText: 'Docker docs',
|
||||
href: '/en/docs/getting-started#docker',
|
||||
},
|
||||
{ id: 'macos-arm', label: 'For macOS (Apple Silicon)', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_aarch64.dmg' },
|
||||
{ id: 'macos-intel', label: 'For macOS (Intel)', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_x64.dmg' },
|
||||
{ id: 'windows', label: 'For Windows', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_x64-setup.exe' },
|
||||
{ id: 'linux', label: 'For Linux x64', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_amd64.AppImage' },
|
||||
{ id: 'linux-arm', label: 'For Linux ARM64', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_aarch64.AppImage' },
|
||||
],
|
||||
cn: [
|
||||
{
|
||||
id: 'macos',
|
||||
label: 'macOS',
|
||||
note: 'Homebrew',
|
||||
command: 'brew install --cask t8y2/tap/dbx',
|
||||
linkText: 'GitHub Releases',
|
||||
},
|
||||
{
|
||||
id: 'windows',
|
||||
label: 'Windows',
|
||||
note: 'Scoop',
|
||||
command: 'scoop bucket add dbx https://github.com/t8y2/scoop-bucket; scoop install dbx',
|
||||
linkText: 'GitHub Releases',
|
||||
},
|
||||
{
|
||||
id: 'linux',
|
||||
label: 'Linux',
|
||||
note: '.deb / AppImage',
|
||||
command: 'chmod +x DBX*.AppImage',
|
||||
linkText: '下载安装包',
|
||||
},
|
||||
{
|
||||
id: 'docker',
|
||||
label: 'Docker',
|
||||
note: '自托管',
|
||||
command: 'docker run -d --name dbx -p 4224:4224 -v dbx-data:/app/data t8y2/dbx',
|
||||
linkText: 'Docker 文档',
|
||||
href: '/cn/docs/getting-started#docker',
|
||||
},
|
||||
{ id: 'macos-arm', label: '适用于 macOS (Apple Silicon)', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_aarch64.dmg' },
|
||||
{ id: 'macos-intel', label: '适用于 macOS (Intel)', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_x64.dmg' },
|
||||
{ id: 'windows', label: '适用于 Windows', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_x64-setup.exe' },
|
||||
{ id: 'linux', label: '适用于 Linux x64', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_amd64.AppImage' },
|
||||
{ id: 'linux-arm', label: '适用于 Linux ARM64', href: 'https://dl.dbxio.com/releases/latest/DBX_0.5.9_aarch64.AppImage' },
|
||||
],
|
||||
};
|
||||
|
||||
export function InstallTabs({ lang }: InstallTabsProps) {
|
||||
const options = installOptions[lang];
|
||||
const [activeId, setActiveId] = useState(options[0].id);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const active = options.find((item) => item.id === activeId) ?? options[0];
|
||||
const downloadLabel = { en: 'Download DBX', cn: '下载 DBX' };
|
||||
|
||||
async function copyCommand() {
|
||||
await navigator.clipboard.writeText(active.command);
|
||||
setCopied(true);
|
||||
window.setTimeout(() => setCopied(false), 1600);
|
||||
}
|
||||
const platformIconPaths = {
|
||||
dark: {
|
||||
'linux-arm': '/icons/platform/linux.svg',
|
||||
linux: '/icons/platform/linux.svg',
|
||||
'macos-arm': '/icons/platform/macos.png',
|
||||
'macos-intel': '/icons/platform/macos.png',
|
||||
windows: '/icons/platform/windows.png',
|
||||
},
|
||||
light: {
|
||||
'linux-arm': '/icons/platform/linux.svg',
|
||||
linux: '/icons/platform/linux.svg',
|
||||
'macos-arm': '/icons/platform/macos-white.png',
|
||||
'macos-intel': '/icons/platform/macos-white.png',
|
||||
windows: '/icons/platform/windows.png',
|
||||
},
|
||||
};
|
||||
|
||||
function detectPlatformId(): string {
|
||||
if (typeof navigator === 'undefined') return 'macos-arm';
|
||||
const ua = navigator.userAgent.toLowerCase();
|
||||
if (ua.includes('win')) return 'windows';
|
||||
if (ua.includes('linux')) return ua.includes('aarch64') || ua.includes('arm') ? 'linux-arm' : 'linux';
|
||||
return 'macos-arm';
|
||||
}
|
||||
|
||||
function PlatformIcon({ id, size, variant }: { id: string; size: number; variant: 'dark' | 'light' }) {
|
||||
const src = platformIconPaths[variant][id as keyof (typeof platformIconPaths)['dark']];
|
||||
if (!src) return <Server size={size} />;
|
||||
return <img alt="" aria-hidden="true" height={size} src={src} width={size} />;
|
||||
}
|
||||
|
||||
export function InstallTabs({ lang }: InstallTabsProps) {
|
||||
const options = allOptions[lang];
|
||||
const [open, setOpen] = useState(false);
|
||||
const [platformId, setPlatformId] = useState('macos-arm');
|
||||
|
||||
useEffect(() => {
|
||||
setPlatformId(detectPlatformId());
|
||||
}, []);
|
||||
|
||||
const primary = useMemo(() => options.find((o) => o.id === platformId) ?? options[0], [options, platformId]);
|
||||
const menuOptions = useMemo(() => options.filter((o) => o.id !== platformId), [options, platformId]);
|
||||
|
||||
return (
|
||||
<div className="landing-install">
|
||||
<div className="landing-install-tabs" role="tablist" aria-label={lang === 'cn' ? '安装平台' : 'Install platform'}>
|
||||
{options.map((item) => (
|
||||
<button
|
||||
aria-selected={item.id === active.id}
|
||||
className="landing-install-tab"
|
||||
<div
|
||||
className="landing-install relative z-20 block w-fit max-w-full mx-auto"
|
||||
data-open={open}
|
||||
onBlur={(event) => {
|
||||
if (!event.currentTarget.contains(event.relatedTarget)) {
|
||||
setOpen(false);
|
||||
}
|
||||
}}
|
||||
onMouseEnter={() => setOpen(true)}
|
||||
onMouseLeave={() => setOpen(false)}
|
||||
>
|
||||
<a
|
||||
aria-controls="landing-install-menu"
|
||||
aria-expanded={open}
|
||||
aria-haspopup="listbox"
|
||||
className="landing-install-trigger grid grid-cols-[auto_minmax(0,1fr)_auto] gap-4 items-center w-[min(400px,calc(100vw-48px))] min-h-[68px] border-0 rounded-full mx-auto px-7 cursor-pointer"
|
||||
href={primary.href}
|
||||
onFocus={() => setOpen(true)}
|
||||
>
|
||||
<PlatformIcon id={primary.id} size={30} variant="dark" />
|
||||
<span className="grid gap-0.5 min-w-0">
|
||||
<strong className="overflow-hidden text-[15px] font-[780] leading-[1.2] truncate">{downloadLabel[lang]}</strong>
|
||||
<small className="overflow-hidden text-xs font-[520] leading-tight truncate text-[color-mix(in_srgb,#0f172a_48%,#94a3b8)]">{primary.label}</small>
|
||||
</span>
|
||||
<ChevronDown size={18} />
|
||||
</a>
|
||||
<div
|
||||
className="landing-install-menu absolute z-30 top-[calc(100%+12px)] left-1/2 -translate-x-1/2 grid w-[min(360px,calc(100vw-48px))] border border-[rgba(155,176,205,0.17)] rounded-xl py-1.5"
|
||||
id="landing-install-menu"
|
||||
role="listbox"
|
||||
aria-label={lang === 'cn' ? '下载选项' : 'Download options'}
|
||||
>
|
||||
{menuOptions.map((item) => (
|
||||
<a
|
||||
aria-selected="false"
|
||||
className="landing-install-option grid grid-cols-[24px_minmax(0,1fr)_18px] gap-3 items-center min-w-0 border-0 px-[18px] py-3 bg-transparent text-left cursor-pointer"
|
||||
href={item.href}
|
||||
key={item.id}
|
||||
onClick={() => {
|
||||
setActiveId(item.id);
|
||||
setCopied(false);
|
||||
}}
|
||||
role="tab"
|
||||
type="button"
|
||||
role="option"
|
||||
>
|
||||
<span>{item.label}</span>
|
||||
<small>{item.note}</small>
|
||||
</button>
|
||||
<PlatformIcon id={item.id} size={20} variant="light" />
|
||||
<strong className="overflow-hidden text-sm font-[640] leading-[1.2] truncate">{item.label}</strong>
|
||||
<Download size={15} aria-hidden="true" />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div className="landing-install-command">
|
||||
<code>{active.command}</code>
|
||||
<button
|
||||
aria-label={lang === 'cn' ? '复制安装命令' : 'Copy install command'}
|
||||
className="landing-install-copy"
|
||||
onClick={copyCommand}
|
||||
title={lang === 'cn' ? '复制安装命令' : 'Copy install command'}
|
||||
type="button"
|
||||
>
|
||||
{copied ? <Check size={16} /> : <Copy size={16} />}
|
||||
</button>
|
||||
</div>
|
||||
<a className="landing-install-release" href={active.href ?? releaseUrl} target="_blank">
|
||||
{active.linkText}
|
||||
<ExternalLink size={14} />
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
export function LandingNav({ children }: { children: React.ReactNode }) {
|
||||
const ref = useRef<HTMLElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
if (!node) return;
|
||||
|
||||
function onScroll() {
|
||||
node!.classList.toggle('is-scrolled', window.scrollY > 60);
|
||||
}
|
||||
|
||||
onScroll();
|
||||
window.addEventListener('scroll', onScroll, { passive: true });
|
||||
return () => window.removeEventListener('scroll', onScroll);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<nav ref={ref} className="landing-nav">
|
||||
{children}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user