;; Reference page layouts — receive data from Python primitives

(defcomp ~reference-attrs-content (&key req-table beh-table uniq-table)
  (~doc-page :title "Attribute Reference"
    (p :class "text-stone-600 mb-6"
      "sx attributes mirror htmx where possible. This table shows all available attributes and their status.")
    (div :class "space-y-8"
      req-table
      beh-table
      uniq-table)))

(defcomp ~reference-headers-content (&key req-table resp-table)
  (~doc-page :title "Headers"
    (p :class "text-stone-600 mb-6"
      "sx uses custom HTTP headers to coordinate between client and server.")
    (div :class "space-y-8"
      req-table
      resp-table)))

(defcomp ~reference-events-content (&key table)
  (~doc-page :title "Events"
    table))

(defcomp ~reference-js-api-content (&key table)
  (~doc-page :title "JavaScript API"
    table))

(defcomp ~reference-attr-detail-content (&key title description demo
    example-code handler-code wire-placeholder-id)
  (~doc-page :title title
    (p :class "text-stone-600 mb-6" description)
    (when demo
      (~example-card :title "Demo"
        (~example-demo demo)))
    (h3 :class "text-lg font-semibold text-stone-700 mt-6" "S-expression")
    (~example-source :code (highlight example-code "lisp"))
    (when handler-code
      (<>
        (h3 :class "text-lg font-semibold text-stone-700 mt-6" "Server handler")
        (~example-source :code (highlight handler-code "lisp"))))
    (when wire-placeholder-id
      (<>
        (h3 :class "text-lg font-semibold text-stone-700 mt-6" "Wire response")
        (p :class "text-stone-500 text-sm mb-2"
          "Trigger the demo to see the raw response the server sends.")
        (~doc-placeholder :id wire-placeholder-id)))))

(defcomp ~reference-attr-not-found (&key slug)
  (~doc-page :title "Not Found"
    (p :class "text-stone-600"
      (str "No documentation found for \"" slug "\"."))))
