mirror of
http://nostr-git-proxy.forgejo.svc.cluster.local/git/45387ca441053e230b2126802005eb03767ab59d84555e8bac86b6e7def14e27/myadhd
synced 2026-09-23 20:23:10 +00:00
feat(ui): add ambient body doubling pill and focus room feed
This commit is contained in:
parent
2077e9b1d7
commit
b39f7fdb81
3 changed files with 379 additions and 22 deletions
|
|
@ -28,6 +28,17 @@
|
||||||
<a href="#now" data-tab="now" class="tab" role="tab" id="tab-now" aria-selected="false" aria-controls="now">One thing</a>
|
<a href="#now" data-tab="now" class="tab" role="tab" id="tab-now" aria-selected="false" aria-controls="now">One thing</a>
|
||||||
<a href="#inbox" data-tab="inbox" class="tab" role="tab" id="tab-inbox" aria-selected="false" aria-controls="inbox">Brain dump</a>
|
<a href="#inbox" data-tab="inbox" class="tab" role="tab" id="tab-inbox" aria-selected="false" aria-controls="inbox">Brain dump</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
<div id="ambient-pill" class="ambient-pill" role="button" aria-expanded="false" tabindex="0">
|
||||||
|
<span class="pill-dot">🟢</span>
|
||||||
|
<span id="pill-count">..</span> with you
|
||||||
|
</div>
|
||||||
|
<div id="ambient-panel" class="ambient-panel" hidden>
|
||||||
|
<p class="ambient-panel-head">You are not alone. Across the world, people with ADHD are taking on tasks just like you.</p>
|
||||||
|
<ul id="ambient-feed" class="ambient-feed">
|
||||||
|
<!-- feed items added via JS -->
|
||||||
|
</ul>
|
||||||
|
<div id="ambient-cheer-btn" class="ambient-cheer" role="button" tabindex="0">Send a quiet cheer 🎉</div>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -989,4 +1100,115 @@
|
||||||
if(timerTabBtn) timerTabBtn.click();
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -381,3 +381,127 @@ input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-off
|
||||||
0% { fill: #d97706; }
|
0% { fill: #d97706; }
|
||||||
100% { fill: #f59e0b; }
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue