Pregnancy Health Guide
A Trimester-by-Trimester Companion
Health Topics
Welcome!
Select a trimester and a health topic to view personalized guidance for your pregnancy journey. This guide covers key areas like nutrition, exercise, and what to expect at each stage.
Select a trimester and a health topic to view personalized guidance for your pregnancy journey.
"; downloadPdfBtn.disabled = true; return; } currentGuideData = GUIDE_DATA[currentTrimester][currentCategory]; contentTitleEl.textContent = currentGuideData.title; contentBodyEl.innerHTML = currentGuideData.content; downloadPdfBtn.disabled = false; }; // --- EVENT HANDLERS --- const handleTrimesterClick = (e) => { const button = e.target.closest('.tab-button'); if (button) { currentTrimester = button.dataset.trimester; document.querySelectorAll('#trimester-tabs .tab-button').forEach(btn => btn.classList.remove('active')); button.classList.add('active'); // Reset category and update UI currentCategory = ""; document.querySelectorAll('.category-button').forEach(btn => btn.classList.remove('active')); renderCategoryButtons(); updateContent(); } }; const handleCategoryClick = (e) => { const button = e.target.closest('.category-button'); if (button) { currentCategory = button.dataset.category; document.querySelectorAll('.category-button').forEach(btn => btn.classList.remove('active')); button.classList.add('active'); updateContent(); } }; const handlePdfDownload = () => { if (!currentGuideData) return; const { jsPDF } = window.jspdf; const doc = new jsPDF('p', 'mm', 'a4'); const primaryColor = '#db2777'; doc.setFillColor(primaryColor).rect(0, 0, 210, 30, 'F'); doc.setFont('helvetica', 'bold').setFontSize(20).setTextColor('#ffffff'); doc.text('Pregnancy Health Guide', 105, 18, { align: 'center' }); doc.setFontSize(22).setFont('helvetica', 'bold').setTextColor(primaryColor).text(currentGuideData.title, 14, 45); // Use jsPDF's built-in HTML renderer // It's basic but works for simple lists and paragraphs doc.html(currentGuideData.content, { callback: function (doc) { doc.save(`${currentGuideData.title}.pdf`); }, x: 14, y: 55, width: 180, windowWidth: 650 }); }; const addEventListeners = () => { trimesterTabs.addEventListener('click', handleTrimesterClick); downloadPdfBtn.addEventListener('click', handlePdfDownload); }; // --- KICK IT OFF --- init(); });