nomadweb/frontend/src/components/SleepWindDown.tsx
eric d857d5b9b2 Add 14 nomad tools in one batch: weekend, money, life, and safety kits.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-29 02:32:54 -05:00

45 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { useMemo, useState } from "react";
export default function SleepWindDown() {
const [wake, setWake] = useState(7);
const [cycles, setCycles] = useState(5);
const bed = useMemo(() => {
// 90min cycles + 15min fall asleep
const totalMin = cycles * 90 + 15;
let h = wake - totalMin / 60;
while (h < 0) h += 24;
const hh = Math.floor(h);
const mm = Math.round((h - hh) * 60);
return `${String(hh).padStart(2, "0")}:${String(mm).padStart(2, "0")}`;
}, [wake, cycles]);
return (
<section className="section kit-section" id="sleep">
<div className="container">
<div className="section-header reveal">
<span className="section-tag">😴 SLEEP</span>
<h2>睡眠周期入睡点</h2>
<p>按起床时间倒推,睡够完整周期少浑噩</p>
</div>
<div className="kit-card reveal">
<label className="kit-field"><span>想几点起 {String(wake).padStart(2, "0")}:00</span>
<input type="range" min={5} max={11} value={wake} onChange={(e) => setWake(+e.target.value)} />
</label>
<label className="kit-field"><span>睡眠周期 {cycles} × 90 分钟</span>
<input type="range" min={3} max={6} value={cycles} onChange={(e) => setCycles(+e.target.value)} />
</label>
<div className="kit-hero">
<span>🛏️</span>
<div>
<small>建议入睡</small>
<strong>{bed}</strong>
<p>含约 15 分钟入睡缓冲 · 共约 {cycles * 1.5} 小时</p>
</div>
</div>
</div>
</div>
</section>
);
}