diff --git a/HTMX-LANGUAGE-SWITCHING.md b/HTMX-LANGUAGE-SWITCHING.md new file mode 100644 index 0000000..ff2651e --- /dev/null +++ b/HTMX-LANGUAGE-SWITCHING.md @@ -0,0 +1,518 @@ +# HTMX Atomic Updates Implementation + +## Overview + +This document describes the atomic update patterns using HTMX's out-of-band (OOB) swaps. These patterns are used throughout the CV application for language switching, theme toggling, length control, and logo visibility. The solution follows HTMX best practices by updating only the components that change, avoiding full-page reloads and maintaining clean URLs. + +## Architecture + +### The Problem +When switching languages, we need to update TWO distinct UI components: +1. The language selector buttons (to show which language is active) +2. The CV content (to display translated text) + +### The Solution: Out-of-Band Swaps +We use HTMX's `hx-swap-oob` feature to update multiple DOM elements from a single server response: + +``` +Single Request → Single Response → Multiple Atomic Updates +``` + +## Implementation Details + +### 1. Frontend: Language Selector Buttons + +**File:** `templates/partials/navigation/language-selector.html` + +```html +