import streamlit as st
from pathlib import Path
import os
# Load custom CSS
def load_css():
css_file = Path(__file__).parent / "custom.css"
if css_file.exists():
with open(css_file) as f:
st.markdown(f"", unsafe_allow_html=True)
else:
st.warning("Custom CSS file not found. Some styles may be missing.")
# Header component
def header():
st.markdown("""
Historical OCR Workshop
""", unsafe_allow_html=True)
# Create a page wrapper similar to the React component
def page_wrapper(content_function, current_module=1):
"""
Creates a consistent page layout with navigation
Args:
content_function: Function that renders the page content
current_module: Current module number (1-6)
"""
# Load custom CSS
load_css()
# Display header
header()
# Ensure session state for navigation
if 'current_module' not in st.session_state:
st.session_state.current_module = current_module
# Main content area with bottom padding for the nav
st.markdown('
', unsafe_allow_html=True)
# Call the content function to render the module content
content_function()
# Add spacer for fixed nav
st.markdown('', unsafe_allow_html=True)
# Navigation
render_navigation(current_module)
st.markdown('
""", unsafe_allow_html=True)
# Previous button HTML
def prev_button_html(current_module, modules):
if current_module > 1:
prev_module = current_module - 1
return f"""
"""
return ""
# Next button HTML
def next_button_html(current_module, modules):
if current_module < len(modules):
next_module = current_module + 1
return f"""
"""
return ""
# Navigation dots HTML
def nav_dots_html(current_module, modules):
dots_html = ""
for i, name in enumerate(modules, 1):
active_class = "active" if i == current_module else ""
dots_html += f"""
{i}
"""
return dots_html
# Helper functions for container styles
def gray_container(content, padding="1.5rem"):
"""Renders content in a gray container with consistent styling"""
st.markdown(f'
{content}
', unsafe_allow_html=True)
def blue_container(content, padding="1.5rem"):
"""Renders content in a blue container with consistent styling"""
st.markdown(f'
{content}
', unsafe_allow_html=True)
def yellow_container(content, padding="1.5rem"):
"""Renders content in a yellow container with consistent styling"""
st.markdown(f'
{content}
', unsafe_allow_html=True)
def card_grid(cards):
"""
Renders a responsive grid of cards
Args:
cards: List of HTML strings for each card
"""
grid_html = '