Unify website and documentation pages with a consistent terminal aesthetic
Extract shared canvas animation module, refactor docs page to a terminal man-page style, and align overall visual language. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 6def8112-39d2-4641-b93b-f39108179f33 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 87e11a5a-0718-4680-a1d4-0d2c471eca80 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/42ae33dd-8759-4196-85a5-434465c72ece/6def8112-39d2-4641-b93b-f39108179f33/Mumw6Ni Replit-Helium-Checkpoint-Created: true
This commit is contained in:
148
docs.html
148
docs.html
@@ -3,101 +3,111 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Documentation - Terminal Portfolio</title>
|
<title>man ssh — keshavanand.net</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="docs">
|
||||||
<div class="container">
|
<canvas id="field" aria-hidden="true"></canvas>
|
||||||
<div class="header">
|
|
||||||
<a href="/" class="back-link">$ cd ..</a>
|
|
||||||
<h1>Documentation</h1>
|
|
||||||
<p class="subtitle">The who, what, when, where, why</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="command-reference">
|
<main class="page">
|
||||||
<div class="command-box">
|
<a href="/" class="back">$ cd ..</a>
|
||||||
<code id="sshCommand">ssh portfolio@keshavanand.net</code>
|
|
||||||
<button class="copy-btn" id="copyBtn" aria-label="Copy command">
|
<header class="head">
|
||||||
<svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<h1>man <span class="accent">ssh</span></h1>
|
||||||
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
<p class="sub">portfolio(1)<span class="dot">·</span>keshavanand.net<span class="dot">·</span>v1</p>
|
||||||
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
</header>
|
||||||
</svg>
|
|
||||||
<svg class="check-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<div class="rule" aria-hidden="true"></div>
|
||||||
<polyline points="20 6 9 17 4 12"></polyline>
|
|
||||||
|
<div class="command-box" id="commandBox">
|
||||||
|
<span class="line"><span class="dollar">$ </span><span class="typed">ssh portfolio@keshavanand.net</span></span>
|
||||||
|
<button class="action-btn" id="copyBtn" aria-label="Copy command">
|
||||||
|
<svg id="copyIcon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path id="copyPath" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="sections">
|
<section class="block">
|
||||||
<section class="section">
|
<h2><span class="hash">#</span> name</h2>
|
||||||
<h2>What is it?</h2>
|
|
||||||
<p>
|
<p>
|
||||||
When executed in your terminal, this command renders a fully interactive shell portfolio experience.
|
A keystroke-driven portfolio. The command above opens a real SSH session into a restricted, passwordless
|
||||||
Much like a digital resume or personal site, it allows you to explore my work and background through
|
account on a homeserver and drops you into a custom C++/FTXUI interface. <span class="fg">No web app, no JS, no installer — just the shell you already have.</span>
|
||||||
a safe, <strong>secure</strong>, and purely text-based interface.
|
|
||||||
<strong>It is completely harmless to your system.</strong>
|
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="block">
|
||||||
<h2>Command Breakdown</h2>
|
<h2><span class="hash">#</span> synopsis</h2>
|
||||||
<div class="breakdown-grid">
|
<pre class="code"><span class="dim">$</span> ssh <span class="accent">portfolio</span>@<span class="accent">keshavanand.net</span></pre>
|
||||||
<div class="breakdown-item">
|
|
||||||
<h3>ssh →</h3>
|
|
||||||
<p><strong>Secure Shell:</strong> The standard terminal protocol for logging into and controlling remote computers safely.</p>
|
|
||||||
</div>
|
|
||||||
<div class="breakdown-item">
|
|
||||||
<h3>portfolio →</h3>
|
|
||||||
<p><strong>User:</strong> A passwordless, restricted user on my homeserver meant for public access.</p>
|
|
||||||
</div>
|
|
||||||
<div class="breakdown-item">
|
|
||||||
<h3>keshavanand.net →</h3>
|
|
||||||
<p><strong>Domain:</strong> Points to a web record that directs your request to my server's public IP (gateway).</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="block">
|
||||||
<h2>How to Run</h2>
|
<h2><span class="hash">#</span> arguments</h2>
|
||||||
|
<dl class="defs">
|
||||||
|
<div class="def">
|
||||||
|
<dt><span class="accent">ssh</span></dt>
|
||||||
|
<dd>secure shell — the standard remote-login protocol. ubiquitous on macOS, linux, and modern windows.</dd>
|
||||||
|
</div>
|
||||||
|
<div class="def">
|
||||||
|
<dt><span class="accent">portfolio</span></dt>
|
||||||
|
<dd>a passwordless, restricted user account. the only thing it can do is launch the portfolio binary.</dd>
|
||||||
|
</div>
|
||||||
|
<div class="def">
|
||||||
|
<dt><span class="accent">keshavanand.net</span></dt>
|
||||||
|
<dd>resolves to my homeserver's public IP. the gateway forwards port 22 to the box.</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="block">
|
||||||
|
<h2><span class="hash">#</span> usage</h2>
|
||||||
<ol class="steps">
|
<ol class="steps">
|
||||||
<li>Copy the command above using the clipboard tool.</li>
|
<li><span class="step">01</span> copy the command above (click the box, or the icon).</li>
|
||||||
<li>Open your native terminal (Terminal on Mac/Linux, PowerShell on Windows).</li>
|
<li><span class="step">02</span> open your terminal — Terminal, iTerm, Alacritty, Windows Terminal, anything.</li>
|
||||||
<li>Paste the command and accept the host identity by typing 'yes' if prompted.</li>
|
<li><span class="step">03</span> paste, hit return. accept the host fingerprint with <kbd>yes</kbd> on first connect.</li>
|
||||||
<li>Press Enter to launch the interactive environment.</li>
|
<li><span class="step">04</span> navigate with arrow keys + return. quit any time with <kbd>Ctrl</kbd>+<kbd>C</kbd>.</li>
|
||||||
<li>Terminate the process at any time by pressing <kbd>Ctrl + C</kbd>.</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="block">
|
||||||
<h2>Code Logic</h2>
|
<h2><span class="hash">#</span> implementation</h2>
|
||||||
<p>
|
<p>
|
||||||
This command gives authenticated access to the <strong>'portfolio'</strong> user account on my private home server.
|
The <span class="fg">portfolio</span> user's login shell isn't bash — it's a custom C++ binary that uses
|
||||||
</p>
|
<a href="https://github.com/ArthurSonzogni/FTXUI" target="_blank" rel="noopener noreferrer">FTXUI</a>
|
||||||
<p>
|
for layout, focus management, and rendering. Input is captured raw, output is repainted on a frame loop.
|
||||||
Instead of a standard bash or zsh shell, the user session triggers a custom-coded <strong>C++ executable</strong>.
|
<span class="fg">It is sandboxed, read-only, and harmless to your machine.</span>
|
||||||
This binary utilizes <strong>FTXUI</strong>—a sophisticated functional terminal user interface library—to handle
|
|
||||||
real-time rendering and input.
|
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="section">
|
<section class="block">
|
||||||
<h2>Resources</h2>
|
<h2><span class="hash">#</span> see also</h2>
|
||||||
<div class="resources-grid">
|
<ul class="links">
|
||||||
<a href="https://git.keshavanand.net/KeshavAnandCode/terminal-portfolio" target="_blank" rel="noopener noreferrer" class="resource-card">
|
<li>
|
||||||
<span>View Source Code</span>
|
<a href="https://git.keshavanand.net/KeshavAnandCode/terminal-portfolio" target="_blank" rel="noopener noreferrer">
|
||||||
|
<span class="arrow">→</span> source — git.keshavanand.net
|
||||||
</a>
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="/webshell">
|
||||||
|
<span class="arrow">→</span> run in browser — /webshell
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
<a href="/webshell" class="resource-card">
|
<footer class="foot">
|
||||||
<span>Run Web Shell</span>
|
<span>keshavanand.net</span>
|
||||||
</a>
|
<span class="dot">·</span>
|
||||||
</div>
|
<span>portfolio(1)</span>
|
||||||
</div>
|
<span class="dot">·</span>
|
||||||
</div>
|
<span>last updated 2026</span>
|
||||||
|
</footer>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<div class="byline">// vibe coded to present human code</div>
|
||||||
|
|
||||||
<script type="module" src="/src/docs.ts"></script>
|
<script type="module" src="/src/docs.ts"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
438
src/docs.css
438
src/docs.css
@@ -1,11 +1,13 @@
|
|||||||
:root {
|
:root {
|
||||||
--base: #000000;
|
--bg: #0b0b0d;
|
||||||
--text: #cdd6f4;
|
--fg: #e6e6e6;
|
||||||
--subtext0: #a6adc8;
|
--dim: #6a6a72;
|
||||||
--surface0: #1a1a1a;
|
--dimmer: #4a4a52;
|
||||||
--surface1: #2a2a2a;
|
--line: #1c1c20;
|
||||||
--green: #a6e3a1;
|
--accent: #a6e3a1;
|
||||||
--blue: #89b4fa;
|
--accent-soft: rgba(166, 227, 161, 0.22);
|
||||||
|
--accent-strong: rgba(166, 227, 161, 0.55);
|
||||||
|
--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
@@ -14,238 +16,320 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
html { height: 100%; }
|
||||||
font-family: "JetBrains Mono", monospace;
|
|
||||||
background-color: var(--base);
|
body.docs {
|
||||||
color: var(--text);
|
font-family: var(--mono);
|
||||||
min-height: 100vh;
|
background: var(--bg);
|
||||||
padding: 2rem 1.5rem;
|
color: var(--fg);
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
min-height: 100%;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
position: relative;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
#field {
|
||||||
max-width: 650px;
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
max-width: 720px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
padding: 3rem 1.75rem 6rem;
|
||||||
|
opacity: 0;
|
||||||
|
animation: fade 500ms ease-out 60ms forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
@keyframes fade { to { opacity: 1; } }
|
||||||
margin-bottom: 3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-link {
|
/* back link — same accent treatment as the home dollar */
|
||||||
color: var(--subtext0);
|
.back {
|
||||||
text-decoration: none;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
transition: color 0.2s ease;
|
color: var(--dim);
|
||||||
|
text-decoration: none;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
padding: 0.15rem 0;
|
||||||
|
transition: color 180ms ease, transform 180ms ease;
|
||||||
|
}
|
||||||
|
.back:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
transform: translateX(-2px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-link:hover {
|
.head {
|
||||||
color: var(--green);
|
margin-top: 2.5rem;
|
||||||
}
|
|
||||||
|
|
||||||
.back-link:hover {
|
|
||||||
color: var(--green);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
color: var(--text);
|
font-size: 1.65rem;
|
||||||
font-size: 2.5rem;
|
font-weight: 500;
|
||||||
margin: 1rem 0 0.5rem 0;
|
letter-spacing: 0.01em;
|
||||||
font-weight: 600;
|
color: var(--fg);
|
||||||
}
|
}
|
||||||
|
|
||||||
.subtitle {
|
h1 .accent { color: var(--accent); }
|
||||||
color: var(--subtext0);
|
|
||||||
font-size: 1rem;
|
.sub {
|
||||||
|
margin-top: 0.45rem;
|
||||||
|
color: var(--dim);
|
||||||
|
font-size: 0.78rem;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.command-reference {
|
.sub .dot {
|
||||||
margin: 2rem 0 3rem 0;
|
margin: 0 0.55rem;
|
||||||
|
color: var(--dimmer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rule {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--line);
|
||||||
|
margin: 1.6rem 0 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* command box — visually identical to the home version, sans caret/input */
|
||||||
.command-box {
|
.command-box {
|
||||||
background: rgba(26, 26, 26, 0.8);
|
width: 100%;
|
||||||
border: 1px solid var(--green);
|
background: rgba(10, 10, 12, 0.55);
|
||||||
padding: 1.25rem;
|
backdrop-filter: blur(2px);
|
||||||
|
-webkit-backdrop-filter: blur(2px);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 1.05rem 1.15rem;
|
||||||
|
font-size: 1.05rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--fg);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
gap: 0;
|
||||||
gap: 1rem;
|
transition: border-color 200ms ease, box-shadow 200ms ease;
|
||||||
transition: border-color 0.2s ease;
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.command-box:hover {
|
.command-box:hover {
|
||||||
border-color: var(--blue);
|
border-color: var(--accent-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
.command-box code {
|
.command-box.copied {
|
||||||
color: var(--green);
|
border-color: var(--accent-strong);
|
||||||
font-size: 1.1rem;
|
box-shadow: 0 0 0 1px rgba(166, 227, 161, 0.10), 0 0 24px rgba(166, 227, 161, 0.10);
|
||||||
flex: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.copy-btn {
|
.line {
|
||||||
background: none;
|
flex: 1 1 auto;
|
||||||
border: none;
|
min-width: 0;
|
||||||
color: var(--subtext0);
|
white-space: pre;
|
||||||
cursor: pointer;
|
overflow: hidden;
|
||||||
padding: 0.5rem;
|
text-overflow: clip;
|
||||||
border-radius: 4px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn:hover {
|
|
||||||
color: var(--green);
|
|
||||||
background-color: var(--surface0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn .check-icon {
|
|
||||||
display: none;
|
|
||||||
color: var(--green);
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn.copied .copy-icon {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.copy-btn.copied .check-icon {
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sections {
|
.dollar {
|
||||||
display: flex;
|
color: var(--accent);
|
||||||
flex-direction: column;
|
font-weight: 600;
|
||||||
gap: 3rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.section {
|
.typed { color: var(--fg); }
|
||||||
|
|
||||||
|
.action-btn {
|
||||||
|
margin-left: 0.6rem;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--dim);
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0.2rem;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
transition: color 180ms ease, transform 180ms ease;
|
||||||
|
}
|
||||||
|
.action-btn:hover { color: var(--fg); }
|
||||||
|
.action-btn svg { width: 16px; height: 16px; }
|
||||||
|
|
||||||
|
/* sections — terminal-style "# heading" then prose */
|
||||||
|
.block {
|
||||||
|
margin-top: 2.6rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
color: var(--green);
|
font-size: 0.85rem;
|
||||||
font-size: 1.5rem;
|
font-weight: 500;
|
||||||
margin-bottom: 1.25rem;
|
color: var(--fg);
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
text-transform: lowercase;
|
||||||
|
margin-bottom: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 .hash {
|
||||||
|
color: var(--accent);
|
||||||
|
margin-right: 0.4rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
.block p {
|
||||||
color: var(--subtext0);
|
color: var(--dim);
|
||||||
margin-bottom: 1rem;
|
font-size: 0.88rem;
|
||||||
font-size: 0.95rem;
|
line-height: 1.75;
|
||||||
}
|
}
|
||||||
|
|
||||||
strong {
|
.block p .fg { color: var(--fg); }
|
||||||
color: var(--text);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breakdown-grid {
|
.block p a {
|
||||||
|
color: var(--accent);
|
||||||
|
text-decoration: none;
|
||||||
|
border-bottom: 1px dashed transparent;
|
||||||
|
transition: border-color 180ms ease;
|
||||||
|
}
|
||||||
|
.block p a:hover { border-bottom-color: var(--accent-soft); }
|
||||||
|
|
||||||
|
/* code block — quieter, leaner than the command box */
|
||||||
|
.code {
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 0.92rem;
|
||||||
|
background: rgba(10, 10, 12, 0.4);
|
||||||
|
border-left: 1px solid var(--accent-soft);
|
||||||
|
padding: 0.8rem 1rem;
|
||||||
|
color: var(--fg);
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
.code .dim { color: var(--dim); margin-right: 0.5rem; }
|
||||||
|
.code .accent { color: var(--accent); }
|
||||||
|
|
||||||
|
/* arguments — definition list, mono leader */
|
||||||
|
.defs {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.9rem;
|
||||||
|
}
|
||||||
|
.def {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
grid-template-columns: minmax(160px, 200px) 1fr;
|
||||||
gap: 1.5rem;
|
gap: 1rem;
|
||||||
margin-top: 1.5rem;
|
padding: 0.5rem 0;
|
||||||
}
|
border-bottom: 1px dashed var(--line);
|
||||||
|
align-items: baseline;
|
||||||
.breakdown-item {
|
}
|
||||||
padding: 1rem;
|
.def:last-child { border-bottom: none; }
|
||||||
border-bottom: 1px solid rgba(166, 227, 161, 0.1);
|
.def dt {
|
||||||
}
|
font-size: 0.85rem;
|
||||||
|
font-weight: 500;
|
||||||
.breakdown-item:last-child {
|
}
|
||||||
border-bottom: none;
|
.def dd {
|
||||||
}
|
color: var(--dim);
|
||||||
|
font-size: 0.85rem;
|
||||||
.breakdown-item h3 {
|
line-height: 1.7;
|
||||||
color: var(--blue);
|
|
||||||
font-size: 1rem;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breakdown-item p {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* steps — numbered, monospace numerals */
|
||||||
.steps {
|
.steps {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
counter-reset: step;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.steps li {
|
|
||||||
counter-increment: step;
|
|
||||||
margin-bottom: 1.25rem;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 1rem;
|
flex-direction: column;
|
||||||
color: var(--subtext0);
|
gap: 0.55rem;
|
||||||
font-size: 0.95rem;
|
|
||||||
}
|
}
|
||||||
|
.steps li {
|
||||||
.steps li::before {
|
color: var(--dim);
|
||||||
content: counter(step, decimal-leading-zero);
|
font-size: 0.88rem;
|
||||||
color: var(--green);
|
line-height: 1.7;
|
||||||
font-weight: 600;
|
}
|
||||||
min-width: 2rem;
|
.steps .step {
|
||||||
|
display: inline-block;
|
||||||
|
color: var(--accent);
|
||||||
|
margin-right: 0.85rem;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
kbd {
|
kbd {
|
||||||
background-color: var(--surface0);
|
font-family: var(--mono);
|
||||||
border: 1px solid var(--surface1);
|
font-size: 0.78em;
|
||||||
padding: 0.2rem 0.5rem;
|
color: var(--fg);
|
||||||
border-radius: 4px;
|
border: 1px solid var(--line);
|
||||||
color: var(--text);
|
background: rgba(255, 255, 255, 0.03);
|
||||||
font-size: 0.9em;
|
padding: 0.05rem 0.35rem;
|
||||||
font-family: inherit;
|
border-radius: 3px;
|
||||||
|
margin: 0 0.1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.resources-grid {
|
/* see also — link list */
|
||||||
display: grid;
|
.links {
|
||||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
list-style: none;
|
||||||
gap: 1rem;
|
display: flex;
|
||||||
margin-top: 1.5rem;
|
flex-direction: column;
|
||||||
|
gap: 0.4rem;
|
||||||
}
|
}
|
||||||
|
.links a {
|
||||||
.resource-card {
|
display: inline-flex;
|
||||||
display: block;
|
align-items: baseline;
|
||||||
padding: 0.75rem 1rem;
|
gap: 0.55rem;
|
||||||
background: rgba(26, 26, 26, 0.5);
|
color: var(--fg);
|
||||||
border: 1px solid rgba(166, 227, 161, 0.15);
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: var(--text);
|
font-size: 0.88rem;
|
||||||
margin: 0.5rem 0;
|
padding: 0.25rem 0;
|
||||||
transition: border-color 0.2s ease, background-color 0.2s ease;
|
transition: color 180ms ease, transform 180ms ease;
|
||||||
|
}
|
||||||
|
.links a:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
transform: translateX(3px);
|
||||||
|
}
|
||||||
|
.links .arrow { color: var(--accent); }
|
||||||
|
|
||||||
|
/* footer — quiet, like a man-page footer */
|
||||||
|
.foot {
|
||||||
|
margin-top: 4rem;
|
||||||
|
padding-top: 1.2rem;
|
||||||
|
border-top: 1px solid var(--line);
|
||||||
|
color: var(--dimmer);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
letter-spacing: 0.04em;
|
||||||
|
}
|
||||||
|
.foot .dot {
|
||||||
|
margin: 0 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.resource-card:hover {
|
/* whisper-quiet byline, identical to home */
|
||||||
border-color: var(--green);
|
.byline {
|
||||||
background: rgba(26, 26, 26, 0.7);
|
position: fixed;
|
||||||
|
left: 50%;
|
||||||
|
bottom: 1rem;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
z-index: 1;
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: 0.62rem;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
color: rgba(106, 106, 114, 0.28);
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0;
|
||||||
|
animation: fadeWhisper 900ms ease-out 1500ms forwards;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.resource-card span {
|
@keyframes fadeWhisper { to { opacity: 1; } }
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 640px) {
|
||||||
body {
|
.page { padding: 2rem 1.25rem 5rem; }
|
||||||
padding: 1.5rem 1rem;
|
h1 { font-size: 1.35rem; }
|
||||||
}
|
.command-box { font-size: 0.92rem; padding: 0.9rem 1rem; }
|
||||||
|
.def {
|
||||||
h1 {
|
|
||||||
font-size: 1.8rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.breakdown-grid,
|
|
||||||
.resources-grid {
|
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
|
gap: 0.25rem;
|
||||||
}
|
}
|
||||||
|
.byline { font-size: 0.56rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.page, .byline { animation: none; opacity: 1; }
|
||||||
}
|
}
|
||||||
|
|||||||
45
src/docs.ts
45
src/docs.ts
@@ -1,16 +1,41 @@
|
|||||||
import './docs.css';
|
import './docs.css';
|
||||||
|
import { initField } from './field';
|
||||||
|
|
||||||
const copyBtn = document.getElementById('copyBtn') as HTMLButtonElement;
|
initField('field');
|
||||||
const command = 'ssh portfolio@keshavanand.net';
|
|
||||||
|
|
||||||
if (copyBtn) {
|
const COMMAND = 'ssh portfolio@keshavanand.net';
|
||||||
copyBtn.addEventListener('click', async () => {
|
|
||||||
|
const copyBtn = document.getElementById('copyBtn') as HTMLButtonElement | null;
|
||||||
|
const commandBox = document.getElementById('commandBox') as HTMLDivElement | null;
|
||||||
|
const copyPath = document.getElementById('copyPath') as unknown as SVGPathElement | null;
|
||||||
|
|
||||||
|
const COPY_PATH =
|
||||||
|
'M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z';
|
||||||
|
const CHECK_PATH = 'M5 13l4 4L19 7';
|
||||||
|
|
||||||
|
let resetTimer: number | undefined;
|
||||||
|
|
||||||
|
async function copy() {
|
||||||
|
if (!commandBox || !copyPath) return;
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(command);
|
await navigator.clipboard.writeText(COMMAND);
|
||||||
copyBtn.classList.add('copied');
|
copyPath.setAttribute('d', CHECK_PATH);
|
||||||
setTimeout(() => copyBtn.classList.remove('copied'), 2000);
|
commandBox.classList.add('copied');
|
||||||
} catch (err) {
|
window.clearTimeout(resetTimer);
|
||||||
console.error('Failed to copy:', err);
|
resetTimer = window.setTimeout(() => {
|
||||||
|
copyPath.setAttribute('d', COPY_PATH);
|
||||||
|
commandBox.classList.remove('copied');
|
||||||
|
}, 1400);
|
||||||
|
} catch {
|
||||||
|
/* clipboard blocked */
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyBtn?.addEventListener('click', (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
copy();
|
||||||
|
});
|
||||||
|
commandBox?.addEventListener('click', (e) => {
|
||||||
|
if ((e.target as HTMLElement).closest('.action-btn')) return;
|
||||||
|
copy();
|
||||||
|
});
|
||||||
|
|||||||
205
src/field.ts
Normal file
205
src/field.ts
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
type Dot = { bx: number; by: number; ox: number; oy: number };
|
||||||
|
type Ripple = { x: number; y: number; born: number };
|
||||||
|
|
||||||
|
const SPACING = 26;
|
||||||
|
const RADIUS = 170;
|
||||||
|
const PUSH = 18;
|
||||||
|
|
||||||
|
const RIPPLE_LIFE = 900;
|
||||||
|
const RIPPLE_MAX = 520;
|
||||||
|
const RIPPLE_BAND = 70;
|
||||||
|
const RIPPLE_PUSH = 36;
|
||||||
|
|
||||||
|
const BASE_RGB = '230, 230, 230';
|
||||||
|
const ACCENT_RGB = '166, 227, 161';
|
||||||
|
const BASE_ALPHA = 0.11;
|
||||||
|
const PEAK_ALPHA = 0.9;
|
||||||
|
|
||||||
|
let canvas: HTMLCanvasElement | null = null;
|
||||||
|
let ctx: CanvasRenderingContext2D | null = null;
|
||||||
|
|
||||||
|
let dots: Dot[] = [];
|
||||||
|
const ripples: Ripple[] = [];
|
||||||
|
|
||||||
|
let dpr = 1;
|
||||||
|
let w = 0;
|
||||||
|
let h = 0;
|
||||||
|
|
||||||
|
let targetX = -9999;
|
||||||
|
let targetY = -9999;
|
||||||
|
let curX = -9999;
|
||||||
|
let curY = -9999;
|
||||||
|
let active = false;
|
||||||
|
|
||||||
|
let started = false;
|
||||||
|
|
||||||
|
function build() {
|
||||||
|
if (!canvas || !ctx) return;
|
||||||
|
dpr = Math.max(1, window.devicePixelRatio || 1);
|
||||||
|
w = window.innerWidth;
|
||||||
|
h = window.innerHeight;
|
||||||
|
canvas.width = Math.floor(w * dpr);
|
||||||
|
canvas.height = Math.floor(h * dpr);
|
||||||
|
canvas.style.width = w + 'px';
|
||||||
|
canvas.style.height = h + 'px';
|
||||||
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
|
||||||
|
dots = [];
|
||||||
|
const pad = SPACING;
|
||||||
|
for (let y = -pad; y < h + pad; y += SPACING) {
|
||||||
|
for (let x = -pad; x < w + pad; x += SPACING) {
|
||||||
|
dots.push({ bx: x, by: y, ox: 0, oy: 0 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMove(x: number, y: number) {
|
||||||
|
targetX = x;
|
||||||
|
targetY = y;
|
||||||
|
active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function spawnRipple(x: number, y: number) {
|
||||||
|
ripples.push({ x, y, born: performance.now() });
|
||||||
|
if (ripples.length > 8) ripples.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
function frame() {
|
||||||
|
if (!ctx) return;
|
||||||
|
const now = performance.now();
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
targetX = -9999;
|
||||||
|
targetY = -9999;
|
||||||
|
}
|
||||||
|
curX += (targetX - curX) * 0.18;
|
||||||
|
curY += (targetY - curY) * 0.18;
|
||||||
|
|
||||||
|
for (let i = ripples.length - 1; i >= 0; i--) {
|
||||||
|
if (now - ripples[i].born > RIPPLE_LIFE) ripples.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rippleState = ripples.map((rp) => {
|
||||||
|
const p = (now - rp.born) / RIPPLE_LIFE;
|
||||||
|
return { x: rp.x, y: rp.y, radius: p * RIPPLE_MAX, fade: 1 - p };
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.clearRect(0, 0, w, h);
|
||||||
|
|
||||||
|
const r2 = RADIUS * RADIUS;
|
||||||
|
|
||||||
|
for (let i = 0; i < dots.length; i++) {
|
||||||
|
const d = dots[i];
|
||||||
|
|
||||||
|
const dx = d.bx - curX;
|
||||||
|
const dy = d.by - curY;
|
||||||
|
const d2 = dx * dx + dy * dy;
|
||||||
|
|
||||||
|
let tx = 0;
|
||||||
|
let ty = 0;
|
||||||
|
let strength = 0;
|
||||||
|
|
||||||
|
if (d2 < r2) {
|
||||||
|
const dist = Math.sqrt(d2) || 0.0001;
|
||||||
|
const t = 1 - dist / RADIUS;
|
||||||
|
strength = t * t;
|
||||||
|
tx = (dx / dist) * strength * PUSH;
|
||||||
|
ty = (dy / dist) * strength * PUSH;
|
||||||
|
}
|
||||||
|
|
||||||
|
let rippleStrength = 0;
|
||||||
|
for (let k = 0; k < rippleState.length; k++) {
|
||||||
|
const rp = rippleState[k];
|
||||||
|
const rdx = d.bx - rp.x;
|
||||||
|
const rdy = d.by - rp.y;
|
||||||
|
const rdist = Math.sqrt(rdx * rdx + rdy * rdy) || 0.0001;
|
||||||
|
const delta = Math.abs(rdist - rp.radius);
|
||||||
|
if (delta < RIPPLE_BAND) {
|
||||||
|
const ringT = 1 - delta / RIPPLE_BAND;
|
||||||
|
const s = ringT * ringT * rp.fade;
|
||||||
|
tx += (rdx / rdist) * s * RIPPLE_PUSH;
|
||||||
|
ty += (rdy / rdist) * s * RIPPLE_PUSH;
|
||||||
|
if (s > rippleStrength) rippleStrength = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d.ox += (tx - d.ox) * 0.22;
|
||||||
|
d.oy += (ty - d.oy) * 0.22;
|
||||||
|
|
||||||
|
const px = d.bx + d.ox;
|
||||||
|
const py = d.by + d.oy;
|
||||||
|
|
||||||
|
const visStrength = Math.min(1, strength + rippleStrength);
|
||||||
|
const alpha = BASE_ALPHA + (PEAK_ALPHA - BASE_ALPHA) * visStrength;
|
||||||
|
const size = 1 + visStrength * 1.6;
|
||||||
|
|
||||||
|
if (visStrength > 0.04) {
|
||||||
|
const blend = visStrength;
|
||||||
|
const r = Math.round(230 * (1 - blend) + 166 * blend);
|
||||||
|
const g = Math.round(230 * (1 - blend) + 227 * blend);
|
||||||
|
const b = Math.round(230 * (1 - blend) + 161 * blend);
|
||||||
|
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
||||||
|
} else {
|
||||||
|
ctx.fillStyle = `rgba(${BASE_RGB}, ${alpha})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.fillRect(px - size / 2, py - size / 2, size, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active) {
|
||||||
|
const grad = ctx.createRadialGradient(curX, curY, 0, curX, curY, RADIUS);
|
||||||
|
grad.addColorStop(0, `rgba(${ACCENT_RGB}, 0.10)`);
|
||||||
|
grad.addColorStop(1, `rgba(${ACCENT_RGB}, 0)`);
|
||||||
|
ctx.fillStyle = grad;
|
||||||
|
ctx.fillRect(curX - RADIUS, curY - RADIUS, RADIUS * 2, RADIUS * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let k = 0; k < rippleState.length; k++) {
|
||||||
|
const rp = rippleState[k];
|
||||||
|
if (rp.radius < 4) continue;
|
||||||
|
ctx.strokeStyle = `rgba(${ACCENT_RGB}, ${0.16 * rp.fade})`;
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(rp.x, rp.y, rp.radius, 0, Math.PI * 2);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initField(canvasId = 'field') {
|
||||||
|
if (started) return;
|
||||||
|
const el = document.getElementById(canvasId) as HTMLCanvasElement | null;
|
||||||
|
if (!el) return;
|
||||||
|
canvas = el;
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
if (!ctx) return;
|
||||||
|
started = true;
|
||||||
|
|
||||||
|
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
|
|
||||||
|
build();
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', (e) => onMove(e.clientX, e.clientY), { passive: true });
|
||||||
|
window.addEventListener('mouseleave', () => { active = false; });
|
||||||
|
window.addEventListener('click', (e) => spawnRipple(e.clientX, e.clientY));
|
||||||
|
window.addEventListener('touchmove', (e) => {
|
||||||
|
if (e.touches[0]) onMove(e.touches[0].clientX, e.touches[0].clientY);
|
||||||
|
}, { passive: true });
|
||||||
|
window.addEventListener('touchstart', (e) => {
|
||||||
|
if (e.touches[0]) spawnRipple(e.touches[0].clientX, e.touches[0].clientY);
|
||||||
|
}, { passive: true });
|
||||||
|
window.addEventListener('touchend', () => { active = false; });
|
||||||
|
window.addEventListener('resize', build);
|
||||||
|
window.addEventListener('scroll', () => {
|
||||||
|
// keep ripples / dots independent of page scroll — recompute baselines
|
||||||
|
}, { passive: true });
|
||||||
|
|
||||||
|
if (reduceMotion) {
|
||||||
|
if (!ctx) return;
|
||||||
|
ctx.fillStyle = `rgba(${BASE_RGB}, ${BASE_ALPHA})`;
|
||||||
|
for (const d of dots) ctx.fillRect(d.bx, d.by, 1, 1);
|
||||||
|
} else {
|
||||||
|
requestAnimationFrame(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
186
src/main.ts
186
src/main.ts
@@ -1,4 +1,5 @@
|
|||||||
import './style.css';
|
import './style.css';
|
||||||
|
import { initField, spawnRipple } from './field';
|
||||||
|
|
||||||
const COMMAND = 'ssh portfolio@keshavanand.net';
|
const COMMAND = 'ssh portfolio@keshavanand.net';
|
||||||
|
|
||||||
@@ -280,189 +281,6 @@ docsLink.addEventListener('click', (e) => {
|
|||||||
|
|
||||||
/* ---------- cursor-reactive dot field + click ripples ---------- */
|
/* ---------- cursor-reactive dot field + click ripples ---------- */
|
||||||
|
|
||||||
const canvas = document.getElementById('field') as HTMLCanvasElement;
|
initField('field');
|
||||||
const ctx = canvas.getContext('2d')!;
|
|
||||||
|
|
||||||
type Dot = { bx: number; by: number; ox: number; oy: number };
|
|
||||||
|
|
||||||
let dots: Dot[] = [];
|
|
||||||
let dpr = Math.max(1, window.devicePixelRatio || 1);
|
|
||||||
let w = 0;
|
|
||||||
let h = 0;
|
|
||||||
|
|
||||||
const SPACING = 26;
|
|
||||||
const RADIUS = 170;
|
|
||||||
const PUSH = 18;
|
|
||||||
|
|
||||||
let targetX = -9999;
|
|
||||||
let targetY = -9999;
|
|
||||||
let curX = -9999;
|
|
||||||
let curY = -9999;
|
|
||||||
let active = false;
|
|
||||||
|
|
||||||
type Ripple = { x: number; y: number; born: number };
|
|
||||||
const ripples: Ripple[] = [];
|
|
||||||
const RIPPLE_LIFE = 900;
|
|
||||||
const RIPPLE_MAX = 520;
|
|
||||||
const RIPPLE_BAND = 70;
|
|
||||||
const RIPPLE_PUSH = 36;
|
|
||||||
|
|
||||||
function build() {
|
|
||||||
dpr = Math.max(1, window.devicePixelRatio || 1);
|
|
||||||
w = window.innerWidth;
|
|
||||||
h = window.innerHeight;
|
|
||||||
canvas.width = Math.floor(w * dpr);
|
|
||||||
canvas.height = Math.floor(h * dpr);
|
|
||||||
canvas.style.width = w + 'px';
|
|
||||||
canvas.style.height = h + 'px';
|
|
||||||
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
||||||
|
|
||||||
dots = [];
|
|
||||||
const pad = SPACING;
|
|
||||||
for (let y = -pad; y < h + pad; y += SPACING) {
|
|
||||||
for (let x = -pad; x < w + pad; x += SPACING) {
|
|
||||||
dots.push({ bx: x, by: y, ox: 0, oy: 0 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onMove(x: number, y: number) {
|
|
||||||
targetX = x;
|
|
||||||
targetY = y;
|
|
||||||
active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function spawnRipple(x: number, y: number) {
|
|
||||||
ripples.push({ x, y, born: performance.now() });
|
|
||||||
if (ripples.length > 8) ripples.shift();
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('mousemove', (e) => onMove(e.clientX, e.clientY), { passive: true });
|
|
||||||
window.addEventListener('mouseleave', () => { active = false; });
|
|
||||||
window.addEventListener('click', (e) => spawnRipple(e.clientX, e.clientY));
|
|
||||||
window.addEventListener('touchmove', (e) => {
|
|
||||||
if (e.touches[0]) onMove(e.touches[0].clientX, e.touches[0].clientY);
|
|
||||||
}, { passive: true });
|
|
||||||
window.addEventListener('touchstart', (e) => {
|
|
||||||
if (e.touches[0]) spawnRipple(e.touches[0].clientX, e.touches[0].clientY);
|
|
||||||
}, { passive: true });
|
|
||||||
window.addEventListener('touchend', () => { active = false; });
|
|
||||||
window.addEventListener('resize', build);
|
|
||||||
|
|
||||||
build();
|
|
||||||
|
|
||||||
const BASE_RGB = '230, 230, 230';
|
|
||||||
const ACCENT_RGB = '166, 227, 161';
|
|
||||||
const BASE_ALPHA = 0.11;
|
|
||||||
const PEAK_ALPHA = 0.9;
|
|
||||||
|
|
||||||
function frame() {
|
|
||||||
const now = performance.now();
|
|
||||||
|
|
||||||
if (!active) {
|
|
||||||
targetX = -9999;
|
|
||||||
targetY = -9999;
|
|
||||||
}
|
|
||||||
curX += (targetX - curX) * 0.18;
|
|
||||||
curY += (targetY - curY) * 0.18;
|
|
||||||
|
|
||||||
for (let i = ripples.length - 1; i >= 0; i--) {
|
|
||||||
if (now - ripples[i].born > RIPPLE_LIFE) ripples.splice(i, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const rippleState = ripples.map((rp) => {
|
|
||||||
const p = (now - rp.born) / RIPPLE_LIFE;
|
|
||||||
return { x: rp.x, y: rp.y, radius: p * RIPPLE_MAX, fade: 1 - p };
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.clearRect(0, 0, w, h);
|
|
||||||
|
|
||||||
const r2 = RADIUS * RADIUS;
|
|
||||||
|
|
||||||
for (let i = 0; i < dots.length; i++) {
|
|
||||||
const d = dots[i];
|
|
||||||
|
|
||||||
const dx = d.bx - curX;
|
|
||||||
const dy = d.by - curY;
|
|
||||||
const d2 = dx * dx + dy * dy;
|
|
||||||
|
|
||||||
let tx = 0;
|
|
||||||
let ty = 0;
|
|
||||||
let strength = 0;
|
|
||||||
|
|
||||||
if (d2 < r2) {
|
|
||||||
const dist = Math.sqrt(d2) || 0.0001;
|
|
||||||
const t = 1 - dist / RADIUS;
|
|
||||||
strength = t * t;
|
|
||||||
tx = (dx / dist) * strength * PUSH;
|
|
||||||
ty = (dy / dist) * strength * PUSH;
|
|
||||||
}
|
|
||||||
|
|
||||||
let rippleStrength = 0;
|
|
||||||
for (let k = 0; k < rippleState.length; k++) {
|
|
||||||
const rp = rippleState[k];
|
|
||||||
const rdx = d.bx - rp.x;
|
|
||||||
const rdy = d.by - rp.y;
|
|
||||||
const rdist = Math.sqrt(rdx * rdx + rdy * rdy) || 0.0001;
|
|
||||||
const delta = Math.abs(rdist - rp.radius);
|
|
||||||
if (delta < RIPPLE_BAND) {
|
|
||||||
const ringT = 1 - delta / RIPPLE_BAND;
|
|
||||||
const s = ringT * ringT * rp.fade;
|
|
||||||
tx += (rdx / rdist) * s * RIPPLE_PUSH;
|
|
||||||
ty += (rdy / rdist) * s * RIPPLE_PUSH;
|
|
||||||
if (s > rippleStrength) rippleStrength = s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d.ox += (tx - d.ox) * 0.22;
|
|
||||||
d.oy += (ty - d.oy) * 0.22;
|
|
||||||
|
|
||||||
const px = d.bx + d.ox;
|
|
||||||
const py = d.by + d.oy;
|
|
||||||
|
|
||||||
const visStrength = Math.min(1, strength + rippleStrength);
|
|
||||||
const alpha = BASE_ALPHA + (PEAK_ALPHA - BASE_ALPHA) * visStrength;
|
|
||||||
const size = 1 + visStrength * 1.6;
|
|
||||||
|
|
||||||
if (visStrength > 0.04) {
|
|
||||||
const blend = visStrength;
|
|
||||||
const r = Math.round(230 * (1 - blend) + 166 * blend);
|
|
||||||
const g = Math.round(230 * (1 - blend) + 227 * blend);
|
|
||||||
const b = Math.round(230 * (1 - blend) + 161 * blend);
|
|
||||||
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
||||||
} else {
|
|
||||||
ctx.fillStyle = `rgba(${BASE_RGB}, ${alpha})`;
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.fillRect(px - size / 2, py - size / 2, size, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active) {
|
|
||||||
const grad = ctx.createRadialGradient(curX, curY, 0, curX, curY, RADIUS);
|
|
||||||
grad.addColorStop(0, `rgba(${ACCENT_RGB}, 0.10)`);
|
|
||||||
grad.addColorStop(1, `rgba(${ACCENT_RGB}, 0)`);
|
|
||||||
ctx.fillStyle = grad;
|
|
||||||
ctx.fillRect(curX - RADIUS, curY - RADIUS, RADIUS * 2, RADIUS * 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let k = 0; k < rippleState.length; k++) {
|
|
||||||
const rp = rippleState[k];
|
|
||||||
if (rp.radius < 4) continue;
|
|
||||||
ctx.strokeStyle = `rgba(${ACCENT_RGB}, ${0.16 * rp.fade})`;
|
|
||||||
ctx.lineWidth = 1;
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.arc(rp.x, rp.y, rp.radius, 0, Math.PI * 2);
|
|
||||||
ctx.stroke();
|
|
||||||
}
|
|
||||||
|
|
||||||
requestAnimationFrame(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!reduceMotion) {
|
|
||||||
requestAnimationFrame(frame);
|
|
||||||
} else {
|
|
||||||
ctx.fillStyle = `rgba(${BASE_RGB}, ${BASE_ALPHA})`;
|
|
||||||
for (const d of dots) ctx.fillRect(d.bx, d.by, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void caretEl;
|
void caretEl;
|
||||||
|
|||||||
Reference in New Issue
Block a user