|
96 | 96 |
|
97 | 97 | (defn- react-raw [raw-html-str] |
98 | 98 | "A React component that renders raw html." |
99 | | - (js/React.createElement "div" |
100 | | - #js {:key (str (hash raw-html-str)) |
101 | | - :dangerouslySetInnerHTML |
102 | | - #js {:__html raw-html-str}})) |
| 99 | + (react/createElement "div" |
| 100 | + #js {:key (str (hash raw-html-str)) |
| 101 | + :dangerouslySetInnerHTML |
| 102 | + #js {:__html raw-html-str}})) |
103 | 103 |
|
104 | 104 | (declare get-props ref->node) |
105 | 105 |
|
|
123 | 123 | (get-props this :code)]]))) |
124 | 124 |
|
125 | 125 | (defn code-highlight [code-str lang] |
126 | | - (js/React.createElement CodeHighlight #js {:code code-str |
127 | | - :lang lang})) |
| 126 | + (react/createElement CodeHighlight #js {:code code-str |
| 127 | + :lang lang})) |
128 | 128 |
|
129 | 129 | (defmulti markdown-block->react :type) |
130 | 130 |
|
131 | 131 | (defmethod markdown-block->react :default [{:keys [content]}] |
132 | 132 | (-> content mark/markdown-to-html react-raw)) |
133 | 133 |
|
134 | 134 | (defmethod markdown-block->react :code-block [{:keys [content] :as block}] |
135 | | - (js/React.createElement CodeHighlight #js {:code (:content block) |
136 | | - :lang (:lang block)})) |
| 135 | + (react/createElement CodeHighlight #js {:code (:content block) |
| 136 | + :lang (:lang block)})) |
137 | 137 |
|
138 | 138 | (declare react-element?) |
139 | 139 |
|
|
217 | 217 |
|
218 | 218 | (defn ref->node [this ref] |
219 | 219 | (when-let [comp (gobj/get (.. this -refs) ref)] |
220 | | - (js/ReactDOM.findDOMNode comp))) |
| 220 | + (react-dom/findDOMNode comp))) |
221 | 221 |
|
222 | 222 | (defn get-props [this k] |
223 | 223 | (gobj/get (.-props this) (name k))) |
|
239 | 239 |
|
240 | 240 | ;; this is not currently being used |
241 | 241 | (defn dont-update [change-count children-thunk] |
242 | | - (js/React.createElement DontUpdate |
243 | | - #js { :change_count change-count |
244 | | - :children_thunk children-thunk})) |
| 242 | + (react/createElement DontUpdate |
| 243 | + #js {:change_count change-count |
| 244 | + :children_thunk children-thunk})) |
245 | 245 |
|
246 | 246 | (defn wrangle-inital-data [this] |
247 | 247 | (let [data (or (:initial-data (get-props this :card)) {})] |
|
366 | 366 | (componentWillUnmount |
367 | 367 | [this] |
368 | 368 | (when-let [node (ref->node this (get-state this :unique_id))] |
369 | | - (js/ReactDOM.unmountComponentAtNode node))) |
| 369 | + (react-dom/unmountComponentAtNode node))) |
370 | 370 | (componentDidMount [this] (render-into-dom this)) |
371 | 371 | (render |
372 | 372 | [this] |
373 | 373 | (if (html-env?) |
374 | | - (js/React.createElement "div" |
| 374 | + (react/createElement "div" |
375 | 375 | #js { :className "com-rigsomelight-devcards-dom-node" :ref (get-state this :unique_id)} |
376 | 376 | "Card has not mounted DOM node.") |
377 | | - (js/React.createElement "div" nil "Card has not mounted DOM node.")))) |
| 377 | + (react/createElement "div" nil "Card has not mounted DOM node.")))) |
378 | 378 |
|
379 | 379 | (defn booler? [key opts] |
380 | 380 | (let [x (get opts key)] |
|
477 | 477 | (let [errors (validate-card-options card-options)] |
478 | 478 | (if (not-empty errors) |
479 | 479 | (render-errors card-options errors) |
480 | | - (js/React.createElement DevcardBase #js { :card (add-environment-defaults card-options) })))) |
| 480 | + (react/createElement DevcardBase #js { :card (add-environment-defaults card-options) })))) |
481 | 481 |
|
482 | 482 | (defrecord IdentityOptions [obj] |
483 | 483 | IDevcardOptions |
|
528 | 528 | ;; keep |
529 | 529 | (defn- dom-node* [node-fn] |
530 | 530 | (fn [data-atom owner] |
531 | | - (js/React.createElement DomComponent |
532 | | - #js {:node_fn node-fn |
533 | | - :data_atom data-atom}))) |
| 531 | + (react/createElement DomComponent |
| 532 | + #js {:node_fn node-fn |
| 533 | + :data_atom data-atom}))) |
534 | 534 |
|
535 | 535 | ;; devcard protocol that takes a devcard and returns a devcard |
536 | 536 |
|
|
733 | 733 |
|
734 | 734 | ;; keep |
735 | 735 | (defn- hist-recorder* [data-atom] |
736 | | - (js/React.createElement HistoryComponent |
737 | | - #js { :data_atom data-atom :key "devcards-history-control-bar"})) |
| 736 | + (react/createElement HistoryComponent |
| 737 | + #js { :data_atom data-atom :key "devcards-history-control-bar"})) |
738 | 738 |
|
739 | 739 | ;; Testing via cljs.test |
740 | 740 | (comment |
|
789 | 789 | m |
790 | 790 | (sab/html |
791 | 791 | [:div |
792 | | - (js/React.createElement CodeHighlight #js {:code (utils/pprint-code expected) |
793 | | - :lang "clojure"}) |
| 792 | + (react/createElement CodeHighlight #js {:code (utils/pprint-code expected) |
| 793 | + :lang "clojure"}) |
794 | 794 | (when (= type :fail) |
795 | 795 | (sab/html [:div {:style {:marginTop "5px"}} |
796 | 796 | [:div {:style {:position "absolute" :fontSize "0.9em"}} "▶"] |
797 | 797 | [:div {:style {:marginLeft "20px"}} |
798 | | - (js/React.createElement CodeHighlight #js {:code (utils/pprint-code actual) |
799 | | - :lang "clojure"})]]))]))) |
| 798 | + (react/createElement CodeHighlight #js {:code (utils/pprint-code actual) |
| 799 | + :lang "clojure"})]]))]))) |
800 | 800 |
|
801 | 801 | (defmethod test-render :pass [m] |
802 | 802 | (render-pass-fail m)) |
|
968 | 968 | IDevcard |
969 | 969 | (-devcard [this devcard-opts] |
970 | 970 | (let [path (:path devcards.system/*devcard-data*)] |
971 | | - (js/React.createElement TestDevcard |
972 | | - #js {:test_thunks test-thunks |
973 | | - :path path}))))) |
| 971 | + (react/createElement TestDevcard |
| 972 | + #js {:test_thunks test-thunks |
| 973 | + :path path}))))) |
974 | 974 |
|
975 | 975 | ;; render namespace to string |
976 | 976 |
|
|
998 | 998 | (println "Adding base card options!" (prn-str base-card-options)) |
999 | 999 | (swap! dev/app-state update-in [:base-card-options] (fn [opts] (merge opts base-card-options))))) |
1000 | 1000 |
|
| 1001 | +;; deprecated |
1001 | 1002 | (defn ^:export render-namespace-to-string [ns-symbol] |
1002 | 1003 | (when-let [card (get-cards-for-ns ns-symbol)] |
1003 | 1004 | (merge-front-matter-options! ns-symbol) |
|
1011 | 1012 |
|
1012 | 1013 | (defn render-ns [ns-symbol app-state] |
1013 | 1014 | (when-let [card (get-cards-for-ns ns-symbol)] |
1014 | | - (js/ReactDOM.render |
| 1015 | + (react-dom/render |
1015 | 1016 | (sab/html |
1016 | 1017 | [:div.com-rigsomelight-devcards-base.com-rigsomelight-devcards-string-render |
1017 | 1018 | (dev/render-cards (dev/display-cards card) app-state)]) |
|
0 commit comments