Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
feat(open-knowledge): single share-splash CTA with download fallback (#1786)
Andrew Mikofalvy5518ffb357e2
diff --git a/docs/src/app/d/[encoded]/splash-cta-cluster.tsx b/docs/src/app/d/[encoded]/splash-cta-cluster.tsxindex 2abc9cdaa..ec5e93760 100644--- a/docs/src/app/d/[encoded]/splash-cta-cluster.tsx+++ b/docs/src/app/d/[encoded]/splash-cta-cluster.tsx@@ -1,4 +1,7 @@+'use client';+import { ArrowRightIcon, DownloadIcon, ExternalLinkIcon } from 'lucide-react';+import { useEffect, useRef, useState } from 'react';interface SplashCtaClusterProps {downloadUrl: string;@@ -6,41 +9,112 @@ interface SplashCtaClusterProps {githubUrl: string;}+const FALLBACK_REVEAL_DELAY_MS = 2500;+export function SplashCtaCluster({downloadUrl,customSchemeUrl,githubUrl,}: SplashCtaClusterProps) {+ const [attempting, setAttempting] = useState(false);+ const [handoffFailed, setHandoffFailed] = useState(false);+ const attemptCleanupRef = useRef<(() => void) | null>(null);+ const fallbackCtaRef = useRef<HTMLAnchorElement | null>(null);++ useEffect(() => () => attemptCleanupRef.current?.(), []);++ useEffect(() => {+ if (handoffFailed) fallbackCtaRef.current?.focus();+ }, [handoffFailed]);++ const handleOpenClick = () => {+ attemptCleanupRef.current?.();+ setHandoffFailed(false);+ setAttempting(true);++ function cleanup() {+ clearTimeout(timer);+ document.removeEventListener('visibilitychange', onVisibilityChange);+ window.removeEventListener('pagehide', onHandoffSignal);+ window.removeEventListener('blur', onHandoffSignal);+ attemptCleanupRef.current = null;+ setAttempting(false);+ }++ function onHandoffSignal() {+ cleanup();+ }++ function onVisibilityChange() {+ if (document.visibilityState === 'hidden') cleanup();+ }++ document.addEventListener('visibilitychange', onVisibilityChange);+ window.addEventListener('pagehide', onHandoffSignal);+ window.addEventListener('blur', onHandoffSignal);++ const timer = setTimeout(() => {+ cleanup();+ if (document.visibilityState === 'visible') setHandoffFailed(true);+ }, FALLBACK_REVEAL_DELAY_MS);++ attemptCleanupRef.current = cleanup;+ };+return (- <div className="mt-12 flex flex-wrap items-center gap-4">- <a- href={downloadUrl}- data-testid="splash-download-cta"- className="slide-btn-primary inline-flex items-center gap-2 rounded-lg px-6 py-3 text-sm font-medium transition-opacity focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent-strong)]"- >- <DownloadIcon className="size-4" aria-hidden="true" />- Download Open Knowledge for macOS- </a>-- <a- href={customSchemeUrl}- data-testid="splash-open-cta"- className="slide-btn-outline inline-flex items-center gap-2 rounded-lg px-6 py-3 text-sm font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent)]"- >- Open in Open Knowledge- <ArrowRightIcon className="size-4" aria-hidden="true" />- </a>-- <a- href={githubUrl}- data-testid="splash-github-cta"- rel="noopener noreferrer"- target="_blank"- className="inline-flex items-center gap-1.5 text-sm font-medium text-[var(--slide-muted)] transition-colors hover:text-[var(--slide-accent)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent)] focus-visible:rounded"- >- View on GitHub- <ExternalLinkIcon className="size-3.5" aria-hidden="true" />- </a>+ <div className="mt-12">+ <div className="flex flex-wrap items-center gap-4">+ <a+ href={customSchemeUrl}+ onClick={handleOpenClick}+ data-testid="splash-open-cta"+ className="slide-btn-primary inline-flex touch-manipulation items-center gap-2 rounded-lg px-6 py-3 text-sm font-medium transition-[opacity,transform] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent-strong)]"+ >+ {attempting ? 'Opening…' : 'Open in Open Knowledge'}+ <ArrowRightIcon className="size-4" aria-hidden="true" />+ </a>++ <a+ href={githubUrl}+ data-testid="splash-github-cta"+ rel="noopener noreferrer"+ target="_blank"+ className="inline-flex touch-manipulation items-center gap-1.5 text-sm font-medium text-[var(--slide-muted)] transition-colors hover:text-[var(--slide-accent)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent)] focus-visible:rounded"+ >+ View on GitHub+ <ExternalLinkIcon className="size-3.5" aria-hidden="true" />+ </a>+ </div>++ <div aria-live="polite">+ {handoffFailed ? (+ <div className="mt-6" data-testid="splash-handoff-fallback">+ <p className="text-sm text-[var(--slide-muted)]">+ Looks like Open Knowledge isn’t installed yet.+ </p>+ <a+ ref={fallbackCtaRef}+ href={downloadUrl}+ data-testid="splash-download-fallback-cta"+ className="slide-btn-primary mt-3 inline-flex touch-manipulation items-center gap-2 rounded-lg px-6 py-3 text-sm font-medium transition-[opacity,transform] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent-strong)]"+ >+ <DownloadIcon className="size-4" aria-hidden="true" />+ Download Open Knowledge for macOS+ </a>+ </div>+ ) : (+ <p className="mt-4 text-sm text-[var(--slide-muted)]">+ Don’t have the app?{' '}+ <a+ href={downloadUrl}+ data-testid="splash-download-cta"+ className="touch-manipulation font-medium text-[var(--slide-text)] underline underline-offset-4 transition-colors hover:text-[var(--slide-accent)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--slide-accent)] focus-visible:rounded"+ >+ Download for macOS+ </a>+ </p>+ )}+ </div></div>);}diff --git a/docs/src/app/global.css b/docs/src/app/global.cssindex 237542d08..21dc400f6 100644--- a/docs/src/app/global.css+++ b/docs/src/app/global.css@@ -269,6 +269,10 @@opacity: 0.92;}+.slide-btn-primary:active {+ transform: scale(0.97);+}+.dark .slide-btn-primary {/* Dark mode: --slide-accent-strong is LIGHT (#93c5fd) — pair with darktext (--slide-bg = #0c0c0c) for ~10.9:1 contrast. Using --slide-text