Spaces:
Running
Running
ชื่อโปรเจกต์: Oura Ring Dashboard Mockup (Web Version)เป้าหมาย: สร้างไฟล์ HTML5 เดี่ยว (.html) ที่ประกอบด้วย HTML, CSS, และ JavaScript ทั้งหมด เพื่อจำลองหน้า Dashboard หลักของ Oura Ring บนเว็บ (คล้ายกับ "Oura on the Web") โดยเน้นการแสดงผล คะแนนหลัก 3 คะแนน และ แนวโน้มข้อมูลรายวัน/รายสัปดาห์ อย่างชัดเจนและสวยงาม📝 รายละเอียด Prompt1. โครงสร้างไฟล์ (File Structure)ต้องเป็น ไฟล์ HTML5 เดี่ยว (index.html หรือชื่ออื่นตามสะดวก)HTML, CSS, และ JavaScript ทั้งหมดต้องอยู่ในไฟล์เดียวCSS ต้องอยู่ในแท็ก <style> ภายใน <head> (ใช้ CSS Variables และ Flexbox/Grid เพื่อความทันสมัย).JavaScript ต้องอยู่ในแท็ก <script> ภายใน <body> หรือ <head> (เน้นการสร้าง Chart แบบง่ายๆ).ห้ามใช้ Library/Framework ภายนอก (เช่น React, Vue, jQuery, หรือ Chart.js/D3.js) ต้องใช้ Vanilla JS เท่านั้น.2. ข้อมูลจำลอง (Mock Data)สร้างโครงสร้างข้อมูล JavaScript เพื่อจำลองข้อมูลสุขภาพรายวัน/รายสัปดาห์ (อย่างน้อย 7 วัน) โดยเน้นไปที่ Metrics หลักของ Oura:FieldDescriptionTypeDaily ExampleWeekly Array Example (7 days)dateวันที่ของข้อมูลString"2025-11-15"["11/9", "11/10", ...]readinessScoreคะแนนความพร้อม (0-100)Number85[75, 88, 65, 90, 85, 70, 92]sleepScoreคะแนนการนอน (0-100)Number90[80, 91, 72, 85, 90, 75, 95]activityScoreคะแนนกิจกรรม (0-100)Number78[85, 75, 90, 80, 78, 92, 60]rhrอัตราการเต้นของหัวใจขณะพัก (Resting HR)Number52[55, 50, 58, 51, 52, 57, 49]hrvความแปรปรวนของอัตราการเต้นของหัวใจ (HRV)Number80[65, 85, 50, 90, 80, 60, 95]tempDeltaอุณหภูมิร่างกายที่เปลี่ยนแปลงจาก BaselineNumber$-0.1$[0.2, -0.1, 0.5, 0.0, -0.2, 0.1, -0.3]sleepDurationระยะเวลาการนอนทั้งหมด (นาที)Number450 (7.5 ชม.)[400, 480, 390, 450, 470, 420, 500]3. องค์ประกอบของ Dashboard (Dashboard Components)Dashboard ต้องแบ่งออกเป็น 3 ส่วนหลัก (หรือแท็บ: Today, Vitals, Trends) โดยเน้นการแสดงผลที่หน้า Today และ Trends:A. Today's View (มุมมองประจำวัน)Header Card: แสดงวันที่ปัจจุบันและ 3 คะแนนหลัก พร้อมสีตามช่วงคะแนน (Optimal: เขียว >85, Good: เหลือง 70-84, Pay Attention: แดง <70).Readiness ScoreSleep ScoreActivity ScoreInsight Card: ข้อความสรุปสั้นๆ (เช่น "Your RHR was lower than usual, indicating strong recovery." หรือ "Lower Readiness today. Focus on light activity.")B. Sleep Breakdown Card (รายละเอียดการนอนหลับ)แสดงผล Sleep Score (ตัวเลขและกราฟวงกลม/วงแหวน)Sub-Metrics: แสดงค่าตัวเลขสำหรับ:Total Sleep Duration (sleepDuration)Time in Bed (สมมติ: Total Sleep + 30 นาที)Efficiency (สมมติ: sleepScore / 100)Graph Mockup: จำลองกราฟแท่งแสดง Sleep Stages (Deep, REM, Light) แบบง่ายๆ (ไม่ต้องใช้ข้อมูลจริง).C. Readiness & Vitals Trends (แนวโน้มและสัญญาณชีพ)Trend Chart 1: Readiness & RHR: กราฟเส้นคู่สำหรับ 7 วันล่าสุด เพื่อเปรียบเทียบ readinessScore และ rhr (แสดงความสัมพันธ์แบบผกผัน: RHR ต่ำ = Readiness สูง).ใช้ JavaScript สร้างเส้นกราฟ/จุด ด้วยการจัดการ DOM/SVG/Canvas อย่างง่ายTrend Chart 2: HRV & Temperature: กราฟเส้นคู่สำหรับ 7 วันล่าสุด เพื่อเปรียบเทียบ hrv และ tempDelta (แสดงความสัมพันธ์: HRV สูง/Temp Delta ใกล้ 0 = Recovery ดี).4. คุณสมบัติการโต้ตอบ (Interactive Features)Date Picker Mockup: มีปุ่ม/ฟังก์ชัน Previous Day และ Next Day (จำลองการเปลี่ยนข้อมูลในหน้า Today's View โดยการสลับ Index ใน Mock Data Array).Toggle/Switch Mockup: ปุ่มจำลอง (เช่น "Show 7-Day / Show 30-Day") ใต้กราฟ Trends ที่ปรับเปลี่ยน Label/Scale ของกราฟให้ดูเหมือนเปลี่ยนมุมมอง.5. ข้อจำกัดด้านการออกแบบ (Design Constraints)เน้นความสะอาด (Clean Design): ใช้โทนสีเข้ม (Dark Mode) คล้าย Oura App หรือโทนสีอ่อนที่สบายตา.ใช้ Emoji: ใช้ Emoji (เช่น 🌙, 🔋, ✨) เพื่อช่วยนำทางข้อมูลแทนไอคอนที่ซับซ้อน.Responsive Mockup: การจัดวางควรดูดีทั้งบนหน้าจอ Desktop และเมื่อจำลองบน Mobile View (ใช้ Media Queries หรือ Flexbox/Grid).🚀 สิ่งที่ต้องการจากการตอบกลับโค้ด HTML5 ที่ทำงานได้เต็มรูปแบบ (Full working HTML5 file) พร้อมข้อมูลจำลองและฟังก์ชัน JavaScript ข้างต้น เพื่อเป็น Mockup Dashboard ของ Oura Ring ที่มีความคล้ายคลึงและสื่อถึงข้อมูลหลักของอุปกรณ์ได้อย่างครบถ้วน
152c583 verified Download components/scoreCard.js from CSNET/oura-health-hub: direct link, hf CLI and curl.
- Browser
- Download file 6.65 kB
-
https://huggingface.co/spaces/CSNET/oura-health-hub/resolve/main/components/scoreCard.js
- Command line
-
hf download hf://spaces/CSNET/oura-health-hub/components/scoreCard.js
-
curl -L -o scoreCard.js https://huggingface.co/spaces/CSNET/oura-health-hub/resolve/main/components/scoreCard.js
6.65 kB
| class ScoreCard extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.score = this.getAttribute('score') || 85; | |
| this.title = this.getAttribute('title') || 'Score'; | |
| this.icon = this.getAttribute('icon') || 'star'; | |
| this.status = this.getAttribute('status') || 'Good'; | |
| this.color = this.getAttribute('color') || 'green'; | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .card { | |
| background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); | |
| border: 1px solid rgba(255, 255, 255, 0.1); | |
| border-radius: 1rem; | |
| padding: 1.5rem; | |
| transition: all 0.3s ease; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .card:hover { | |
| transform: translateY(-4px); | |
| box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3); | |
| border-color: rgba(255, 255, 255, 0.2); | |
| } | |
| .card-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 1.5rem; | |
| } | |
| .card-title { | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| font-weight: 600; | |
| color: #94a3b8; | |
| font-size: 0.875rem; | |
| text-transform: uppercase; | |
| letter-spacing: 0.05em; | |
| } | |
| .card-icon { | |
| width: 20px; | |
| height: 20px; | |
| } | |
| .score-display { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| margin-bottom: 1rem; | |
| } | |
| .score-ring-container { | |
| position: relative; | |
| width: 120px; | |
| height: 120px; | |
| } | |
| .score-ring { | |
| transform: rotate(-90deg); | |
| transition: stroke-dashoffset 0.5s ease-in-out; | |
| } | |
| .score-ring-bg { | |
| stroke: rgba(255, 255, 255, 0.1); | |
| } | |
| .score-value { | |
| position: absolute; | |
| top: 50%; | |
| left: 50%; | |
| transform: translate(-50%, -50%); | |
| font-size: 2rem; | |
| font-weight: 700; | |
| color: white; | |
| } | |
| .status-badge { | |
| text-align: center; | |
| font-size: 0.875rem; | |
| font-weight: 500; | |
| padding: 0.25rem 0.75rem; | |
| border-radius: 9999px; | |
| display: inline-block; | |
| } | |
| .status-optimal { | |
| background: rgba(16, 185, 129, 0.2); | |
| color: #10b981; | |
| } | |
| .status-good { | |
| background: rgba(245, 158, 11, 0.2); | |
| color: #f59e0b; | |
| } | |
| .status-attention { | |
| background: rgba(239, 68, 68, 0.2); | |
| color: #ef4444; | |
| } | |
| .color-optimal { | |
| stroke: #10b981; | |
| } | |
| .color-good { | |
| stroke: #f59e0b; | |
| } | |
| .color-attention { | |
| stroke: #ef4444; | |
| } | |
| </style> | |
| <div class="card"> | |
| <div class="card-header"> | |
| <div class="card-title"> | |
| <i data-feather="${this.icon}" class="card-icon"></i> | |
| <span>${this.title}</span> | |
| </div> | |
| </div> | |
| <div class="score-display"> | |
| <div class="score-ring-container"> | |
| <svg width="120" height="120"> | |
| <circle class="score-ring-bg" cx="60" cy="60" r="54" fill="none" stroke-width="12"></circle> | |
| <circle class="score-ring color-${this.color}" cx="60" cy="60" r="54" fill="none" stroke-width="12" | |
| stroke-dasharray="${2 * Math.PI * 54}" | |
| stroke-dashoffset="${2 * Math.PI * 54 * (1 - this.score / 100)}"></circle> | |
| </svg> | |
| <div class="score-value">${this.score}</div> | |
| </div> | |
| </div> | |
| <div style="text-align: center;"> | |
| <span class="status-badge status-${this.status.toLowerCase().replace(' ', '-')}">${this.status}</span> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| static get observedAttributes() { | |
| return ['score', 'status', 'color']; | |
| } | |
| attributeChangedCallback(name, oldValue, newValue) { | |
| if (name === 'score' && this.shadowRoot) { | |
| const ring = this.shadowRoot.querySelector('.score-ring'); | |
| const value = this.shadowRoot.querySelector('.score-value'); | |
| const radius = 54; | |
| const circumference = 2 * Math.PI * radius; | |
| if (ring) { | |
| ring.style.strokeDashoffset = circumference * (1 - newValue / 100); | |
| } | |
| if (value) { | |
| value.textContent = newValue; | |
| } | |
| } | |
| if (name === 'status' && this.shadowRoot) { | |
| const badge = this.shadowRoot.querySelector('.status-badge'); | |
| if (badge) { | |
| badge.textContent = newValue; | |
| badge.className = `status-badge status-${newValue.toLowerCase().replace(' ', '-')}`; | |
| } | |
| } | |
| if (name === 'color' && this.shadowRoot) { | |
| const ring = this.shadowRoot.querySelector('.score-ring'); | |
| if (ring) { | |
| ring.className = `score-ring color-${newValue}`; | |
| } | |
| } | |
| } | |
| } | |
| customElements.define('score-card', ScoreCard); |