Skip to content

Commit

Permalink
LocalPlanStepper
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Feb 24, 2021
1 parent e9c394a commit fe13ec8
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/embed/com/wsscode/pathom/viz/embed/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,45 @@
(:require
["react-dom" :as react-dom]
[com.fulcrologic.fulcro.dom :as dom]
[com.wsscode.pathom.viz.embed.fulcro-float-roots]
[com.wsscode.pathom.viz.embed.helix-state-play]
[com.wsscode.pathom.viz.embed.messaging :as p.viz.msg]
[com.wsscode.pathom.viz.lib.hooks :as p.hooks]
[com.wsscode.pathom.viz.trace :as pvt]
[com.wsscode.pathom.viz.styles]
[com.wsscode.pathom.viz.trace-with-plan :as trace+plan]
[com.wsscode.tailwind-garden.core :as tailwind]
[com.wsscode.pathom.viz.index-explorer :as index-explorer]
[helix.core :as h]
[helix.hooks :as hooks]))
[com.wsscode.pathom3.viz.plan :as viz-plan]
[helix.core :as h]))

(h/defnc EmbedTrace [{:keys [data]}]
(trace+plan/trace-with-plan data))

(h/defnc IndexExplorer [{:keys [data]}]
(trace+plan/trace-with-plan data))
(h/defnc LocalPlanStepper
"Data should be:
'{::pci/index-oir {}
::pcp/available-data {}
::eql/query []}"
[{:keys [data]}]
(h/$ viz-plan/PlanSnapshots
{:frames
(->> (viz-plan/compute-frames data)
(mapv (juxt identity viz-plan/compute-plan-elements)))

:display
::viz-plan/display-type-node-id}))

(def component-map
{"trace" EmbedTrace
"index-explorer" IndexExplorer})
{"trace" EmbedTrace
"plan-stepper" LocalPlanStepper})

(defn render-child-component [{:keys [component-name component-props]}]
(if-let [Comp (get component-map component-name)]
(h/$ Comp {:data component-props})
(dom/div "Can't find component " component-name)))

(def full-css
(into pvt/trace-css (tailwind/everything)))

(comment
(js/console.log "!! " full-css))

(h/defnc PathomVizEmbed []
(let [component-contents! (p.hooks/use-fstate (p.viz.msg/query-param-state))]

(p.viz.msg/use-post-message-data component-contents!)

(or (p.hooks/use-garden-css full-css)
(or (p.hooks/use-garden-css com.wsscode.pathom.viz.styles/full-css)
(if @component-contents!
(render-child-component @component-contents!)
(dom/noscript)))))
Expand All @@ -50,6 +51,4 @@
(h/$ PathomVizEmbed {})
(js/document.getElementById "app")))

#_ (start)

(com.wsscode.pathom.viz.embed.helix-state-play/start)
(start)

0 comments on commit fe13ec8

Please sign in to comment.