Baby Growth & Development Tracker

Baby Growth & Development Tracker

Add a New Entry

Log your baby's measurements and any new milestones they've reached.

${new Date(m.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}

`).join(''); }; const downloadPDF = () => { if (trackerData.entries.length === 0) { alert('No data to generate a report.'); return; } const dashboardContent = document.getElementById('dashboard-content'); window.html2canvas(dashboardContent, { scale: 2, backgroundColor: '#ffffff' }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfMargin = 40; const contentWidth = pdfWidth - (pdfMargin * 2); const imgHeight = canvas.height * contentWidth / canvas.width; pdf.setFontSize(22).setFont('helvetica', 'bold'); pdf.text(`${trackerData.name}'s Growth Report`, pdfWidth / 2, pdfMargin, { align: 'center' }); pdf.addImage(imgData, 'PNG', pdfMargin, pdfMargin + 20, contentWidth, imgHeight); pdf.save(`${trackerData.name.replace(/\s/g, '_')}_Growth_Report.pdf`); }); }; // --- Initialization --- const initialize = () => { loadData(); populateMilestones(); renderDashboard(); logForm.addEventListener('submit', addLogEntry); downloadPdfBtn.addEventListener('click', downloadPDF); logDateInput.valueAsDate = new Date(); }; initialize(); }); function switchTab(tabId) { document.getElementById('log-tab').style.display = (tabId === 'log') ? 'block' : 'none'; document.getElementById('dashboard-tab').style.display = (tabId === 'dashboard') ? 'block' : 'none'; document.getElementById('tab-log-btn').classList.toggle('active', tabId === 'log'); document.getElementById('tab-dashboard-btn').classList.toggle('active', tabId === 'dashboard'); }
Scroll to Top