remove UI part which is unnecessary to have for re-frisk-remote
This commit is contained in:
parent
47c83c5d34
commit
a77ad1dbe7
|
@ -1,4 +1,4 @@
|
|||
(defproject day8.re-frame/re-frame-10x "0.2.1-SNAPSHOT"
|
||||
(defproject status-im/re-frame-10x "0.2.1-SNAPSHOT"
|
||||
:description "Become 10x more productive when developing and debugging re-frame applications."
|
||||
:url "https://github.com/Day8/re-frame-10x"
|
||||
:license {:name "MIT"}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
(ns day8.re-frame-10x
|
||||
(:require [day8.re-frame-10x.styles :as styles]
|
||||
[day8.re-frame-10x.view.container :as container]
|
||||
[day8.re-frame-10x.subs]
|
||||
[day8.re-frame-10x.events]
|
||||
[day8.re-frame-10x.db :as trace.db]
|
||||
[re-frame.trace :as trace :include-macros true]
|
||||
(:require [re-frame.trace :as trace :include-macros true]
|
||||
[clojure.string :as str]
|
||||
[reagent.interop :refer-macros [$ $!]]
|
||||
[reagent.impl.util :as util]
|
||||
|
@ -142,94 +137,5 @@
|
|||
[]
|
||||
(monkey-patch-reagent))
|
||||
|
||||
|
||||
(defn resizer-style [draggable-area]
|
||||
{:position "absolute" :z-index 2 :opacity 0
|
||||
:left (str (- (/ draggable-area 2)) "px") :width "10px" :height "100%" :top "0px" :cursor "col-resize"})
|
||||
|
||||
(def ease-transition "left 0.2s ease-out, top 0.2s ease-out, width 0.2s ease-out, height 0.2s ease-out")
|
||||
|
||||
(defn devtools-outer [opts]
|
||||
;; Add clear button
|
||||
;; Filter out different trace types
|
||||
(let [position (r/atom :right)
|
||||
panel-width% (rf/subscribe [:settings/panel-width%])
|
||||
showing? (rf/subscribe [:settings/show-panel?])
|
||||
dragging? (r/atom false)
|
||||
pin-to-bottom? (r/atom true)
|
||||
selected-tab (rf/subscribe [:settings/selected-tab])
|
||||
window-width (r/atom js/window.innerWidth)
|
||||
handle-window-resize (fn [e]
|
||||
;; N.B. I don't think this should be a perf bottleneck.
|
||||
(reset! window-width js/window.innerWidth))
|
||||
handle-keys (fn [e]
|
||||
(let [combo-key? (or (.-ctrlKey e) (.-metaKey e) (.-altKey e))
|
||||
tag-name (.-tagName (.-target e))
|
||||
key (.-key e)
|
||||
entering-input? (contains? #{"INPUT" "SELECT" "TEXTAREA"} tag-name)]
|
||||
(when (and (not entering-input?) combo-key?)
|
||||
(cond
|
||||
(and (= key "h") (.-ctrlKey e))
|
||||
(do (rf/dispatch [:settings/user-toggle-panel])
|
||||
(.preventDefault e))))))
|
||||
handle-mousemove (fn [e]
|
||||
(when @dragging?
|
||||
(let [x (.-clientX e)
|
||||
y (.-clientY e)
|
||||
new-window-width js/window.innerWidth]
|
||||
(.preventDefault e)
|
||||
(rf/dispatch [:settings/panel-width% (/ (- new-window-width x) new-window-width)])
|
||||
(reset! window-width new-window-width))))
|
||||
handle-mouse-up (fn [e] (reset! dragging? false))]
|
||||
(r/create-class
|
||||
{:component-did-mount (fn []
|
||||
(js/window.addEventListener "keydown" handle-keys)
|
||||
(js/window.addEventListener "mousemove" handle-mousemove)
|
||||
(js/window.addEventListener "mouseup" handle-mouse-up)
|
||||
(js/window.addEventListener "resize" handle-window-resize))
|
||||
:component-will-unmount (fn []
|
||||
(js/window.removeEventListener "keydown" handle-keys)
|
||||
(js/window.removeEventListener "mousemove" handle-mousemove)
|
||||
(js/window.removeEventListener "mouseup" handle-mouse-up)
|
||||
(js/window.removeEventListener "resize" handle-window-resize))
|
||||
:display-name "devtools outer"
|
||||
:reagent-render (fn []
|
||||
(let [draggable-area 10
|
||||
left (if @showing? (str (* 100 (- 1 @panel-width%)) "%")
|
||||
(str @window-width "px"))
|
||||
transition (if @dragging?
|
||||
""
|
||||
ease-transition)]
|
||||
[:div.panel-wrapper
|
||||
{:style {:position "fixed" :width "0px" :height "0px" :top "0px" :left "0px" :z-index 99999999}}
|
||||
[:div.panel
|
||||
{:style {:position "fixed" :z-index 1 :box-shadow "rgba(0, 0, 0, 0.3) 0px 0px 4px" :background "white"
|
||||
:display "flex"
|
||||
:left left :top "0px" :width (str (* 100 @panel-width%) "%") :height "100%"
|
||||
:transition transition}}
|
||||
[:div.panel-resizer (when @showing? {:style (resizer-style draggable-area)
|
||||
:on-mouse-down #(reset! dragging? true)})]
|
||||
[container/devtools-inner opts]]]))})))
|
||||
|
||||
|
||||
(defn panel-div []
|
||||
(let [id "--re-frame-10x--"
|
||||
panel (.getElementById js/document id)]
|
||||
(if panel
|
||||
panel
|
||||
(let [new-panel (.createElement js/document "div")]
|
||||
(.setAttribute new-panel "id" id)
|
||||
(.appendChild (.-body js/document) new-panel)
|
||||
(js/window.focus new-panel)
|
||||
new-panel))))
|
||||
|
||||
(defn inject-devtools! []
|
||||
(styles/inject-trace-styles js/document)
|
||||
(r/render [devtools-outer {:panel-type :inline
|
||||
:debug? debug?}] (panel-div)))
|
||||
|
||||
(defn init-db! []
|
||||
(trace.db/init-db debug?))
|
||||
|
||||
(defn ^:export factory-reset! []
|
||||
(rf/dispatch [:settings/factory-reset]))
|
||||
|
|
|
@ -6,6 +6,4 @@
|
|||
;; Use this namespace with the :preloads compiler option to perform the necessary setup for enabling tracing:
|
||||
;; {:compiler {:preloads [day8.re-frame-10x.preload] ...}}
|
||||
(rf/clear-subscription-cache!)
|
||||
(trace/init-db!)
|
||||
(defonce _ (trace/init-tracing!))
|
||||
(trace/inject-devtools!)
|
||||
|
|
|
@ -17,12 +17,14 @@
|
|||
|
||||
see additional properties that can be specified in options
|
||||
https://github.com/joshwcomeau/react-flip-move#options"
|
||||
(:require-macros [cljs.core :refer [exists?]])
|
||||
(:require
|
||||
[mranderson047.reagent.v0v7v0.reagent.core :as reagent]
|
||||
[cljsjs.react-flip-move]))
|
||||
|
||||
(def component
|
||||
(reagent/adapt-react-class js/FlipMove))
|
||||
(when (exists? js/FlipMove)
|
||||
(reagent/adapt-react-class js/FlipMove)))
|
||||
|
||||
(def ^{:constant true
|
||||
:doc "mimic v-box style properties for standard :div
|
||||
|
|
Loading…
Reference in New Issue