From 89215ac3b118b929094370d6b7ad4a59421f2339 Mon Sep 17 00:00:00 2001 From: ZingerLittleBee <6970999@gmail.com> Date: Fri, 4 Dec 2026 21:23:08 +0800 Subject: [PATCH 1/2] feat(landing): add dedicated interactive tailscale onboarding section --- apps/landing/src/components/landing.astro | 10 +- .../src/components/sections/tailscale.astro | 353 ++++++++++ apps/landing/src/i18n/copy.ts | 243 +++++++ apps/landing/src/lib/site.ts | 7 +- apps/landing/src/scripts/motion/index.ts | 2 + apps/landing/src/scripts/motion/tailscale.ts | 468 +++++++++++++ apps/landing/src/styles/global.css | 630 +++++++++++++++++- apps/landing/src/styles/motion.css | 76 +++ 8 files changed, 1783 insertions(+), 6 deletions(-) create mode 100644 apps/landing/src/components/sections/tailscale.astro create mode 100644 apps/landing/src/scripts/motion/tailscale.ts diff --git a/apps/landing/src/components/landing.astro b/apps/landing/src/components/landing.astro index cff545fa..0328ad27 100644 --- a/apps/landing/src/components/landing.astro +++ b/apps/landing/src/components/landing.astro @@ -12,6 +12,7 @@ import IpQuality from '@/components/sections/ip-quality.astro' import More from '@/components/sections/more.astro' import Network from '@/components/sections/network.astro' import Security from '@/components/sections/security.astro' +import Tailscale from '@/components/sections/tailscale.astro' import { landingCopy } from '@/i18n/copy' import Base from '@/layouts/base.astro' import { featureOrder, type Lang } from '@/lib/site' @@ -21,7 +22,14 @@ interface Props { } const { lang } = Astro.props -const features = { dash: Dashboards, ios: Ios, ipq: IpQuality, network: Network, security: Security } +const features = { + dash: Dashboards, + ios: Ios, + ipq: IpQuality, + network: Network, + security: Security, + tailscale: Tailscale +} --- diff --git a/apps/landing/src/components/sections/tailscale.astro b/apps/landing/src/components/sections/tailscale.astro new file mode 100644 index 00000000..1e6daa1d --- /dev/null +++ b/apps/landing/src/components/sections/tailscale.astro @@ -0,0 +1,353 @@ +--- +import Check from '@lucide/astro/icons/check' +import Lock from '@lucide/astro/icons/lock' +import RotateCcw from '@lucide/astro/icons/rotate-ccw' +import ShieldCheck from '@lucide/astro/icons/shield-check' +import Smartphone from '@lucide/astro/icons/smartphone' +import Terminal from '@lucide/astro/icons/terminal' +import Zap from '@lucide/astro/icons/zap' +import Heading from '@/components/heading.astro' +import OutLink from '@/components/out-link.astro' +import Points from '@/components/points.astro' +import { landingCopy, type TailscaleMode } from '@/i18n/copy' +import type { Lang } from '@/lib/site' + +interface Props { + lang: Lang +} + +const { lang } = Astro.props +const copy = landingCopy[lang].tailscale +const { stage } = copy +const modes: TailscaleMode[] = ['knock', 'ssh', 'baremetal'] +const qrCells = [ + 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, + 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, + 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, + 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, + 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, + 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, + 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, + 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, + 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 +] +--- + + + + + + {copy.lede} + {copy.link.label} + + + + + + + { + modes.map((mode, index) => ( + + {stage.modes[mode]} + + )) + } + + + + {stage.knock.replay} + + + + + + + + + {stage.knock.hostLabel} + prod-web-01 + + $ install.sh agent --tailscale + + { + stage.knock.terminalSteps.map((line, index) => ( + + + {line} + + )) + } + + + {stage.knock.sasLabel} + Z1T-T1D + + + + + + + + + + + {stage.knock.pipeWhois} + + + + + + {stage.knock.inboxLabel} + + {stage.knock.inboxBadge} + + + + + + prod-web-01 + 100.64.0.2 · ubuntu · alice@tailnet + + {stage.knock.whoisBadge} + + + {stage.knock.sasLabel} + Z1T-T1D + + + + CPU + — + + + MEM + — + + + RTT + — + + + + + {stage.knock.pending} + + + + {stage.knock.approve} + + + + + + + + + + + + {stage.ssh.serverLabel} + {stage.ssh.optIn} + + + + + ssh-node-01 + 100.64.0.3 · linux · root@100.64.0.3:22 + + {stage.ssh.ready} + + + LocalAPI + {stage.ssh.hostKeys} + + + + {stage.ssh.ready} + + + + {stage.ssh.deploy} + + + + + + + + + + + + + {stage.ssh.pipeHostKey} + + + + + + {stage.ssh.terminalLabel} + russh + + + { + stage.ssh.terminalLines.map((line, index) => ( + + {line} + + )) + } + + + + + + + + + + {stage.baremetal.hostLabel} + TTL 10m + + $ tailscale up --authkey=tskey-auth-*** && install.sh agent --tailscale + + { + stage.baremetal.stages.map((label, index) => ( + + + {label} + + )) + } + + + + + {stage.baremetal.action} + + + + + + + + + + + + {stage.baremetal.pipeLabel} + + + + + + {stage.baremetal.iosLabel} + {stage.baremetal.atsBadge} + + + + {qrCells.map((cell) => )} + + + https://{stage.baremetal.urlLabel} + + {stage.baremetal.iosWaiting} + + + + + + + + + + + diff --git a/apps/landing/src/i18n/copy.ts b/apps/landing/src/i18n/copy.ts index 17d0cd49..4e1dda38 100644 --- a/apps/landing/src/i18n/copy.ts +++ b/apps/landing/src/i18n/copy.ts @@ -66,6 +66,60 @@ interface HeroCopy { tabs: Record } +export type TailscaleMode = 'knock' | 'ssh' | 'baremetal' + +interface TailscaleCopy extends FeatureCopy { + stage: { + baremetal: { + action: string + atsBadge: string + hostLabel: string + iosLabel: string + iosPaired: string + iosWaiting: string + pipeLabel: string + replay: string + running: string + stages: [string, string, string] + urlLabel: string + } + knock: { + approve: string + approved: string + hostLabel: string + inboxBadge: string + inboxLabel: string + metricsLabel: string + online: string + pending: string + pipeApproved: string + pipeKnocking: string + pipeWhois: string + replay: string + sasLabel: string + terminalSteps: [string, string, string] + whoisBadge: string + } + modeLabel: string + modes: Record + ssh: { + deploy: string + deploying: string + deployed: string + hostKeys: string + optIn: string + pipeHostKey: string + pipeInstall: string + pipeOnline: string + ready: string + replay: string + serverLabel: string + terminalLabel: string + terminalLines: [string, string, string, string] + } + } +} + interface SecurityCopy extends FeatureCopy { /** The temporary grant command, taken apart: one note per argument. */ grant: { @@ -190,6 +244,7 @@ export interface LandingCopy { network: FeatureCopy scenes: ScenesCopy security: SecurityCopy + tailscale: TailscaleCopy /** Alternative text of the product captures. */ shots: Record } @@ -238,6 +293,10 @@ const zh: LandingCopy = { label: '安全', href: '#security' }, + { + label: 'Tailscale', + href: '#tailscale' + }, { label: '仪表盘', href: '#dash' @@ -368,6 +427,94 @@ const zh: LandingCopy = { href: docsUrl('zh', 'capabilities') } }, + tailscale: { + h2: '同在 Tailnet,设备自己找上门。', + lede: '服务端与主机登录同一个 Tailscale 或 Headscale,免配 API Key、免抄一次性注册码、面板零公网暴露。支持自动敲门核码一键批准、可选 Tailscale SSH 零接触部署,以及全新裸机二合一入网。', + stage: { + modeLabel: 'Tailscale 接入方式演示', + modes: { + knock: '自动敲门认领', + ssh: 'Tailscale SSH 部署', + baremetal: '裸机二合一 & iOS' + }, + knock: { + hostLabel: '目标 VPS · 100.64.0.2', + inboxLabel: 'ServerBee 收件箱 · 100.64.0.1', + inboxBadge: '待批准 1', + whoisBadge: 'WhoIs 已验身', + sasLabel: '安全核对码', + pending: '等待管理员核对并批准', + approve: '核码一键批准', + approved: '已原子签发并上线', + online: '在线', + metricsLabel: '实时监控中', + replay: '重放', + pipeKnocking: 'WireGuard 敲门', + pipeWhois: 'WhoIs + SAS', + pipeApproved: 'WSS 加密在线', + terminalSteps: [ + '经本机 tailscaled 发现 serverbee.ts.net', + '本地落盘暂存 run_token (0600)', + '直连 Tailnet 敲门完成,等待批准…' + ] + }, + ssh: { + serverLabel: 'ServerBee 控制台', + terminalLabel: '实时 SSE 部署终端 · 100.64.0.3:22', + optIn: '默认关闭 · 管理员开启', + hostKeys: '已锁定 3 把 sshHostKeys', + ready: 'SSH 就绪', + deploy: '一键远程部署', + deploying: '远程部署中…', + deployed: '零操作上线完成', + replay: '重放', + pipeHostKey: 'sshHostKeys 校验', + pipeInstall: '安全安装中', + pipeOnline: 'WSS 加密在线', + terminalLines: [ + '[1/4] 公钥匹配 Peer.sshHostKeys (ed25519)', + '[2/4] mktemp 安全下载安装脚本…', + '[3/4] 注入一次性注册码 [REDACTED] 并启动 Agent', + '[4/4] Agent 认领成功,4.1 秒上线' + ] + }, + baremetal: { + hostLabel: '全新裸机 · 未装 Tailscale', + iosLabel: 'iOS 伴生端 · Tailnet 扫码直连', + action: '运行二合一脚本', + running: '自动入网中…', + replay: '重放', + pipeLabel: '私网 HTTPS', + urlLabel: 'serverbee.fox-koi.ts.net', + atsBadge: 'Let’s Encrypt · ATS 就绪', + iosWaiting: '打开系统 Tailscale 扫码配对', + iosPaired: '已配对 · 私网加密直连', + stages: ['安装 Tailscale 并凭一次性密钥入网', '安装 Agent 并自动完成注册', '加密隧道上线并开始上报'] + } + }, + points: [ + { + t: '免 API Key 零配置发现', + d: '直连本机 tailscaled.sock 读取同网设备并支持网页扫码入网,同时兼容 Tailscale 与 Headscale。' + }, + { + t: 'WhoIs 验身 + 6 位核对码', + d: '基于 WireGuard 真实隧道身份校验,终端与网页核对同一 6 位短码后一键批准,绝不静默建档。' + }, + { + t: '可选 Tailscale SSH 推送', + d: '默认关闭防横向移动;开启后严格校验 sshHostKeys、日志脱敏注册码,失败或取消自动吊销注册码。' + }, + { + t: '裸机二合一与 iOS 直连', + d: '经 OAuth 或 Headscale 签发 10 分钟一次性入网密钥,配合私网 HTTPS Serve 实现 iPhone 扫码直连。' + } + ], + link: { + label: 'Tailscale 图文教程', + href: docsUrl('zh', 'tailscale') + } + }, dash: { h2: '监控墙,按你的习惯摆。', lede: '18 种内置组件,在 12 列网格里拖拽、缩放和锁定。日常总览、三网线路页、按地区或项目拆开的看板,随你建几张。', @@ -699,6 +846,10 @@ const en: LandingCopy = { label: 'Security', href: '#security' }, + { + label: 'Tailscale', + href: '#tailscale' + }, { label: 'iOS', href: '#ios' @@ -829,6 +980,98 @@ const en: LandingCopy = { href: docsUrl('en', 'capabilities') } }, + tailscale: { + h2: 'On the same tailnet, servers find you.', + lede: 'Sign your server and hosts into the same Tailscale or Headscale tailnet. Discover peers with zero API keys, approve knocking agents by verification code, deploy over Tailscale SSH, or bootstrap bare-metal hosts in one command.', + stage: { + modeLabel: 'Interactive Tailscale onboarding demo', + modes: { + knock: 'Auto-knock inbox', + ssh: 'Tailscale SSH deploy', + baremetal: 'Bare-metal & iOS QR' + }, + knock: { + hostLabel: 'Target VPS · 100.64.0.2', + inboxLabel: 'ServerBee inbox · 100.64.0.1', + inboxBadge: '1 pending', + whoisBadge: 'WhoIs verified', + sasLabel: 'SAS code', + pending: 'Waiting for code check and approval', + approve: 'Approve & connect', + approved: 'Admitted and online', + online: 'Online', + metricsLabel: 'Live telemetry', + replay: 'Replay', + pipeKnocking: 'WireGuard knock', + pipeWhois: 'WhoIs + SAS', + pipeApproved: 'WSS live', + terminalSteps: [ + 'Found serverbee.ts.net via local tailscaled', + 'Staged run_token locally (0600)', + 'Knocked over WireGuard, awaiting approval...' + ] + }, + ssh: { + serverLabel: 'ServerBee panel', + terminalLabel: 'Live SSE terminal · 100.64.0.3:22', + optIn: 'Off by default · Admin opt-in', + hostKeys: 'Pinned 3 sshHostKeys', + ready: 'SSH ready', + deploy: 'Deploy over SSH', + deploying: 'Deploying...', + deployed: 'Online with zero shell steps', + replay: 'Replay', + pipeHostKey: 'sshHostKeys ok', + pipeInstall: 'Installing', + pipeOnline: 'WSS live', + terminalLines: [ + '[1/4] Host key matched Peer.sshHostKeys (ed25519)', + '[2/4] Downloading installer to mktemp...', + '[3/4] Installing with code [REDACTED] & starting agent', + '[4/4] Offer claimed, live in 4.1s' + ] + }, + baremetal: { + hostLabel: 'Fresh host · No Tailscale yet', + iosLabel: 'iOS companion · Tailnet QR pair', + action: 'Run 2-in-1 script', + running: 'Bootstrapping...', + replay: 'Replay', + pipeLabel: 'Private HTTPS', + urlLabel: 'serverbee.fox-koi.ts.net', + atsBadge: 'Let’s Encrypt · ATS ready', + iosWaiting: 'Turn on Tailscale & scan to pair', + iosPaired: 'Paired over private tailnet', + stages: [ + 'Install Tailscale & join via one-time auth key', + 'Install agent & finish enrollment', + 'Encrypted WebSocket online' + ] + } + }, + points: [ + { + t: 'Zero-key peer discovery', + d: 'Reads peers straight from tailscaled.sock with built-in web QR login, supporting both Tailscale and Headscale.' + }, + { + t: 'WhoIs identity + 6-char SAS', + d: 'Verifies WireGuard tunnel identity locally and pairs terminal and web UI with a matching code, never enrolling silently.' + }, + { + t: 'Opt-in Tailscale SSH deploy', + d: 'Disabled by default. Pins sshHostKeys, redacts enrollment codes in SSE logs, and revokes offers on cancel or failure.' + }, + { + t: 'Bare-metal 2-in-1 & iOS QR', + d: 'Mints 10-minute single-use auth keys via OAuth or Headscale, publishes private HTTPS Serve, and pairs iOS with zero public ports.' + } + ], + link: { + label: 'Tailscale guide', + href: docsUrl('en', 'tailscale') + } + }, dash: { h2: 'Lay out the screen you actually watch.', lede: 'Drag, resize and lock 18 built-in widgets on a 12-column grid, and save as many views as you need: a daily overview, a network board, or separate pages by region and project.', diff --git a/apps/landing/src/lib/site.ts b/apps/landing/src/lib/site.ts index 94813b45..472e4177 100644 --- a/apps/landing/src/lib/site.ts +++ b/apps/landing/src/lib/site.ts @@ -23,12 +23,11 @@ export const installCommands = { agent: `${INSTALLER} | sudo bash -s -- agent --server-url 'https://panel.example.com' --enrollment-code ''` } as const -export type FeatureKey = 'dash' | 'ios' | 'ipq' | 'network' | 'security' +export type FeatureKey = 'dash' | 'ios' | 'ipq' | 'network' | 'security' | 'tailscale' -/** Feature sections in page order: Chinese readers come for network quality, English readers for dashboards. */ export const featureOrder: Record = { - en: ['dash', 'network', 'ipq', 'security', 'ios'], - zh: ['network', 'ipq', 'security', 'dash', 'ios'] + en: ['dash', 'network', 'ipq', 'security', 'tailscale', 'ios'], + zh: ['network', 'ipq', 'security', 'tailscale', 'dash', 'ios'] } /** Documentation pages the landing links to. scripts/check-contracts.ts requires each one in both locales. */ diff --git a/apps/landing/src/scripts/motion/index.ts b/apps/landing/src/scripts/motion/index.ts index 72fe7301..c7cd3a7c 100644 --- a/apps/landing/src/scripts/motion/index.ts +++ b/apps/landing/src/scripts/motion/index.ts @@ -14,11 +14,13 @@ import { mountPush } from './push' import { mountRail } from './rail' import { mountReveal } from './reveal' import { reduced } from './stage' +import { mountTailscale } from './tailscale' export function mountMotion(): void { // These two also have a settled form: the routes drawn, and a rail that follows the scroll. mountHero() mountRail() + mountTailscale() if (reduced) { return } diff --git a/apps/landing/src/scripts/motion/tailscale.ts b/apps/landing/src/scripts/motion/tailscale.ts new file mode 100644 index 00000000..1fb5131c --- /dev/null +++ b/apps/landing/src/scripts/motion/tailscale.ts @@ -0,0 +1,468 @@ +import { onArrival, reduced, sleep } from './stage' + +type Mode = 'baremetal' | 'knock' | 'ssh' + +const KNOCK_CMD = 'install.sh agent --tailscale' + +export function mountTailscale(): void { + const stage = document.querySelector('tailscale-stage') + if (!stage) { + return + } + + const tablist = stage.querySelector('[role="tablist"]') + const tabs = [...stage.querySelectorAll('[data-ts-tab]')] + const panels = [...stage.querySelectorAll('[data-ts-panel]')] + const replayBtn = stage.querySelector('[data-ts-replay]') + + const cmdEl = stage.querySelector('[data-ts-cmd]') + const knockSteps = [...stage.querySelectorAll('[data-ts-step]')] + const sasBox = stage.querySelector('[data-ts-sas]') + const inboxCard = stage.querySelector('[data-ts-inbox]') + const inboxBadge = stage.querySelector('[data-ts-inbox-badge]') + const knockPipe = stage.querySelector('[data-ts-knock-pipe]') + const knockPipeText = stage.querySelector('[data-ts-knock-pipe-text]') + const knockStatus = stage.querySelector('[data-ts-knock-status]') + const approveBtn = stage.querySelector('[data-ts-approve]') + const approveLabel = stage.querySelector('[data-ts-approve-label]') + const cpuEl = stage.querySelector('[data-ts-cpu]') + const memEl = stage.querySelector('[data-ts-mem]') + const rttEl = stage.querySelector('[data-ts-rtt]') + + const deployBtn = stage.querySelector('[data-ts-deploy]') + const deployLabel = stage.querySelector('[data-ts-deploy-label]') + const sshStatus = stage.querySelector('[data-ts-ssh-status]') + const sshPipe = stage.querySelector('[data-ts-ssh-pipe]') + const sshPipeText = stage.querySelector('[data-ts-ssh-pipe-text]') + const sshLines = [...stage.querySelectorAll('[data-ts-ssh-line]')] + + const bmBtn = stage.querySelector('[data-ts-bm-run]') + const bmLabel = stage.querySelector('[data-ts-bm-label]') + const bmSteps = [...stage.querySelectorAll('[data-ts-bm-step]')] + const iosCard = stage.querySelector('[data-ts-ios-card]') + const iosStatus = stage.querySelector('[data-ts-ios-status]') + + let activeMode: Mode = 'knock' + let runToken = 0 + let metricsTimer: number | undefined + let knockApproved = false + + const stopMetrics = (): void => { + if (metricsTimer !== undefined) { + window.clearInterval(metricsTimer) + metricsTimer = undefined + } + } + + const startMetrics = (): void => { + stopMetrics() + if (reduced) { + return + } + const cpuSamples = ['14%', '17%', '12%', '19%', '15%'] + const memSamples = ['42%', '42%', '43%', '42%', '41%'] + const rttSamples = ['1.8 ms', '1.6 ms', '2.1 ms', '1.7 ms', '1.9 ms'] + let tick = 0 + metricsTimer = window.setInterval(() => { + tick = (tick + 1) % cpuSamples.length + if (cpuEl) { + cpuEl.textContent = cpuSamples[tick] + } + if (memEl) { + memEl.textContent = memSamples[tick] + } + if (rttEl) { + rttEl.textContent = rttSamples[tick] + } + }, 1800) + } + + const pill = document.createElement('span') + pill.className = 'tab-pill' + pill.setAttribute('aria-hidden', 'true') + + const placePill = (): void => { + const selected = tabs.find((tab) => tab.getAttribute('aria-selected') === 'true') + if (!(selected && tablist)) { + return + } + const inset = pill.offsetLeft + const left = selected.offsetLeft - inset + pill.style.setProperty('--left', `${left}px`) + pill.style.setProperty('--right', `${pill.offsetWidth - left - selected.offsetWidth}px`) + } + + const resetKnock = (): void => { + stopMetrics() + knockApproved = false + stage.dataset.phase = 'idle' + if (cmdEl) { + cmdEl.textContent = reduced ? KNOCK_CMD : '\u00A0' + } + if (cpuEl) { + cpuEl.textContent = '—' + } + if (memEl) { + memEl.textContent = '—' + } + if (rttEl) { + rttEl.textContent = '—' + } + for (const step of knockSteps) { + step.toggleAttribute('data-on', reduced) + step.removeAttribute('data-done') + } + sasBox?.toggleAttribute('data-on', reduced) + inboxCard?.toggleAttribute('data-arrived', reduced) + inboxCard?.removeAttribute('data-online') + if (inboxBadge) { + inboxBadge.textContent = inboxBadge.dataset.pending ?? '' + inboxBadge.classList.remove('ts-badge-ok') + inboxBadge.classList.add('ts-badge-warn') + } + if (knockPipeText && knockPipe) { + knockPipeText.textContent = knockPipe.dataset.whois ?? '' + } + if (knockStatus) { + knockStatus.textContent = knockStatus.dataset.pending ?? '' + } + if (approveBtn && approveLabel) { + approveBtn.disabled = false + approveBtn.removeAttribute('data-complete') + approveLabel.textContent = approveBtn.dataset.idle ?? '' + } + } + + const applyKnockApproved = (): void => { + knockApproved = true + stage.dataset.phase = 'online' + for (const step of knockSteps) { + step.setAttribute('data-on', '') + step.setAttribute('data-done', '') + } + sasBox?.setAttribute('data-on', '') + inboxCard?.setAttribute('data-arrived', '') + inboxCard?.setAttribute('data-online', '') + if (inboxBadge) { + inboxBadge.textContent = inboxBadge.dataset.online ?? '' + inboxBadge.classList.remove('ts-badge-warn') + inboxBadge.classList.add('ts-badge-ok') + } + if (knockPipeText && knockPipe) { + knockPipeText.textContent = knockPipe.dataset.approved ?? '' + } + if (knockStatus) { + knockStatus.textContent = knockStatus.dataset.approved ?? '' + } + if (approveBtn && approveLabel) { + approveBtn.disabled = true + approveBtn.setAttribute('data-complete', '') + approveLabel.textContent = approveBtn.dataset.done ?? '' + } + if (cpuEl) { + cpuEl.textContent = cpuEl.dataset.live ?? '14%' + } + if (memEl) { + memEl.textContent = memEl.dataset.live ?? '42%' + } + if (rttEl) { + rttEl.textContent = rttEl.dataset.live ?? '1.8 ms' + } + startMetrics() + } + + const playKnock = async (token: number, autoApprove: boolean): Promise => { + resetKnock() + if (reduced) { + return + } + stage.dataset.phase = 'active' + if (knockPipeText && knockPipe) { + knockPipeText.textContent = knockPipe.dataset.knocking ?? '' + } + if (cmdEl) { + for (let i = 1; i <= KNOCK_CMD.length; i += 1) { + if (token !== runToken) { + return + } + cmdEl.textContent = KNOCK_CMD.slice(0, i) + await sleep(22) + } + } + await sleep(220) + for (const step of knockSteps) { + if (token !== runToken) { + return + } + step.setAttribute('data-on', '') + await sleep(340) + step.setAttribute('data-done', '') + } + if (token !== runToken) { + return + } + sasBox?.setAttribute('data-on', '') + if (knockPipeText && knockPipe) { + knockPipeText.textContent = knockPipe.dataset.whois ?? '' + } + await sleep(260) + if (token !== runToken) { + return + } + inboxCard?.setAttribute('data-arrived', '') + stage.dataset.phase = 'ready' + if (autoApprove) { + await sleep(2200) + if (token !== runToken || knockApproved) { + return + } + applyKnockApproved() + } + } + + const resetSsh = (): void => { + stopMetrics() + stage.dataset.phase = 'idle' + for (const line of sshLines) { + line.toggleAttribute('data-on', reduced) + } + if (sshPipeText && sshPipe) { + sshPipeText.textContent = sshPipe.dataset.hostkey ?? '' + } + if (sshStatus) { + sshStatus.textContent = sshStatus.dataset.idle ?? '' + } + if (deployBtn && deployLabel) { + deployBtn.disabled = false + deployBtn.removeAttribute('data-complete') + deployLabel.textContent = deployBtn.dataset.idle ?? '' + } + } + + const playSsh = async (token: number): Promise => { + resetSsh() + if (reduced) { + stage.dataset.phase = 'online' + if (sshStatus) { + sshStatus.textContent = sshStatus.dataset.done ?? '' + } + if (sshPipeText && sshPipe) { + sshPipeText.textContent = sshPipe.dataset.online ?? '' + } + if (deployBtn && deployLabel) { + deployBtn.setAttribute('data-complete', '') + deployLabel.textContent = deployBtn.dataset.done ?? '' + } + return + } + stage.dataset.phase = 'active' + if (deployBtn && deployLabel) { + deployBtn.disabled = true + deployLabel.textContent = deployBtn.dataset.busy ?? '' + } + if (sshStatus) { + sshStatus.textContent = sshStatus.dataset.deploying ?? '' + } + for (const [index, line] of sshLines.entries()) { + if (token !== runToken) { + return + } + if (index === 1 && sshPipeText && sshPipe) { + sshPipeText.textContent = sshPipe.dataset.install ?? '' + } + await sleep(index === 0 ? 280 : 520) + if (token !== runToken) { + return + } + line.setAttribute('data-on', '') + } + if (token !== runToken) { + return + } + stage.dataset.phase = 'online' + if (sshPipeText && sshPipe) { + sshPipeText.textContent = sshPipe.dataset.online ?? '' + } + if (sshStatus) { + sshStatus.textContent = sshStatus.dataset.done ?? '' + } + if (deployBtn && deployLabel) { + deployBtn.disabled = false + deployBtn.setAttribute('data-complete', '') + deployLabel.textContent = deployBtn.dataset.done ?? '' + } + } + + const resetBaremetal = (): void => { + stopMetrics() + stage.dataset.phase = 'idle' + for (const step of bmSteps) { + step.toggleAttribute('data-on', reduced) + step.toggleAttribute('data-done', reduced) + } + iosCard?.toggleAttribute('data-paired', reduced) + if (iosStatus) { + iosStatus.textContent = reduced ? (iosStatus.dataset.paired ?? '') : (iosStatus.dataset.waiting ?? '') + } + if (bmBtn && bmLabel) { + bmBtn.disabled = false + bmBtn.toggleAttribute('data-complete', reduced) + bmLabel.textContent = reduced ? (bmBtn.dataset.done ?? '') : (bmBtn.dataset.idle ?? '') + } + } + + const playBaremetal = async (token: number): Promise => { + resetBaremetal() + if (reduced) { + stage.dataset.phase = 'online' + return + } + stage.dataset.phase = 'active' + if (bmBtn && bmLabel) { + bmBtn.disabled = true + bmLabel.textContent = bmBtn.dataset.busy ?? '' + } + for (const step of bmSteps) { + if (token !== runToken) { + return + } + step.setAttribute('data-on', '') + await sleep(560) + if (token !== runToken) { + return + } + step.setAttribute('data-done', '') + } + if (token !== runToken) { + return + } + stage.dataset.phase = 'online' + iosCard?.setAttribute('data-paired', '') + if (iosStatus) { + iosStatus.textContent = iosStatus.dataset.paired ?? '' + } + if (bmBtn && bmLabel) { + bmBtn.disabled = false + bmBtn.setAttribute('data-complete', '') + bmLabel.textContent = bmBtn.dataset.done ?? '' + } + } + + const runCurrentMode = (autoApprove: boolean): void => { + runToken += 1 + const token = runToken + if (activeMode === 'knock') { + void playKnock(token, autoApprove) + } else if (activeMode === 'ssh') { + void playSsh(token) + } else { + void playBaremetal(token) + } + } + + const selectMode = (mode: Mode, focus: boolean): void => { + if (mode === activeMode) { + if (focus) { + tabs.find((tab) => tab.dataset.tsTab === mode)?.focus() + } + return + } + runToken += 1 + const token = runToken + activeMode = mode + stage.dataset.mode = mode + stage.dataset.switched = '' + if (mode === 'knock') { + resetKnock() + } else if (mode === 'ssh') { + resetSsh() + } else { + resetBaremetal() + } + for (const tab of tabs) { + const selected = tab.dataset.tsTab === mode + tab.setAttribute('aria-selected', String(selected)) + tab.tabIndex = selected ? 0 : -1 + if (selected && focus) { + tab.focus() + } + } + for (const panel of panels) { + const isActive = panel.dataset.tsPanel === mode + panel.toggleAttribute('data-active', isActive) + panel.setAttribute('aria-hidden', String(!isActive)) + panel.inert = !isActive + } + placePill() + if (mode === 'knock') { + void playKnock(token, false) + } else if (mode === 'ssh') { + void playSsh(token) + } else { + void playBaremetal(token) + } + } + + const keys: Record number> = { + ArrowLeft: (index) => (index - 1 + tabs.length) % tabs.length, + ArrowRight: (index) => (index + 1) % tabs.length, + End: () => tabs.length - 1, + Home: () => 0 + } + + for (const [index, tab] of tabs.entries()) { + tab.addEventListener('click', () => { + const mode = tab.dataset.tsTab as Mode | undefined + if (mode) { + selectMode(mode, false) + } + }) + tab.addEventListener('keydown', (event) => { + const move = keys[event.key] + if (!move) { + return + } + event.preventDefault() + const next = tabs[move(index)] + const mode = next?.dataset.tsTab as Mode | undefined + if (mode) { + selectMode(mode, true) + } + }) + } + + approveBtn?.addEventListener('click', () => { + runToken += 1 + applyKnockApproved() + }) + + deployBtn?.addEventListener('click', () => { + runToken += 1 + void playSsh(runToken) + }) + + bmBtn?.addEventListener('click', () => { + runToken += 1 + void playBaremetal(runToken) + }) + + replayBtn?.addEventListener('click', () => { + runCurrentMode(false) + }) + + if (tablist) { + tablist.prepend(pill) + tablist.dataset.pill = '' + placePill() + addEventListener('resize', placePill) + document.fonts.ready.then(placePill) + requestAnimationFrame(() => requestAnimationFrame(() => pill.setAttribute('data-ready', ''))) + } + + resetKnock() + if (!reduced) { + onArrival(stage, 0.35, () => { + runCurrentMode(true) + }) + } +} diff --git a/apps/landing/src/styles/global.css b/apps/landing/src/styles/global.css index 2d97b87a..6ecda78c 100644 --- a/apps/landing/src/styles/global.css +++ b/apps/landing/src/styles/global.css @@ -2140,7 +2140,9 @@ section[id] { .tool, .copy, .header .btn, - .install-tabs button { + .install-tabs button, + .ts-tabs button, + .ts-action { height: 44px; } @@ -2182,6 +2184,632 @@ section[id] { } } +.ts-stage { + display: block; + margin-top: clamp(28px, 3.6vw, 44px); +} + +.ts-bar { + display: flex; + flex-wrap: wrap; + gap: 12px; + align-items: center; + justify-content: space-between; + margin-bottom: 16px; +} + +.ts-tabs { + position: relative; + display: inline-flex; + flex-wrap: wrap; + gap: 2px; + padding: 3px; + background: var(--sunken); + border: 1px solid var(--line); + border-radius: var(--r-m); +} + +.ts-tabs button { + position: relative; + z-index: 1; + height: 34px; + padding: 0 14px; + font-size: 0.875rem; + font-weight: 600; + color: var(--ink-2); + cursor: pointer; + background: none; + border: 0; + border-radius: 7px; + -webkit-tap-highlight-color: transparent; + transition: color 0.15s; +} + +.ts-tabs button[aria-selected="true"] { + color: var(--ink); +} + +.ts-tabs .tab-pill { + background: var(--surface); + box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); +} + +.ts-replay { + display: inline-flex; + gap: 6px; + align-items: center; + height: 34px; + padding: 0 12px; + font-size: 0.8125rem; + font-weight: 600; + color: var(--ink-2); + cursor: pointer; + background: var(--surface); + border: 1px solid var(--line); + border-radius: 8px; + transition: + color 0.15s, + border-color 0.15s; +} + +.ts-replay svg { + width: 14px; + height: 14px; +} + +@media (hover: hover) { + .ts-tabs button:hover { + color: var(--ink); + } + + .ts-replay:hover { + color: var(--ink); + border-color: var(--line-strong); + } +} + +.ts-panels { + display: grid; + padding: clamp(16px, 2.2vw, 24px); + background: var(--sunken); + border: 1px solid var(--line); + border-radius: var(--r-l); +} + +.ts-panel { + grid-area: 1 / 1; + display: flex; + flex-direction: column; + pointer-events: none; + visibility: hidden; + opacity: 0; +} + +.ts-panel[data-active] { + z-index: 1; + pointer-events: auto; + visibility: visible; + opacity: 1; +} + +.ts-grid { + display: grid; + flex: 1; + grid-template-columns: minmax(0, 1.05fr) 156px minmax(0, 1.05fr); + gap: 0; + align-items: stretch; +} + +.ts-term, +.ts-card { + display: flex; + flex-direction: column; + gap: 14px; + min-width: 0; + padding: 18px 20px; + border-radius: var(--r-m); +} + +.ts-term { + color: var(--cmd-ink); + background: var(--cmd-bg); + border: 1px solid var(--cmd-line); +} + +.ts-card { + background: var(--surface); + border: 1px solid var(--line); +} + +.ts-pane-head { + display: flex; + flex-wrap: nowrap; + gap: 8px; + align-items: center; + justify-content: space-between; +} + +.ts-pane-title { + display: inline-flex; + gap: 7px; + align-items: center; + min-width: 0; + overflow: hidden; + font-family: var(--font-mono); + font-size: 0.75rem; + font-weight: 600; + color: inherit; + text-overflow: ellipsis; + white-space: nowrap; +} + +.ts-pane-head .ts-badge, +.ts-pane-head .ts-pill-mono { + flex: none; + white-space: nowrap; +} + +.ts-term .ts-pane-title { + color: var(--cmd-dim); +} + +.ts-card .ts-pane-title { + color: var(--ink-2); +} + +.ts-pane-title svg { + width: 14px; + height: 14px; +} + +.ts-pill-mono { + padding: 2px 8px; + font-family: var(--font-mono); + font-size: 0.71875rem; + color: var(--ink-2); + background: var(--sunken); + border: 1px solid var(--line); + border-radius: 999px; +} + +.ts-term .ts-pill-mono { + color: var(--cmd-dim); + background: rgb(255 255 255 / 0.05); + border-color: var(--cmd-line); +} + +.ts-cmd { + min-height: 44px; + padding: 10px 12px; + margin: 0; + overflow-wrap: anywhere; + font-family: var(--font-mono); + font-size: 0.78125rem; + line-height: 1.5; + color: var(--cmd-ink); + white-space: pre-wrap; + background: rgb(255 255 255 / 0.04); + border: 1px solid var(--cmd-line); + border-radius: 8px; +} + +.ts-steps, +.ts-stream, +.ts-pipeline { + display: grid; + gap: 8px; + padding: 0; + margin: 0; + font-family: var(--font-mono); + font-size: 0.75rem; + line-height: 1.55; + list-style: none; +} + +.ts-steps li, +.ts-pipeline li { + display: flex; + gap: 9px; + align-items: baseline; + color: var(--cmd-dim); +} + +.ts-steps li[data-on], +.ts-pipeline li[data-on] { + color: var(--cmd-ink); +} + +.ts-dot, +.ts-bm-dot { + flex: none; + width: 7px; + height: 7px; + background: var(--cmd-dim); + border-radius: 50%; + translate: 0 -1px; +} + +.ts-steps li[data-on] .ts-dot, +.ts-pipeline li[data-on] .ts-bm-dot { + background: var(--accent); +} + +.ts-steps li[data-done] .ts-dot, +.ts-pipeline li[data-done] .ts-bm-dot { + background: var(--ok); +} + +.ts-stream li { + padding: 6px 10px; + color: var(--cmd-ink); + background: rgb(255 255 255 / 0.03); + border-left: 2px solid var(--cmd-accent); + border-radius: 0 6px 6px 0; +} + +.ts-sas-banner { + display: flex; + gap: 12px; + align-items: center; + justify-content: space-between; + padding: 10px 14px; + margin-top: auto; + background: color-mix(in oklab, var(--accent) 16%, transparent); + border: 1px solid color-mix(in oklab, var(--accent) 45%, transparent); + border-radius: 8px; +} + +.ts-sas-label { + font-size: 0.75rem; + color: var(--cmd-dim); +} + +.ts-sas-code { + font-family: var(--font-mono); + font-size: 1rem; + font-weight: 700; + color: var(--cmd-ink); + letter-spacing: 0.1em; +} + +.ts-bridge { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 0 6px; +} + +.ts-wire { + position: relative; + width: 100%; + height: 2px; +} + +.ts-wire-line { + position: absolute; + inset: 0; + background: var(--line-strong); +} + +.ts-wire-packet { + position: absolute; + top: -1px; + left: 0; + width: 24px; + height: 4px; + background: var(--accent); + border-radius: 999px; + opacity: 0; +} + +.ts-stage[data-phase="online"] .ts-wire-line { + background: var(--ok); +} + +.ts-stage[data-phase="online"] .ts-wire-packet { + background: var(--ok); +} + +.ts-bridge-badge { + position: relative; + z-index: 1; + display: inline-flex; + gap: 5px; + align-items: center; + padding: 4px 10px; + margin-top: 12px; + font-family: var(--font-mono); + font-size: 0.6875rem; + color: var(--ink-2); + white-space: nowrap; + background: var(--surface); + border: 1px solid var(--line-strong); + border-radius: 999px; +} + +.ts-bridge-badge svg { + width: 11px; + height: 11px; + color: var(--accent-text); +} + +.ts-stage[data-phase="online"] .ts-bridge-badge { + color: var(--ok); + border-color: color-mix(in oklab, var(--ok) 45%, transparent); +} + +.ts-stage[data-phase="online"] .ts-bridge-badge svg { + color: var(--ok); +} + +.ts-badge { + display: inline-flex; + align-items: center; + padding: 2px 9px; + font-family: var(--font-mono); + font-size: 0.71875rem; + font-weight: 600; + border-radius: 999px; +} + +.ts-badge-ok { + color: var(--ok); + background: color-mix(in oklab, var(--ok) 14%, transparent); +} + +.ts-badge-warn { + color: var(--warn); + background: color-mix(in oklab, var(--warn) 14%, transparent); +} + +.ts-badge-muted { + color: var(--ink-2); + background: var(--sunken); + border: 1px solid var(--line); +} + +.ts-node-box { + display: flex; + flex: 1; + flex-direction: column; + gap: 14px; +} + +.ts-node-row { + display: flex; + flex-wrap: wrap; + gap: 10px; + align-items: flex-start; + justify-content: space-between; +} + +.ts-node-meta { + display: grid; + gap: 2px; +} + +.ts-node-meta b { + font-family: var(--font-mono); + font-size: 0.9375rem; + color: var(--ink); +} + +.ts-node-meta span { + font-family: var(--font-mono); + font-size: 0.75rem; + color: var(--ink-3); +} + +.ts-verify-row { + display: flex; + gap: 10px; + align-items: center; + justify-content: space-between; + padding: 10px 12px; + background: var(--sunken); + border: 1px solid var(--line); + border-radius: 8px; +} + +.ts-verify-label { + font-size: 0.8125rem; + color: var(--ink-2); +} + +.ts-sas-chip { + padding: 2px 10px; + font-family: var(--font-mono); + font-size: 0.9375rem; + font-weight: 700; + color: var(--accent-text); + letter-spacing: 0.08em; + background: var(--accent-soft); + border-radius: 6px; +} + +.ts-metrics { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 8px; + opacity: 0.45; + transition: opacity 260ms ease; +} + +.ts-card[data-online] .ts-metrics { + opacity: 1; +} + +.ts-metrics > div { + display: grid; + gap: 2px; + padding: 8px 10px; + background: var(--sunken); + border: 1px solid var(--line); + border-radius: 8px; +} + +.ts-metrics span { + font-family: var(--font-mono); + font-size: 0.6875rem; + color: var(--ink-3); +} + +.ts-metrics b { + font-family: var(--font-mono); + font-size: 0.875rem; + font-variant-numeric: tabular-nums; + color: var(--ink); +} + +.ts-card-foot, +.ts-term-foot { + display: flex; + flex-wrap: wrap; + gap: 10px; + align-items: center; + justify-content: space-between; + margin-top: auto; +} + +.ts-status-text { + font-size: 0.8125rem; + color: var(--ink-2); +} + +.ts-card[data-online] .ts-status-text { + color: var(--ok); +} + +.ts-action { + display: inline-flex; + gap: 6px; + align-items: center; + height: 36px; + padding: 0 14px; + font-size: 0.8125rem; + font-weight: 600; + color: #fff; + cursor: pointer; + background: var(--accent); + border: 0; + border-radius: 8px; + transition: + opacity 0.15s, + background-color 0.2s, + transform 0.12s var(--ease-out); +} + +.ts-action svg { + width: 14px; + height: 14px; +} + +.ts-action[data-complete] { + background: var(--ok); +} + +.ts-action:disabled { + cursor: default; + opacity: 0.88; +} + +@media (hover: hover) { + .ts-action:not(:disabled):hover { + opacity: 0.92; + } +} + +.ts-action:not(:disabled):active { + transform: scale(0.97); +} + +.ts-qr-wrap { + display: flex; + flex: 1; + gap: 18px; + align-items: center; + padding: 12px 14px; + background: var(--sunken); + border: 1px solid var(--line); + border-radius: 10px; +} + +.ts-qr { + display: grid; + flex: none; + grid-template-columns: repeat(13, 6px); + gap: 1px; + padding: 8px; + background: #fff; + border-radius: 8px; +} + +.ts-qr i { + display: block; + width: 6px; + height: 6px; + background: transparent; + border-radius: 1px; +} + +.ts-qr i.on { + background: #111318; +} + +.ts-qr-info { + display: grid; + gap: 6px; + min-width: 0; +} + +.ts-qr-url { + overflow-wrap: anywhere; + font-family: var(--font-mono); + font-size: 0.8125rem; + color: var(--ink); +} + +.ts-qr-state { + margin: 0; + font-size: 0.8125rem; + color: var(--ink-2); +} + +.ts-card[data-paired] .ts-qr-state { + font-weight: 600; + color: var(--ok); +} + +@media (max-width: 960px) { + .ts-grid { + grid-template-columns: minmax(0, 1fr); + gap: 14px; + } + + .ts-bridge { + flex-direction: row; + gap: 12px; + padding: 4px 0; + } + + .ts-wire { + flex: 1; + } + + .ts-bridge-badge { + margin-top: 0; + } +} + +@media (max-width: 560px) { + .ts-card-foot { + flex-direction: column; + align-items: flex-start; + } +} + /* ---------- Not found ---------- */ .lost { diff --git a/apps/landing/src/styles/motion.css b/apps/landing/src/styles/motion.css index ab64a38f..ca89947f 100644 --- a/apps/landing/src/styles/motion.css +++ b/apps/landing/src/styles/motion.css @@ -1133,6 +1133,82 @@ --after: 650ms; } +.ts-steps li, +.ts-stream li, +.ts-pipeline li, +.ts-sas-banner { + opacity: 0; + transform: translateY(6px); + transition: + opacity 320ms var(--ease-out), + transform 320ms var(--ease-out); +} + +.ts-steps li[data-on], +.ts-stream li[data-on], +.ts-pipeline li[data-on], +.ts-sas-banner[data-on] { + opacity: 1; + transform: none; +} + +.ts-card[data-ts-inbox] { + transition: + border-color 320ms ease, + box-shadow 320ms ease; +} + +.ts-card[data-ts-inbox][data-arrived]:not([data-online]) { + border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); + box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 12%, transparent); +} + +.ts-card[data-ts-inbox][data-online], +.ts-card[data-ts-ios-card][data-paired] { + border-color: color-mix(in oklab, var(--ok) 55%, var(--line)); + box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok) 12%, transparent); +} + +@media (prefers-reduced-motion: no-preference) { + .ts-stage[data-phase="active"] .ts-wire-packet, + .ts-stage[data-phase="ready"] .ts-wire-packet, + .ts-stage[data-phase="online"] .ts-wire-packet { + animation: ts-packet 1800ms linear infinite; + } + + .ts-stage[data-phase="online"] .ts-wire-packet { + animation-duration: 2400ms; + } +} + +@media (prefers-reduced-motion: reduce) { + .ts-steps li, + .ts-stream li, + .ts-pipeline li, + .ts-sas-banner { + opacity: 1; + transform: none; + transition: none; + } +} + +@keyframes ts-packet { + from { + opacity: 0; + transform: translateX(0); + } + + 12%, + 88% { + opacity: 1; + } + + to { + opacity: 0; + transform: translateX(120px); + } +} + /* The empty sketch. */ .sketch[data-empty] .sk-days i, .sketch[data-empty] .sk-chip, From 23c65f0488b2ea6cc0b49a0fc330033ec927d736 Mon Sep 17 00:00:00 2001 From: ZingerLittleBee <6970999@gmail.com> Date: Fri, 4 Dec 2026 21:28:15 +0800 Subject: [PATCH 2/2] fix(landing): resolve biome complexity, specificity, and formatting checks --- .../src/components/sections/tailscale.astro | 56 +-- apps/landing/src/i18n/copy.ts | 4 +- apps/landing/src/scripts/motion/tailscale.ts | 355 ++++++++---------- apps/landing/src/styles/global.css | 32 +- 4 files changed, 195 insertions(+), 252 deletions(-) diff --git a/apps/landing/src/components/sections/tailscale.astro b/apps/landing/src/components/sections/tailscale.astro index 1e6daa1d..2866817b 100644 --- a/apps/landing/src/components/sections/tailscale.astro +++ b/apps/landing/src/components/sections/tailscale.astro @@ -21,20 +21,22 @@ const copy = landingCopy[lang].tailscale const { stage } = copy const modes: TailscaleMode[] = ['knock', 'ssh', 'baremetal'] const qrCells = [ - 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, - 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, - 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, - 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, - 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, - 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, - 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, - 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 + '1111101011111', + '1000100110001', + '1010101010101', + '1000101110001', + '1111100111111', + '0000001000000', + '1011011101011', + '0100100110100', + '1111101011011', + '1000101100101', + '1010100111010', + '1000101001101', + '1111101110111' ] + .join('') + .split('') --- @@ -135,8 +137,8 @@ const qrCells = [ - prod-web-01 - 100.64.0.2 · ubuntu · alice@tailnet + prod-web-01 + 100.64.0.2 · ubuntu · alice@tailnet {stage.knock.whoisBadge} @@ -145,17 +147,17 @@ const qrCells = [ Z1T-T1D - - CPU - — + + CPU + — - - MEM - — + + MEM + — - - RTT - — + + RTT + — @@ -201,8 +203,8 @@ const qrCells = [ - ssh-node-01 - 100.64.0.3 · linux · root@100.64.0.3:22 + ssh-node-01 + 100.64.0.3 · linux · root@100.64.0.3:22 {stage.ssh.ready} @@ -329,7 +331,7 @@ const qrCells = [ - {qrCells.map((cell) => )} + {qrCells.map((cell) => )} https://{stage.baremetal.urlLabel} diff --git a/apps/landing/src/i18n/copy.ts b/apps/landing/src/i18n/copy.ts index 4e1dda38..9f5d74b0 100644 --- a/apps/landing/src/i18n/copy.ts +++ b/apps/landing/src/i18n/copy.ts @@ -104,8 +104,8 @@ interface TailscaleCopy extends FeatureCopy { modes: Record ssh: { deploy: string - deploying: string deployed: string + deploying: string hostKeys: string optIn: string pipeHostKey: string @@ -244,9 +244,9 @@ export interface LandingCopy { network: FeatureCopy scenes: ScenesCopy security: SecurityCopy - tailscale: TailscaleCopy /** Alternative text of the product captures. */ shots: Record + tailscale: TailscaleCopy } const zh: LandingCopy = { diff --git a/apps/landing/src/scripts/motion/tailscale.ts b/apps/landing/src/scripts/motion/tailscale.ts index 1fb5131c..479f50c7 100644 --- a/apps/landing/src/scripts/motion/tailscale.ts +++ b/apps/landing/src/scripts/motion/tailscale.ts @@ -3,6 +3,65 @@ import { onArrival, reduced, sleep } from './stage' type Mode = 'baremetal' | 'knock' | 'ssh' const KNOCK_CMD = 'install.sh agent --tailscale' +const CPU_SAMPLES = ['14%', '17%', '12%', '19%', '15%'] +const MEM_SAMPLES = ['42%', '42%', '43%', '42%', '41%'] +const RTT_SAMPLES = ['1.8 ms', '1.6 ms', '2.1 ms', '1.7 ms', '1.9 ms'] + +function setText(el: HTMLElement | null, value: string | undefined): void { + if (el) { + el.textContent = value ?? '' + } +} + +function setActionButton( + button: HTMLButtonElement | null, + label: HTMLElement | null, + text: string | undefined, + disabled: boolean, + complete: boolean +): void { + if (button) { + button.disabled = disabled + button.toggleAttribute('data-complete', complete) + } + setText(label, text) +} + +function toggleItems(items: HTMLElement[], on: boolean, done: boolean): void { + for (const item of items) { + item.toggleAttribute('data-on', on) + item.toggleAttribute('data-done', done) + } +} + +async function typeCommand(el: HTMLElement | null, command: string, alive: () => boolean): Promise { + if (!el) { + return true + } + for (let i = 1; i <= command.length; i += 1) { + if (!alive()) { + return false + } + el.textContent = command.slice(0, i) + await sleep(22) + } + return alive() +} + +async function advanceSteps(items: HTMLElement[], delayMs: number, alive: () => boolean): Promise { + for (const item of items) { + if (!alive()) { + return false + } + item.setAttribute('data-on', '') + await sleep(delayMs) + if (!alive()) { + return false + } + item.setAttribute('data-done', '') + } + return alive() +} export function mountTailscale(): void { const stage = document.querySelector('tailscale-stage') @@ -59,21 +118,12 @@ export function mountTailscale(): void { if (reduced) { return } - const cpuSamples = ['14%', '17%', '12%', '19%', '15%'] - const memSamples = ['42%', '42%', '43%', '42%', '41%'] - const rttSamples = ['1.8 ms', '1.6 ms', '2.1 ms', '1.7 ms', '1.9 ms'] let tick = 0 metricsTimer = window.setInterval(() => { - tick = (tick + 1) % cpuSamples.length - if (cpuEl) { - cpuEl.textContent = cpuSamples[tick] - } - if (memEl) { - memEl.textContent = memSamples[tick] - } - if (rttEl) { - rttEl.textContent = rttSamples[tick] - } + tick = (tick + 1) % CPU_SAMPLES.length + setText(cpuEl, CPU_SAMPLES[tick]) + setText(memEl, MEM_SAMPLES[tick]) + setText(rttEl, RTT_SAMPLES[tick]) }, 1800) } @@ -92,131 +142,78 @@ export function mountTailscale(): void { pill.style.setProperty('--right', `${pill.offsetWidth - left - selected.offsetWidth}px`) } + const setInboxBadge = (online: boolean): void => { + if (!inboxBadge) { + return + } + inboxBadge.textContent = online ? (inboxBadge.dataset.online ?? '') : (inboxBadge.dataset.pending ?? '') + inboxBadge.classList.toggle('ts-badge-ok', online) + inboxBadge.classList.toggle('ts-badge-warn', !online) + } + const resetKnock = (): void => { stopMetrics() knockApproved = false stage.dataset.phase = 'idle' - if (cmdEl) { - cmdEl.textContent = reduced ? KNOCK_CMD : '\u00A0' - } - if (cpuEl) { - cpuEl.textContent = '—' - } - if (memEl) { - memEl.textContent = '—' - } - if (rttEl) { - rttEl.textContent = '—' - } - for (const step of knockSteps) { - step.toggleAttribute('data-on', reduced) - step.removeAttribute('data-done') - } + setText(cmdEl, reduced ? KNOCK_CMD : '\u00A0') + setText(cpuEl, '—') + setText(memEl, '—') + setText(rttEl, '—') + toggleItems(knockSteps, reduced, false) sasBox?.toggleAttribute('data-on', reduced) inboxCard?.toggleAttribute('data-arrived', reduced) inboxCard?.removeAttribute('data-online') - if (inboxBadge) { - inboxBadge.textContent = inboxBadge.dataset.pending ?? '' - inboxBadge.classList.remove('ts-badge-ok') - inboxBadge.classList.add('ts-badge-warn') - } - if (knockPipeText && knockPipe) { - knockPipeText.textContent = knockPipe.dataset.whois ?? '' - } - if (knockStatus) { - knockStatus.textContent = knockStatus.dataset.pending ?? '' - } - if (approveBtn && approveLabel) { - approveBtn.disabled = false - approveBtn.removeAttribute('data-complete') - approveLabel.textContent = approveBtn.dataset.idle ?? '' - } + setInboxBadge(false) + setText(knockPipeText, knockPipe?.dataset.whois) + setText(knockStatus, knockStatus?.dataset.pending) + setActionButton(approveBtn, approveLabel, approveBtn?.dataset.idle, false, false) } const applyKnockApproved = (): void => { knockApproved = true stage.dataset.phase = 'online' - for (const step of knockSteps) { - step.setAttribute('data-on', '') - step.setAttribute('data-done', '') - } + toggleItems(knockSteps, true, true) sasBox?.setAttribute('data-on', '') inboxCard?.setAttribute('data-arrived', '') inboxCard?.setAttribute('data-online', '') - if (inboxBadge) { - inboxBadge.textContent = inboxBadge.dataset.online ?? '' - inboxBadge.classList.remove('ts-badge-warn') - inboxBadge.classList.add('ts-badge-ok') - } - if (knockPipeText && knockPipe) { - knockPipeText.textContent = knockPipe.dataset.approved ?? '' - } - if (knockStatus) { - knockStatus.textContent = knockStatus.dataset.approved ?? '' - } - if (approveBtn && approveLabel) { - approveBtn.disabled = true - approveBtn.setAttribute('data-complete', '') - approveLabel.textContent = approveBtn.dataset.done ?? '' - } - if (cpuEl) { - cpuEl.textContent = cpuEl.dataset.live ?? '14%' - } - if (memEl) { - memEl.textContent = memEl.dataset.live ?? '42%' - } - if (rttEl) { - rttEl.textContent = rttEl.dataset.live ?? '1.8 ms' - } + setInboxBadge(true) + setText(knockPipeText, knockPipe?.dataset.approved) + setText(knockStatus, knockStatus?.dataset.approved) + setActionButton(approveBtn, approveLabel, approveBtn?.dataset.done, true, true) + setText(cpuEl, cpuEl?.dataset.live ?? '14%') + setText(memEl, memEl?.dataset.live ?? '42%') + setText(rttEl, rttEl?.dataset.live ?? '1.8 ms') startMetrics() } const playKnock = async (token: number, autoApprove: boolean): Promise => { + const alive = (): boolean => token === runToken resetKnock() if (reduced) { return } stage.dataset.phase = 'active' - if (knockPipeText && knockPipe) { - knockPipeText.textContent = knockPipe.dataset.knocking ?? '' - } - if (cmdEl) { - for (let i = 1; i <= KNOCK_CMD.length; i += 1) { - if (token !== runToken) { - return - } - cmdEl.textContent = KNOCK_CMD.slice(0, i) - await sleep(22) - } + setText(knockPipeText, knockPipe?.dataset.knocking) + if (!(await typeCommand(cmdEl, KNOCK_CMD, alive))) { + return } await sleep(220) - for (const step of knockSteps) { - if (token !== runToken) { - return - } - step.setAttribute('data-on', '') - await sleep(340) - step.setAttribute('data-done', '') - } - if (token !== runToken) { + if (!(await advanceSteps(knockSteps, 340, alive))) { return } sasBox?.setAttribute('data-on', '') - if (knockPipeText && knockPipe) { - knockPipeText.textContent = knockPipe.dataset.whois ?? '' - } + setText(knockPipeText, knockPipe?.dataset.whois) await sleep(260) - if (token !== runToken) { + if (!alive()) { return } inboxCard?.setAttribute('data-arrived', '') stage.dataset.phase = 'ready' if (autoApprove) { await sleep(2200) - if (token !== runToken || knockApproved) { - return + if (alive() && !knockApproved) { + applyKnockApproved() } - applyKnockApproved() } } @@ -226,138 +223,96 @@ export function mountTailscale(): void { for (const line of sshLines) { line.toggleAttribute('data-on', reduced) } - if (sshPipeText && sshPipe) { - sshPipeText.textContent = sshPipe.dataset.hostkey ?? '' - } - if (sshStatus) { - sshStatus.textContent = sshStatus.dataset.idle ?? '' - } - if (deployBtn && deployLabel) { - deployBtn.disabled = false - deployBtn.removeAttribute('data-complete') - deployLabel.textContent = deployBtn.dataset.idle ?? '' - } + setText(sshPipeText, sshPipe?.dataset.hostkey) + setText(sshStatus, sshStatus?.dataset.idle) + setActionButton(deployBtn, deployLabel, deployBtn?.dataset.idle, false, false) + } + + const completeSsh = (): void => { + stage.dataset.phase = 'online' + setText(sshPipeText, sshPipe?.dataset.online) + setText(sshStatus, sshStatus?.dataset.done) + setActionButton(deployBtn, deployLabel, deployBtn?.dataset.done, false, true) } const playSsh = async (token: number): Promise => { + const alive = (): boolean => token === runToken resetSsh() if (reduced) { - stage.dataset.phase = 'online' - if (sshStatus) { - sshStatus.textContent = sshStatus.dataset.done ?? '' - } - if (sshPipeText && sshPipe) { - sshPipeText.textContent = sshPipe.dataset.online ?? '' - } - if (deployBtn && deployLabel) { - deployBtn.setAttribute('data-complete', '') - deployLabel.textContent = deployBtn.dataset.done ?? '' - } + completeSsh() return } stage.dataset.phase = 'active' - if (deployBtn && deployLabel) { - deployBtn.disabled = true - deployLabel.textContent = deployBtn.dataset.busy ?? '' - } - if (sshStatus) { - sshStatus.textContent = sshStatus.dataset.deploying ?? '' - } + setActionButton(deployBtn, deployLabel, deployBtn?.dataset.busy, true, false) + setText(sshStatus, sshStatus?.dataset.deploying) for (const [index, line] of sshLines.entries()) { - if (token !== runToken) { + if (!alive()) { return } - if (index === 1 && sshPipeText && sshPipe) { - sshPipeText.textContent = sshPipe.dataset.install ?? '' + if (index === 1) { + setText(sshPipeText, sshPipe?.dataset.install) } await sleep(index === 0 ? 280 : 520) - if (token !== runToken) { + if (!alive()) { return } line.setAttribute('data-on', '') } - if (token !== runToken) { - return - } - stage.dataset.phase = 'online' - if (sshPipeText && sshPipe) { - sshPipeText.textContent = sshPipe.dataset.online ?? '' - } - if (sshStatus) { - sshStatus.textContent = sshStatus.dataset.done ?? '' - } - if (deployBtn && deployLabel) { - deployBtn.disabled = false - deployBtn.setAttribute('data-complete', '') - deployLabel.textContent = deployBtn.dataset.done ?? '' + if (alive()) { + completeSsh() } } const resetBaremetal = (): void => { stopMetrics() stage.dataset.phase = 'idle' - for (const step of bmSteps) { - step.toggleAttribute('data-on', reduced) - step.toggleAttribute('data-done', reduced) - } + toggleItems(bmSteps, reduced, reduced) iosCard?.toggleAttribute('data-paired', reduced) - if (iosStatus) { - iosStatus.textContent = reduced ? (iosStatus.dataset.paired ?? '') : (iosStatus.dataset.waiting ?? '') - } - if (bmBtn && bmLabel) { - bmBtn.disabled = false - bmBtn.toggleAttribute('data-complete', reduced) - bmLabel.textContent = reduced ? (bmBtn.dataset.done ?? '') : (bmBtn.dataset.idle ?? '') - } + setText(iosStatus, reduced ? iosStatus?.dataset.paired : iosStatus?.dataset.waiting) + setActionButton(bmBtn, bmLabel, reduced ? bmBtn?.dataset.done : bmBtn?.dataset.idle, false, reduced) } const playBaremetal = async (token: number): Promise => { + const alive = (): boolean => token === runToken resetBaremetal() if (reduced) { stage.dataset.phase = 'online' return } stage.dataset.phase = 'active' - if (bmBtn && bmLabel) { - bmBtn.disabled = true - bmLabel.textContent = bmBtn.dataset.busy ?? '' - } - for (const step of bmSteps) { - if (token !== runToken) { - return - } - step.setAttribute('data-on', '') - await sleep(560) - if (token !== runToken) { - return - } - step.setAttribute('data-done', '') - } - if (token !== runToken) { + setActionButton(bmBtn, bmLabel, bmBtn?.dataset.busy, true, false) + if (!(await advanceSteps(bmSteps, 560, alive))) { return } stage.dataset.phase = 'online' iosCard?.setAttribute('data-paired', '') - if (iosStatus) { - iosStatus.textContent = iosStatus.dataset.paired ?? '' + setText(iosStatus, iosStatus?.dataset.paired) + setActionButton(bmBtn, bmLabel, bmBtn?.dataset.done, false, true) + } + + const startMode = (mode: Mode, token: number, autoApprove: boolean): void => { + if (mode === 'knock') { + playKnock(token, autoApprove) + } else if (mode === 'ssh') { + playSsh(token) + } else { + playBaremetal(token) } - if (bmBtn && bmLabel) { - bmBtn.disabled = false - bmBtn.setAttribute('data-complete', '') - bmLabel.textContent = bmBtn.dataset.done ?? '' + } + + const resetMode = (mode: Mode): void => { + if (mode === 'knock') { + resetKnock() + } else if (mode === 'ssh') { + resetSsh() + } else { + resetBaremetal() } } const runCurrentMode = (autoApprove: boolean): void => { runToken += 1 - const token = runToken - if (activeMode === 'knock') { - void playKnock(token, autoApprove) - } else if (activeMode === 'ssh') { - void playSsh(token) - } else { - void playBaremetal(token) - } + startMode(activeMode, runToken, autoApprove) } const selectMode = (mode: Mode, focus: boolean): void => { @@ -372,13 +327,7 @@ export function mountTailscale(): void { activeMode = mode stage.dataset.mode = mode stage.dataset.switched = '' - if (mode === 'knock') { - resetKnock() - } else if (mode === 'ssh') { - resetSsh() - } else { - resetBaremetal() - } + resetMode(mode) for (const tab of tabs) { const selected = tab.dataset.tsTab === mode tab.setAttribute('aria-selected', String(selected)) @@ -394,13 +343,7 @@ export function mountTailscale(): void { panel.inert = !isActive } placePill() - if (mode === 'knock') { - void playKnock(token, false) - } else if (mode === 'ssh') { - void playSsh(token) - } else { - void playBaremetal(token) - } + startMode(mode, token, false) } const keys: Record number> = { @@ -438,12 +381,12 @@ export function mountTailscale(): void { deployBtn?.addEventListener('click', () => { runToken += 1 - void playSsh(runToken) + playSsh(runToken) }) bmBtn?.addEventListener('click', () => { runToken += 1 - void playBaremetal(runToken) + playBaremetal(runToken) }) replayBtn?.addEventListener('click', () => { diff --git a/apps/landing/src/styles/global.css b/apps/landing/src/styles/global.css index 6ecda78c..ff7a0275 100644 --- a/apps/landing/src/styles/global.css +++ b/apps/landing/src/styles/global.css @@ -2277,18 +2277,18 @@ section[id] { } .ts-panel { - grid-area: 1 / 1; display: flex; + visibility: hidden; flex-direction: column; + grid-area: 1 / 1; pointer-events: none; - visibility: hidden; opacity: 0; } .ts-panel[data-active] { z-index: 1; - pointer-events: auto; visibility: visible; + pointer-events: auto; opacity: 1; } @@ -2335,17 +2335,11 @@ section[id] { align-items: center; min-width: 0; overflow: hidden; + text-overflow: ellipsis; font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: inherit; - text-overflow: ellipsis; - white-space: nowrap; -} - -.ts-pane-head .ts-badge, -.ts-pane-head .ts-pill-mono { - flex: none; white-space: nowrap; } @@ -2363,10 +2357,12 @@ section[id] { } .ts-pill-mono { + flex: none; padding: 2px 8px; font-family: var(--font-mono); font-size: 0.71875rem; color: var(--ink-2); + white-space: nowrap; background: var(--sunken); border: 1px solid var(--line); border-radius: 999px; @@ -2382,11 +2378,11 @@ section[id] { min-height: 44px; padding: 10px 12px; margin: 0; - overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 0.78125rem; line-height: 1.5; color: var(--cmd-ink); + overflow-wrap: anywhere; white-space: pre-wrap; background: rgb(255 255 255 / 0.04); border: 1px solid var(--cmd-line); @@ -2546,11 +2542,13 @@ section[id] { .ts-badge { display: inline-flex; + flex: none; align-items: center; padding: 2px 9px; font-family: var(--font-mono); font-size: 0.71875rem; font-weight: 600; + white-space: nowrap; border-radius: 999px; } @@ -2590,13 +2588,13 @@ section[id] { gap: 2px; } -.ts-node-meta b { +.ts-node-name { font-family: var(--font-mono); font-size: 0.9375rem; color: var(--ink); } -.ts-node-meta span { +.ts-node-sub { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); @@ -2641,7 +2639,7 @@ section[id] { opacity: 1; } -.ts-metrics > div { +.ts-metric-cell { display: grid; gap: 2px; padding: 8px 10px; @@ -2650,13 +2648,13 @@ section[id] { border-radius: 8px; } -.ts-metrics span { +.ts-metric-label { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-3); } -.ts-metrics b { +.ts-metric-val { font-family: var(--font-mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; @@ -2765,10 +2763,10 @@ section[id] { } .ts-qr-url { - overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 0.8125rem; color: var(--ink); + overflow-wrap: anywhere; } .ts-qr-state {
{copy.lede}
$ install.sh agent --tailscale
$ tailscale up --authkey=tskey-auth-*** && install.sh agent --tailscale
+ {stage.baremetal.iosWaiting} +