// packages/veko_ui_kit/examples/demo.vk // Verification suite for `veko_ui_kit` (`1.0.0`) and `veko_ui_kit/kit`: // Light-First accessible HTML5 components (`status-pill`, `kpi-card`, `alert-banner`, // `data-table`, `modal-dialog`, `breadcrumb`, `tabs-nav`, `form-field`) over `lib/html`. use [ui = veko_ui_kit, kit = veko_ui_kit/kit, html] assert-true = fn [label str, cond bool] [ if not cond [ println `[FAIL] {label}` return (err `assertion failed: {label}`) ] println `[PASS] {label}` .ok ] main = fn [] any [ // 1. `status-pill` (including `veko_ui_kit/kit` re-export & XSS escaping) pill_html = html/render (kit/status-pill 'ok' 'Healthy <100%>') _ = assert-true/or 'status-pill class pill-ok' (str/contains? pill_html 'class="pill pill-ok"') [e -> return e] _ = assert-true/or 'status-pill escapes label HTML' (str/contains? pill_html 'Healthy <100%>') [e -> return e] // 2. `kpi-card` kpi_html = ui/render (ui/kpi-card/tone/subtitle 'P99 Latency' '3.4 ms' '-18%' 'ok' 'Last 15 minutes') _ = assert-true/or 'kpi-card renders value and delta pill' ((str/contains? kpi_html '3.4 ms') and (str/contains? kpi_html 'pill-ok')) [e -> return e] _ = assert-true/or 'kpi-card renders subtitle' (str/contains? kpi_html 'Last 15 minutes') [e -> return e] // 3. `alert-banner` (ARIA role escalation + dismissible control) danger_html = ui/render (ui/alert-banner/dismissible 'danger' 'Quota Reached' 'Upgrade plan to continue.' true) info_html = ui/render (ui/alert-banner 'info' 'Sync Complete' 'All replicas converged.') _ = assert-true/or 'danger alert uses role="alert"' (str/contains? danger_html 'role="alert"') [e -> return e] _ = assert-true/or 'dismissible alert includes Dismiss button' (str/contains? danger_html 'aria-label="Dismiss notification"') [e -> return e] _ = assert-true/or 'info alert uses role="status"' (str/contains? info_html 'role="status"') [e -> return e] // 4. `data-table` (map-keyed columns, caption, and empty state) cols = [ { key = 'service', label = 'Service' } { key = 'region', label = 'Region' } { key = 'state', label = 'State' } ] rows = [ { service = 'edge-gw', region = 'us-east', state = (ui/status-pill 'ok' 'Live') } { service = 'worker-q', region = 'eu-west', state = (ui/status-pill 'warn' 'Draining') } ] tbl_html = ui/render (ui/data-table/caption cols rows 'Cluster Nodes') _ = assert-true/or 'data-table renders caption and scope="col"' ((str/contains? tbl_html ' return e] _ = assert-true/or 'data-table renders nested Hiccup cells' (str/contains? tbl_html 'Draining') [e -> return e] empty_tbl_html = ui/render (ui/data-table/empty-text cols [] 'Zero nodes registered.') _ = assert-true/or 'data-table empty state spans all 3 columns' ((str/contains? empty_tbl_html 'colspan="3"') and (str/contains? empty_tbl_html 'Zero nodes registered.')) [e -> return e] // 5. `modal-dialog` dlg_html = ui/render (ui/modal-dialog/footer/open 'confirm-deploy' 'Deploy Release 1.0' [ [.p {} ['Confirm production rollout to 12 regions?']] ] [ [.button { type = 'button', class = 'btn-primary' } ['Confirm']] ] true) _ = assert-true/or 'modal-dialog wires aria-labelledby and open attribute' ((str/contains? dlg_html 'aria-labelledby="confirm-deploy-title"') and (str/contains? dlg_html ' open')) [e -> return e] // 6. `breadcrumb` bc_html = ui/render (ui/breadcrumb [ { label = 'Workspace', href = '/' } { label = 'Packages', href = '/packages' } { label = 'veko_ui_kit', href = 'javascript:alert(1)' } ]) _ = assert-true/or 'breadcrumb marks final item aria-current="page"' (str/contains? bc_html 'aria-current="page"') [e -> return e] // 7. `tabs-nav` tabs_html = ui/render (ui/tabs-nav 'pkg-tabs' [ { id = 'readme', label = 'README' } { id = 'api', label = 'API Reference' } ] 'api') _ = assert-true/or 'tabs-nav sets active tab aria-selected="true"' (str/contains? tabs_html 'id="pkg-tabs-tab-api"') [e -> return e] _ = assert-true/or 'tabs-nav wires aria-controls panel id' (str/contains? tabs_html 'aria-controls="pkg-tabs-panel-api"') [e -> return e] // 8. `form-field` (validation error + hint `aria-describedby` + `aria-invalid`) ff_node = ui/form-field/placeholder/hint/error/required 'admin_email' 'Administrator Email' 'email' 'ops@example.com' 'Used for security advisories.' 'Must be a verified corporate domain.' true ff_html = ui/render ff_node _ = assert-true/or 'form-field sets aria-invalid="true" on error' (str/contains? ff_html 'aria-invalid="true"') [e -> return e] _ = assert-true/or 'form-field links hint + error in aria-describedby' (str/contains? ff_html 'aria-describedby="admin_email-hint admin_email-error"') [e -> return e] // 9. Complete HTML5 document assembly with `light-theme-css` doc = html/document 'Veko UI Kit Showcase' [(html/style-el (ui/light-theme-css))] [ (ui/breadcrumb [{ label = 'Home', href = '/' } { label = 'Dashboard', href = '/dash' }]) (ui/kpi-card 'Active Workers' '64' '+4') ] full_page = html/render doc _ = assert-true/or 'Complete HTML5 document renders and CSS tokens' ((str/contains? full_page '') and (str/contains? full_page '--vk-surface:#ffffff')) [e -> return e] println 'veko_ui_kit demo: all checks passed.' 0 ] main