generated from coulomb/repo-seed
- Schema: hubs, widgets, widget_versions, interaction_events (append-only trigger), annotations, users — single migration file - Web layer: Types, Routes, FrontController with auth + AutoRefresh layout - Controllers: Hubs (CRUD), Widgets (CRUD + versioning), InteractionEvents (JSON capture, canonical event_type validation), Annotations (threaded, append-only) - Sessions controller for IHP auth - Views: Hubs (index/show/new/edit), Widgets (index/show/new/edit), Annotations (index/new), Sessions (login) - widgetEnvelope helper with full data-* governance attributes - Integration tests: Hub CRUD, Widget versioning, event capture, append-only guard, annotation threading, validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.4 KiB
Haskell
45 lines
1.4 KiB
Haskell
module Application.Helper.View where
|
|
|
|
import IHP.ViewPrelude
|
|
import Generated.Types
|
|
import Web.Types
|
|
|
|
-- | Widget Envelope — wraps any widget's rendered content with IHF governance metadata.
|
|
--
|
|
-- Every interactive element that is part of the governed widget registry should
|
|
-- be wrapped with this helper. It injects the stable data-* attributes that the
|
|
-- client-side event capture script reads to identify the widget without coupling
|
|
-- to implementation details.
|
|
--
|
|
-- Usage:
|
|
--
|
|
-- @
|
|
-- widgetEnvelope widget [hsx|
|
|
-- <button>Click me</button>
|
|
-- |]
|
|
-- @
|
|
--
|
|
-- See docs/widget-envelope-convention.md for the full convention.
|
|
widgetEnvelope :: Widget -> Html -> Html
|
|
widgetEnvelope widget inner = [hsx|
|
|
<div
|
|
class="ihf-widget"
|
|
data-widget-id={tshow widget.id}
|
|
data-widget-type={widget.widgetType}
|
|
data-hub-id={tshow widget.hubId}
|
|
data-capability-ref={fromMaybe "" widget.capabilityRef}
|
|
data-view-context={fromMaybe "" widget.viewContext}
|
|
data-policy-scope={widget.policyScope}
|
|
data-widget-version={tshow widget.version}
|
|
>
|
|
{inner}
|
|
<div class="ihf-widget-controls mt-2">
|
|
<a href={WidgetAnnotationsAction { widgetId = widget.id }}
|
|
class="ihf-annotate-btn text-xs text-gray-400 hover:text-indigo-600 border border-gray-200
|
|
rounded px-2 py-0.5 hover:border-indigo-300">
|
|
Annotate
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|]
|