96 lines
3.7 KiB
Python
96 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Phase-31: simple UX-tweaks — toasts, button-states, empty-states, copy-improvements."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio, datetime, json, sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from phase2_features import Feature, FileGen, ROOT, log, log_section
|
|
from phase3_features import run_feature_v2
|
|
|
|
PHASE_STATE = ROOT / ".phase31-state.json"
|
|
|
|
FEATURES: list[Feature] = [
|
|
Feature(
|
|
name="toast-undo-pattern",
|
|
description="Toast mit Undo-Button bei Delete-Actions",
|
|
files=[FileGen(
|
|
path="apps/web/src/lib/toastUndo.tsx",
|
|
purpose=(
|
|
"toastUndo(message, onUndo) hook/util. Wenn toast lib vorhanden: toast mit action-button 'Rückgängig'. "
|
|
"Sonst: window.confirm fallback. Export default. Keep imports minimal."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="empty-state-illustrations",
|
|
description="EmptyState-Component für leere Listen",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/EmptyState.tsx",
|
|
purpose=(
|
|
"EmptyState-Component. Props: icon (lucide-react component), title, description, actionLabel?, onAction?. "
|
|
"Zentriert in container: großes Icon (grey), title (text-lg bold), description (text-sm grey), optional CTA-Button. "
|
|
"Tailwind."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="button-loading-states",
|
|
description="Button mit loading-prop zeigt Spinner",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/Button.tsx",
|
|
purpose=(
|
|
"Button-Component. Props: variant ('primary'|'secondary'|'danger'), loading?: boolean, disabled?, children, onClick. "
|
|
"Tailwind classes per variant. Wenn loading: zeigt Spinner-SVG (lucide Loader2 mit animate-spin) statt children. "
|
|
"Auto-disabled wenn loading. Export default."
|
|
),
|
|
)],
|
|
),
|
|
Feature(
|
|
name="copy-to-clipboard-component",
|
|
description="CopyButton mit visual feedback",
|
|
files=[FileGen(
|
|
path="apps/web/src/components/CopyButton.tsx",
|
|
purpose=(
|
|
"CopyButton-Component. Props: text (string to copy), label?. Klick: navigator.clipboard.writeText(text). "
|
|
"Zeigt 2s lang Check-Icon (grün) + 'Kopiert!', dann zurück zu Copy-Icon. Lucide-react: Copy, Check. Tailwind."
|
|
),
|
|
)],
|
|
),
|
|
]
|
|
|
|
|
|
def load_state():
|
|
if PHASE_STATE.exists():
|
|
return json.loads(PHASE_STATE.read_text())
|
|
return {"completed_features": [], "current_feature": None, "started_at": datetime.datetime.now().isoformat()}
|
|
|
|
|
|
def save_state(state):
|
|
PHASE_STATE.write_text(json.dumps(state, indent=2))
|
|
|
|
|
|
async def main():
|
|
log_section("🚀 Phase-31 Codegen-Run gestartet — UX polish")
|
|
state = load_state()
|
|
for feature in FEATURES:
|
|
if feature.name in state.get("completed_features", []):
|
|
continue
|
|
state["current_feature"] = feature.name; save_state(state)
|
|
try:
|
|
success = await run_feature_v2(feature)
|
|
state.setdefault("completed_features" if success else "attempted_features", []).append(feature.name)
|
|
save_state(state)
|
|
except Exception as e:
|
|
log(f"❌ {feature.name} crashed: {e}", level="ERROR")
|
|
state.setdefault("attempted_features", []).append(feature.name); save_state(state)
|
|
log_section("Phase-31 Run beendet")
|
|
log(f"OK: {len(state.get('completed_features', []))}, Attempted: {len(state.get('attempted_features', []))}, Total: {len(FEATURES)}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(asyncio.run(main()))
|