Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
reagent/reagent {:mvn/version "1.1.1"}
cljsjs/react {:mvn/version "17.0.2-0"}
cljsjs/react-dom {:mvn/version "17.0.2-0"}
rum/rum {:mvn/version "0.12.10"}}
rum/rum {:mvn/version "0.12.10"}
lilactown/helix {:mvn/version "0.1.9"}}
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}}}
15 changes: 15 additions & 0 deletions sample/src/portfolio/components/helix.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(ns portfolio.components.helix
(:require [helix.core :refer [defnc $]]
[helix.hooks :as hooks]
[helix.dom :as d]
[portfolio.react :refer-macros [defscene]]))

(defnc counter []
(let [[count set-count] (hooks/use-state 0)]
(d/div
(d/p "Count: " count)
(d/button {:on-click #(set-count inc)} "Increase"))))

(defscene helix-counter
:title "Counter with React Hooks"
($ counter))
1 change: 1 addition & 0 deletions sample/src/portfolio/scenes.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[portfolio.components.button]
[portfolio.components.dom]
[portfolio.components.heading]
[portfolio.components.helix]
[portfolio.components.html]
[portfolio.components.link]
[portfolio.components.reagent]
Expand Down
12 changes: 12 additions & 0 deletions src/portfolio/react.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns portfolio.react
(:require [portfolio.scene :as scene]))

(defmacro defscene [id & opts]
(when (scene/portfolio-active?)
`(portfolio.data/register-scene!
(portfolio.react/create-scene
~(scene/get-options-map id (:line &env) opts)))))

(defmacro defns [title & opts]
`(portfolio.data/register-namespace!
~(scene/get-namespace-options title opts)))
15 changes: 15 additions & 0 deletions src/portfolio/react.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(ns portfolio.react
(:require [portfolio.adapter :as adapter]
[portfolio.data :as data]
[react :as react]
[react-dom :as react-dom])
(:require-macros [portfolio.react]))

(def component-impl
{`adapter/render-component
(fn [{:keys [component]} el]
(assert (some? el) "Asked to render component into null container.")
(react-dom/render component el))})

(defn create-scene [scene]
(adapter/prepare-scene scene component-impl))