Spaces:
Build error
Build error
docs: add Gradio frontend demo design spec
Browse filesFrontend-only implementation with mock data for visual preview.
Warm wood grain background, flashcard widgets, disabled export buttons.
docs/superpowers/specs/2026-06-08-gradio-frontend-demo-design.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# EuropaLex β Gradio Frontend Demo Design
|
| 2 |
+
|
| 3 |
+
**Date:** 2026-06-08
|
| 4 |
+
**Scope:** Frontend-only implementation with mock data. No backend connection.
|
| 5 |
+
**Goal:** Interactive Gradio UI runnable locally via `uv sync && python app.py` to preview the visual design before backend integration.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## 1. Overview
|
| 10 |
+
|
| 11 |
+
Build a fully interactive Gradio frontend for EuropaLex that renders flashcard widgets on a warm wood-grain desk background. All card data is hardcoded mock content β no model inference, no API calls, no Anki sync. The purpose is to validate the visual design and user experience before wiring up the backend pipeline.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## 2. UI Layout (3 Sections)
|
| 16 |
+
|
| 17 |
+
### Section 1 β Input Panel (top)
|
| 18 |
+
- **Scenario input:** `gr.Textbox` placeholder "e.g., ordering coffee"
|
| 19 |
+
- **CEFR level:** `gr.Dropdown` with options `[A0, A1, A2, B1, B2, C1, C2]`, default `B1`
|
| 20 |
+
- **Batch size:** `gr.Slider` range 1β10, default 3
|
| 21 |
+
- **Generate button:** `gr.Button("Generate Cards")`
|
| 22 |
+
|
| 23 |
+
### Section 2 β Card Gallery (middle)
|
| 24 |
+
Cards rendered as styled Gradio `HTML` blocks. Each card displays:
|
| 25 |
+
- Front text (target language, bold, larger font)
|
| 26 |
+
- Back text (source language, muted gray, smaller)
|
| 27 |
+
- Audio play button (circular placeholder icon, non-functional)
|
| 28 |
+
- Image placeholder (gray box with dashed border, "πΌοΈ" emoji)
|
| 29 |
+
|
| 30 |
+
Cards have slight CSS rotation (β3Β° to +3Β°) for a natural "spread on desk" feel.
|
| 31 |
+
|
| 32 |
+
### Section 3 β Export Bar (bottom)
|
| 33 |
+
Three buttons: **Export .apkg**, **Export CSV**, **Sync to Anki**. All disabled with grayed-out styling and hover tooltip: "Demo mode β requires backend connection".
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## 3. Mock Data
|
| 38 |
+
|
| 39 |
+
Hardcoded in `app.py` as a dict keyed by CEFR level:
|
| 40 |
+
|
| 41 |
+
```
|
| 42 |
+
A0 set: ["Es esmu bΔrns.", "Ε Δ« ir mΔja.", "Es mΔ«lu savu Δ£imeni."]
|
| 43 |
+
β ["I am a child.", "This is a house.", "I love my family."]
|
| 44 |
+
|
| 45 |
+
B1 set (default): ["Es gribΔtu izdzert kafiju.", "Vai jΕ«s varat man palΔ«dzΔt?", "Cik daudz maksΔ Ε‘is?"]
|
| 46 |
+
β ["I would like to drink coffee.", "Can you help me?", "How much does this cost?"]
|
| 47 |
+
|
| 48 |
+
Other levels: fallback to B1 set for demo purposes.
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
Each card includes placeholder `audio_path=None` and `image_path=None`.
|
| 52 |
+
|
| 53 |
+
On Generate click: cards for the selected batch size appear instantly from the appropriate mock set.
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## 4. Styling & Theming
|
| 58 |
+
|
| 59 |
+
### Background β Warm Wood Grain (CSS-only, Option A)
|
| 60 |
+
- Base: diagonal gradient simulating wood grain (`linear-gradient(135deg, #8B6F47, #A0845C, #7A5E3A, #96784E)`)
|
| 61 |
+
- Texture overlay: repeating linear gradients (horizontal + vertical lines at fine intervals for wood grain pattern)
|
| 62 |
+
- Lighting: radial gradient highlight at top-center simulating overhead lamp light on the desk surface
|
| 63 |
+
|
| 64 |
+
### App Container
|
| 65 |
+
- Semi-transparent white card (`rgba(255, 250, 240, 0.92)`) with `backdrop-filter: blur(4px)` for frosted glass effect
|
| 66 |
+
- Rounded corners, subtle inner shadow
|
| 67 |
+
|
| 68 |
+
### Flashcard Widget
|
| 69 |
+
- White/cream background (`#fffef9`), border-radius 8px
|
| 70 |
+
- Drop shadow: `0 2px 6px rgba(0,0,0,0.15)` for depth against wood
|
| 71 |
+
- Border: thin warm tone (`#e8dcc8`)
|
| 72 |
+
- Front text: bold, 1.2em, dark brown (`#2a1f0f`)
|
| 73 |
+
- Back text: lighter weight, 0.95em, muted gray-brown (`#6b5e4a`), separated by dotted line
|
| 74 |
+
- Media buttons: circular, cream fill (`#f0e6d2`), subtle shadow
|
| 75 |
+
|
| 76 |
+
### Disabled Export Buttons
|
| 77 |
+
- Background: `#d4c5a9`, text color: `#8b7355`
|
| 78 |
+
- Opacity: 0.6, text-decoration: line-through
|
| 79 |
+
- Cursor: default (not pointer)
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## 5. File Structure Changes
|
| 84 |
+
|
| 85 |
+
```
|
| 86 |
+
EuropaLex/
|
| 87 |
+
βββ app.py # β Rewritten: Gradio entry point + mock data
|
| 88 |
+
βββ frontend/
|
| 89 |
+
β βββ css/
|
| 90 |
+
β β βββ custom.css # β Populated: wood grain background + card styling
|
| 91 |
+
β βββ ui/
|
| 92 |
+
β βββ cards.py # β Kept as stub (future use)
|
| 93 |
+
β βββ widgets.py # β Kept as stub (future use)
|
| 94 |
+
βββ pyproject.toml # β Updated: add gradio + pyyaml dependencies
|
| 95 |
+
βββ requirements.txt # β Updated to match
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
No new files created. Existing stub files preserved for future backend integration.
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## 6. Dependencies
|
| 103 |
+
|
| 104 |
+
**`pyproject.toml` additions:**
|
| 105 |
+
- `gradio>=4.0.0` β frontend framework
|
| 106 |
+
- `pyyaml>=6.0` β config parsing (for future use, added now to avoid later changes)
|
| 107 |
+
|
| 108 |
+
**Run locally:**
|
| 109 |
+
```bash
|
| 110 |
+
uv sync # installs deps into .venv
|
| 111 |
+
python app.py # launches Gradio on localhost:7860
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
---
|
| 115 |
+
|
| 116 |
+
## 7. What This Does NOT Include
|
| 117 |
+
|
| 118 |
+
- No backend pipeline calls (text generation, TTS, image gen)
|
| 119 |
+
- No actual export functionality (.apkg, CSV)
|
| 120 |
+
- No Anki tunnel sync
|
| 121 |
+
- No model loading or inference
|
| 122 |
+
- No A0 curated word list (mock data only)
|
| 123 |
+
- No error handling for missing models
|
| 124 |
+
|
| 125 |
+
These are deferred to the backend integration phase.
|
| 126 |
+
|
| 127 |
+
---
|
| 128 |
+
|
| 129 |
+
## 8. Success Criteria
|
| 130 |
+
|
| 131 |
+
1. `uv sync && python app.py` launches without errors
|
| 132 |
+
2. Gradio UI renders with warm wood grain background visible behind the app container
|
| 133 |
+
3. Input panel accepts user input (scenario text, CEFR selection, batch size)
|
| 134 |
+
4. Clicking Generate instantly displays mock flashcard widgets in the gallery
|
| 135 |
+
5. Cards show front/back text, audio placeholder, image placeholder
|
| 136 |
+
6. Export buttons are visible but disabled with demo-mode tooltip
|
| 137 |
+
7. Custom CSS is applied: card styling, wood grain background, frosted glass container
|