diff --git a/site/index.html b/site/index.html index 527a590..2a60f09 100644 --- a/site/index.html +++ b/site/index.html @@ -28,6 +28,17 @@ One thing Brain dump + +
@@ -101,7 +112,7 @@ - +

Tip: 25 minutes is a suggestion, not a law. The best length is the one you'll actually start.

- - + +

Interval Grounding

Time blindness? A soft chime will ground you every few minutes to pull you out of rabbit holes.

- +
diff --git a/site/static/app.js b/site/static/app.js index 6fb0c31..4ed53ad 100644 --- a/site/static/app.js +++ b/site/static/app.js @@ -752,35 +752,35 @@ inboxItems.forEach(function (item, i) { var li = document.createElement('li'); li.className = 'step'; - + var textDiv = document.createElement('div'); textDiv.className = 'step-text'; textDiv.textContent = item; - + var editInput = document.createElement('input'); editInput.type = 'text'; editInput.className = 'step-edit-input sr-only'; editInput.value = item; - + textDiv.addEventListener('click', function () { textDiv.classList.add('sr-only'); editInput.classList.remove('sr-only'); editInput.focus(); }); - + function commitEdit() { var v = editInput.value.trim(); if (!v) { inboxItems.splice(i, 1); } else { inboxItems[i] = v; } saveInbox(); } - + editInput.addEventListener('blur', commitEdit); editInput.addEventListener('keydown', function(e) { if (e.key === 'Enter') commitEdit(); }); var actionsDiv = document.createElement('div'); actionsDiv.className = 'row gap'; - + var breakBtn = document.createElement('button'); breakBtn.className = 'btn ghost small'; breakBtn.textContent = 'break this down'; @@ -791,7 +791,7 @@ showTab('breaker'); $('#breaker-form').dispatchEvent(new Event('submit')); }); - + var delBtn = document.createElement('button'); delBtn.className = 'btn ghost small'; delBtn.textContent = '×'; @@ -855,6 +855,117 @@ } }); + + // ========================================== + // AMBIENT BODY DOUBLING (Feature C) + // ========================================== + var pill = $('#ambient-pill'); + var panel = $('#ambient-panel'); + var countEl = $('#pill-count'); + var feedEl = $('#ambient-feed'); + var cheerBtn = $('#ambient-cheer-btn'); + + var fakeBaseCount = 1400; // baseline + var feedEvents = [ + "Someone just finished a 15m focus round", + "Someone broke down an intimidating task", + "Someone took a mindful breath", + "Someone swept their inbox clean", + "Someone just started a timer", + "Someone released a stale task to the universe", + "Someone decided to focus on just One Thing" + ]; + + function getCircadianOffset() { + // Generate a smooth hour-based wave offset so the fake count feels organic + var hour = new Date().getHours(); + var minute = new Date().getMinutes(); + var time = hour + (minute/60); + // peak at noon and 8pm roughly + return Math.floor((Math.sin(time * 0.5) * 300) + (Math.cos(time * 0.8) * 150)); + } + + function updateCount() { + if (!countEl) return; + var base = fakeBaseCount + getCircadianOffset(); + // small jitter + var jitter = Math.floor(Math.random() * 15) - 7; + var finalCount = base + jitter; + if (finalCount < 200) finalCount = 200; // min floor + countEl.textContent = finalCount.toLocaleString(); + } + + function addFeedItem(text) { + if (!feedEl) return; + var li = document.createElement('li'); + li.className = 'feed-item'; + li.textContent = text; + feedEl.prepend(li); + // keep only top 4 + if (feedEl.children.length > 4) { + feedEl.removeChild(feedEl.lastChild); + } + } + + function feedLoop() { + // random feed inject every 8-25 seconds + var delay = 8000 + Math.random() * 17000; + setTimeout(function() { + var evt = feedEvents[Math.floor(Math.random() * feedEvents.length)]; + addFeedItem(evt); + updateCount(); + feedLoop(); + }, delay); + } + + if (pill) { + updateCount(); + addFeedItem("You joined the focus room"); + feedLoop(); + + // click to toggle panel + pill.addEventListener('click', function(e) { + e.stopPropagation(); + var expanded = pill.getAttribute('aria-expanded') === 'true'; + pill.setAttribute('aria-expanded', !expanded); + panel.hidden = expanded; + }); + + // click outside to close + document.addEventListener('click', function(e) { + if (!panel.hidden && !panel.contains(e.target) && !pill.contains(e.target)) { + panel.hidden = true; + pill.setAttribute('aria-expanded', 'false'); + } + }); + + pill.addEventListener('keydown', function(e) { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + pill.click(); + } + }); + } + + if (cheerBtn) { + cheerBtn.addEventListener('click', function() { + addFeedItem("You sent a quiet cheer 🎉"); + cheerBtn.textContent = "Sent!"; + cheerBtn.style.pointerEvents = "none"; + setTimeout(function() { + cheerBtn.textContent = "Send a quiet cheer 🎉"; + cheerBtn.style.pointerEvents = "auto"; + }, 3000); + party.confetti(cheerBtn, { count: 15, spread: 30 }); + }); + cheerBtn.addEventListener('keydown', function(e) { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + cheerBtn.click(); + } + }); + } + })(); @@ -894,13 +1005,13 @@ if(!text) return; clearInterval(breathInterval); let cycle = 0; - + // Physiological Sigh timing matcher (approximate for the 8s CSS animation) // 0-2s: Inhale // 2-3.5s: 2nd Inhale // 3.5-4s: Hold // 4-8s: Long slow exhale - + const updateText = () => { cycle = (cycle + 1) % 8; if (cycle < 2) text.textContent = "Inhale..."; @@ -908,12 +1019,12 @@ else if (cycle < 4) text.textContent = "Hold..."; else text.textContent = "Slooow Exhale..."; }; - + updateText(); // immediate run breathInterval = setInterval(() => { - if (modal.hidden || p1.hidden) { - clearInterval(breathInterval); - return; + if (modal.hidden || p1.hidden) { + clearInterval(breathInterval); + return; } updateText(); }, 1000); @@ -933,13 +1044,13 @@ // Proceed from phase 1 to 2 $('#unstuck-next-1').addEventListener('click', () => { - p1.hidden = true; + p1.hidden = true; p2.hidden = false; }); // Proceed from phase 2 to 3 $('#unstuck-next-2').addEventListener('click', () => { - p2.hidden = true; + p2.hidden = true; p3.hidden = false; }); @@ -947,18 +1058,18 @@ startTimerBtn.addEventListener('click', () => { startTimerBtn.hidden = true; let timeLeft = 180; // 3 minutes - + unstuckInterval = setInterval(() => { timeLeft--; const m = Math.floor(timeLeft / 60).toString().padStart(2, '0'); const s = (timeLeft % 60).toString().padStart(2, '0'); timerDisplay.textContent = `${m}:${s}`; - + if (timeLeft <= 0) { clearInterval(unstuckInterval); timerDisplay.textContent = "Done!"; finishBtn.hidden = false; - + // Play success tone if soundscapes/audio is available globally try { if (window.AudioContext && !window.audioCtx) { @@ -989,4 +1100,115 @@ if(timerTabBtn) timerTabBtn.click(); }); + + // ========================================== + // AMBIENT BODY DOUBLING (Feature C) + // ========================================== + var pill = $('#ambient-pill'); + var panel = $('#ambient-panel'); + var countEl = $('#pill-count'); + var feedEl = $('#ambient-feed'); + var cheerBtn = $('#ambient-cheer-btn'); + + var fakeBaseCount = 1400; // baseline + var feedEvents = [ + "Someone just finished a 15m focus round", + "Someone broke down an intimidating task", + "Someone took a mindful breath", + "Someone swept their inbox clean", + "Someone just started a timer", + "Someone released a stale task to the universe", + "Someone decided to focus on just One Thing" + ]; + + function getCircadianOffset() { + // Generate a smooth hour-based wave offset so the fake count feels organic + var hour = new Date().getHours(); + var minute = new Date().getMinutes(); + var time = hour + (minute/60); + // peak at noon and 8pm roughly + return Math.floor((Math.sin(time * 0.5) * 300) + (Math.cos(time * 0.8) * 150)); + } + + function updateCount() { + if (!countEl) return; + var base = fakeBaseCount + getCircadianOffset(); + // small jitter + var jitter = Math.floor(Math.random() * 15) - 7; + var finalCount = base + jitter; + if (finalCount < 200) finalCount = 200; // min floor + countEl.textContent = finalCount.toLocaleString(); + } + + function addFeedItem(text) { + if (!feedEl) return; + var li = document.createElement('li'); + li.className = 'feed-item'; + li.textContent = text; + feedEl.prepend(li); + // keep only top 4 + if (feedEl.children.length > 4) { + feedEl.removeChild(feedEl.lastChild); + } + } + + function feedLoop() { + // random feed inject every 8-25 seconds + var delay = 8000 + Math.random() * 17000; + setTimeout(function() { + var evt = feedEvents[Math.floor(Math.random() * feedEvents.length)]; + addFeedItem(evt); + updateCount(); + feedLoop(); + }, delay); + } + + if (pill) { + updateCount(); + addFeedItem("You joined the focus room"); + feedLoop(); + + // click to toggle panel + pill.addEventListener('click', function(e) { + e.stopPropagation(); + var expanded = pill.getAttribute('aria-expanded') === 'true'; + pill.setAttribute('aria-expanded', !expanded); + panel.hidden = expanded; + }); + + // click outside to close + document.addEventListener('click', function(e) { + if (!panel.hidden && !panel.contains(e.target) && !pill.contains(e.target)) { + panel.hidden = true; + pill.setAttribute('aria-expanded', 'false'); + } + }); + + pill.addEventListener('keydown', function(e) { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + pill.click(); + } + }); + } + + if (cheerBtn) { + cheerBtn.addEventListener('click', function() { + addFeedItem("You sent a quiet cheer 🎉"); + cheerBtn.textContent = "Sent!"; + cheerBtn.style.pointerEvents = "none"; + setTimeout(function() { + cheerBtn.textContent = "Send a quiet cheer 🎉"; + cheerBtn.style.pointerEvents = "auto"; + }, 3000); + party.confetti(cheerBtn, { count: 15, spread: 30 }); + }); + cheerBtn.addEventListener('keydown', function(e) { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + cheerBtn.click(); + } + }); + } + })(); diff --git a/site/static/style.css b/site/static/style.css index fc69c9d..6c2f22c 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -381,3 +381,127 @@ input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-off 0% { fill: #d97706; } 100% { fill: #f59e0b; } } + + +/* Ambient Doubling */ +.ambient-pill { + position: absolute; + right: var(--spacing); + top: 50%; + transform: translateY(-50%); + background: var(--surface0); + border: 1px solid var(--surface1); + padding: 4px 12px; + border-radius: 20px; + font-size: 0.85rem; + font-weight: 500; + color: var(--text-muted); + cursor: pointer; + display: flex; + align-items: center; + gap: 6px; + box-shadow: 0 2px 4px rgba(0,0,0,0.2); + transition: all 0.2s; + user-select: none; +} +.ambient-pill:hover, .ambient-pill:focus-visible { + background: var(--surface1); + color: var(--text-main); +} +.pill-dot { + font-size: 0.6rem; + animation: slow-pulse 4s ease-in-out infinite alternate; +} +@keyframes slow-pulse { + 0% { opacity: 0.4; } + 100% { opacity: 1; } +} + +.ambient-panel { + position: absolute; + right: var(--spacing); + top: calc(100% + 4px); + width: 320px; + background: var(--surface0); + border: 1px solid var(--surface1); + border-radius: 12px; + padding: 16px; + box-shadow: 0 8px 24px rgba(0,0,0,0.4); + z-index: 100; + display: flex; + flex-direction: column; + gap: 12px; +} +.ambient-panel[hidden] { + display: none !important; +} +.ambient-panel-head { + font-size: 0.9rem; + color: var(--text-muted); + line-height: 1.4; + margin: 0; + padding-bottom: 8px; + border-bottom: 1px solid var(--surface1); +} +.ambient-feed { + list-style: none; + padding: 0; + margin: 0; + display: flex; + flex-direction: column; + gap: 8px; + max-height: 150px; + overflow: hidden; + position: relative; +} +.ambient-feed::after { + content: ""; + position: absolute; + bottom: 0; left: 0; right: 0; + height: 40px; + background: linear-gradient(transparent, var(--surface0)); + pointer-events: none; +} +.feed-item { + font-size: 0.85rem; + color: var(--text-main); + animation: slide-down 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; + opacity: 0; + transform: translateY(-10px); +} +@keyframes slide-down { + to { transform: translateY(0); opacity: 1; } +} +.ambient-cheer { + margin-top: 4px; + background: var(--surface1); + border: 1px solid var(--surface2); + border-radius: 8px; + padding: 10px; + text-align: center; + font-size: 0.9rem; + font-weight: 500; + cursor: pointer; + transition: all 0.2s; + user-select: none; +} +.ambient-cheer:hover, .ambient-cheer:focus-visible { + background: var(--accent); + color: var(--bg); + border-color: var(--accent); +} +.ambient-cheer:active { + transform: scale(0.97); +} + +@media (max-width: 900px) { + .ambient-pill { + position: static; + transform: none; + margin-left: auto; + } + .top { + flex-wrap: wrap; + gap: 12px; + } +}