Trimester-Specific Pregnancy Health Guide

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.

Visits become more frequent, moving to every two weeks, and then weekly in the final month.

  • Continued Monitoring: Checking your blood pressure, weight, and baby's heartbeat and position.
  • Group B Strep Test: A vaginal and rectal swab done around 36-37 weeks.
  • Cervical Checks: Your doctor may start checking your cervix for dilation and effacement as your due date approaches.
  • Discussing Birth Plan: A good time to discuss your preferences for labor and delivery.
` } } }; // --- ELEMENT SELECTION --- const trimesterTabs = document.getElementById('trimester-tabs'); const categoryButtonsContainer = document.getElementById('category-buttons'); const contentTitleEl = document.getElementById('content-title'); const contentBodyEl = document.getElementById('content-body'); const downloadPdfBtn = document.getElementById('download-pdf-btn'); // --- STATE --- let currentTrimester = "1"; let currentCategory = ""; let currentGuideData = null; // --- INITIALIZATION --- const init = () => { renderCategoryButtons(); addEventListeners(); }; const renderCategoryButtons = () => { const categories = Object.keys(GUIDE_DATA[currentTrimester]); categoryButtonsContainer.innerHTML = categories.map(cat => ` `).join(''); // Add event listeners to the new buttons document.querySelectorAll('.category-button').forEach(btn => { btn.addEventListener('click', handleCategoryClick); }); }; const updateContent = () => { if (!currentTrimester || !currentCategory) { // Show welcome message contentTitleEl.textContent = "Welcome!"; contentBodyEl.innerHTML = "

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(); });
Scroll to Top