Spaces:
Running
Running
File size: 12,418 Bytes
f93e15c 9539581 f93e15c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | ```html
<!DOCTYPE html>
<html lang="th" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>การนอน - ชีพจร</title>
<link rel="icon" type="image/x-icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌿</text></svg>">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-gray-900 text-white font-sans pb-20">
<!-- Main Container -->
<div class="min-h-screen bg-gradient-to-br from-gray-900 via-gray-800 to-gray-900">
<!-- Header -->
<header class="px-4 pt-12 pb-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-2xl font-bold bg-gradient-to-r from-blue-400 to-indigo-500 bg-clip-text text-transparent">
การนอนหลับ
</h1>
<p class="text-gray-400 text-sm mt-1">วิเคราะห์คุณภาพการนอนของคุณ 🌙</p>
</div>
<button onclick="window.location.href='index.html'" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center">
<i data-feather="arrow-left" class="w-5 h-5"></i>
</button>
</div>
</header>
<!-- Sleep Score -->
<section class="px-4 mb-6">
<div class="glass-card rounded-2xl p-6 border border-gray-700/50 text-center">
<div class="w-24 h-24 mx-auto mb-4 relative">
<vital-circle
type="sleep"
value="78"
color="from-blue-400 to-indigo-500"
label="คะแนนการนอน">
</vital-circle>
</div>
<p class="text-gray-400 text-sm">คุณภาพการนอนอยู่ในระดับดี</p>
<p class="text-xs text-gray-500 mt-1">อัพเดทล่าสุด: 07:00 น.</p>
</div>
</section>
<!-- Sleep Stages Chart -->
<section class="px-4 mb-6">
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<i data-feather="bar-chart-2" class="w-5 h-5 text-blue-400"></i>
ระยะการนอนเมื่อคืน
</h3>
<canvas id="sleepStagesChart" height="200"></canvas>
<div class="grid grid-cols-3 gap-3 mt-4 text-center">
<div>
<p class="text-xs text-gray-400">ลึก</p>
<p class="text-lg font-bold text-blue-400">2.5 ชม.</p>
</div>
<div>
<p class="text-xs text-gray-400">REM</p>
<p class="text-lg font-bold text-purple-400">1.8 ชม.</p>
</div>
<div>
<p class="text-xs text-gray-400">ตื้น</p>
<p class="text-lg font-bold text-gray-400">3.2 ชม.</p>
</div>
</div>
</div>
</section>
<!-- Sleep Trends -->
<section class="px-4 mb-6">
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<i data-feather="trending-up" class="w-5 h-5 text-green-400"></i>
เทรนด์การนอน 7 วัน
</h3>
<canvas id="sleepTrendChart" height="120"></canvas>
</div>
</section>
<!-- Sleep Insights -->
<section class="px-4 mb-6">
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<i data-feather="lightbulb" class="w-5 h-5 text-yellow-400"></i>
ข้อมูลเชิงลึก
</h3>
<div class="space-y-3">
<div class="p-3 bg-blue-500/10 border border-blue-500/30 rounded-xl">
<div class="flex items-center gap-3">
<div class="w-8 h-8 bg-blue-500 rounded-lg flex items-center justify-center">
<i data-feather="clock" class="w-4 h-4 text-white"></i>
</div>
<div class="flex-1">
<p class="text-sm font-medium">เวลานอนสม่ำเสมอ</p>
<p class="text-xs text-gray-400">คุณนอนตรงเวลา 6 จาก 7 วันล่าสุด</p>
</div>
<span class="text-xs text-green-400">ดีมาก</span>
</div>
</div>
<div class="p-3 bg-orange-500/10 border border-orange-500/30 rounded-xl">
<div class="flex items-center gap-3">
<div class="w-8 h-8 bg-orange-500 rounded-lg flex items-center justify-center">
<i data-feather="coffee" class="w-4 h-4 text-white"></i>
</div>
<div class="flex-1">
<p class="text-sm font-medium">คาเฟอีนก่อนนอน</p>
<p class="text-xs text-gray-400">พบว่าดื่มกาแฟหลัง 15:00 วันนี้</p>
</div>
<span class="text-xs text-orange-400">ควรหลีกเลี่ยง</span>
</div>
</div>
</div>
</div>
</section>
<!-- Bedtime Routine -->
<section class="px-4 mb-6">
<div class="glass-card rounded-2xl p-5 border border-gray-700/50">
<h3 class="text-lg font-semibold mb-4 flex items-center gap-2">
<i data-feather="moon" class="w-5 h-5 text-indigo-400"></i>
กิจวัตรก่อนนอน
</h3>
<div class="space-y-2">
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
<span class="text-sm">งดหน้าจอ 1 ชม. ก่อนนอน</span>
</label>
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
<span class="text-sm">ดื่มนมอุ่น</span>
</label>
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
<span class="text-sm">อ่านหนังสือ 15 นาที</span>
</label>
<label class="flex items-center gap-3 p-2 rounded-lg hover:bg-gray-800/30">
<input type="checkbox" class="w-4 h-4 text-blue-600 rounded">
<span class="text-sm">ฝึกสมาธิ 5 นาที</span>
</label>
</div>
</div>
</section>
</div>
<!-- Bottom Navigation -->
<main-navbar></main-navbar>
<!-- Scripts -->
<script src="components/navbar.js"></script>
<script src="components/vital-circle.js"></script>
<script src="script.js"></script>
<script>
// Initialize sleep charts
document.addEventListener('DOMContentLoaded', function() {
// Sleep Stages Chart
const stagesCtx = document.getElementById('sleepStagesChart');
if (stagesCtx) {
new Chart(stagesCtx, {
type: 'doughnut',
data: {
labels: ['หลับลึก', 'หลับ REM', 'หลับตื้น', 'ตื่น'],
datasets: [{
data: [25, 22, 45, 8],
backgroundColor: [
'#3b82f6',
'#a855f7',
'#9ca3af',
'#ef4444'
],
borderWidth: 0
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'bottom',
labels: {
padding: 15,
font: { size: 12, family: 'Prompt' },
color: '#e5e7eb'
}
}
}
}
});
}
// Sleep Trend Chart
const trendCtx = document.getElementById('sleepTrendChart');
if (trendCtx) {
new Chart(trendCtx, {
type: 'line',
data: {
labels: ['จ', 'อ', 'พ', 'พฤ', 'ศ', 'ส', 'อา'],
datasets: [{
label: 'ชั่วโมงการนอน',
data: [7.5, 6.8, 8.2, 7.1, 7.8, 8.5, 7.2],
borderColor: '#60a5fa',
backgroundColor: 'rgba(96, 165, 250, 0.1)',
tension: 0.4,
fill: true,
pointRadius: 4,
pointBackgroundColor: '#60a5fa'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false }
},
scales: {
y: {
beginAtZero: true,
max: 10,
ticks: {
color: '#9ca3af'
},
grid: {
color: 'rgba(75, 85, 99, 0.3)'
}
},
x: {
ticks: {
color: '#9ca3af'
},
grid: {
display: false
}
}
}
}
});
}
// Set active page in navbar
const navbar = document.querySelector('main-navbar');
if (navbar) {
navbar.setActivePage('sleep');
}
// Save to localStorage
localStorage.setItem('lastSleepView', new Date().toISOString());
});
</script>
<script>feather.replace();</script>
</body>
</html>
>>>>>>> REPLACE |