Files
wevia-brain/wevia-ux-skill.php
2026-04-12 23:01:36 +02:00

63 lines
2.5 KiB
PHP

<?php
// WEVIA UX SKILL v1.0 — Frontend Design Quality Agent
// Injecté dans WEVIA Master pour audit UX automatique
function wevia_ux_audit($page_url) {
$checks = [];
// 1. Screenshot via Playwright
$ss_path = "/opt/weval-l99/screenshots/ux-" . basename($page_url, '.html') . ".png";
shell_exec("timeout 10 python3 -c \"
from playwright.sync_api import sync_playwright
p=sync_playwright().start()
b=p.chromium.launch(headless=True)
pg=b.new_page()
pg.set_viewport_size({'width':1440,'height':900})
pg.goto('{$page_url}',wait_until='domcontentloaded',timeout=8000)
import time;time.sleep(2)
pg.screenshot(path='{$ss_path}')
b.close();p.stop()
\" 2>/dev/null");
// 2. DOM content check
$dom_check = shell_exec("timeout 8 python3 -c \"
from playwright.sync_api import sync_playwright
import json
p=sync_playwright().start()
b=p.chromium.launch(headless=True)
pg=b.new_page()
pg.goto('{$page_url}',wait_until='domcontentloaded',timeout=8000)
import time;time.sleep(2)
txt=pg.evaluate('()=>document.body.innerText')
issues=[]
if 'undefined' in txt: issues.append('undefined_text')
if 'NaN' in txt: issues.append('NaN_text')
badges=[b.text_content() for b in pg.locator('.badge').all()]
empty=[b for b in badges if b.strip() in ['0','?','undefined','null','']]
if empty: issues.append(f'empty_badges:{len(empty)}')
errs=[]
pg.on('pageerror',lambda e:errs.append(1))
if errs: issues.append(f'js_errors:{len(errs)}')
main=pg.locator('.main,.content,main,#app').bounding_box()
if main and main['x']>200: issues.append('layout_offset')
print(json.dumps({'issues':issues,'size':len(txt)}))
b.close();p.stop()
\" 2>/dev/null");
return json.decode($dom_check ?: '{}');
}
// UX Design Guidelines (from Gemini/Banana/GPT leaders)
function wevia_ux_guidelines() {
return [
'typography' => 'Use distinctive fonts. Pair display+body. Never Inter/Arial/Roboto alone.',
'color' => 'Dominant color + sharp accent. CSS variables. Dark/light coherent.',
'motion' => 'Staggered reveals on load. Hover micro-interactions. CSS transforms.',
'layout' => 'Asymmetric grids OK. Generous spacing OR controlled density. Never cramped.',
'badges' => 'Always show real data. Never 0/undefined/null. Fallback to —.',
'responsive' => 'Mobile-first. Sidebar collapse. Touch targets 44px+.',
'accessibility' => 'Contrast 4.5:1+. Focus indicators. ARIA labels.',
'performance' => 'Lazy load images. Debounce fetches. Cache API responses.',
];
}