0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-14 07:51:35 -05:00

Rename all "-l" suffix with "-ref" suffix.

That is more intiutive.
This commit is contained in:
Andrey Antukh 2016-07-09 21:46:10 +03:00
parent f20ce6f057
commit d7f21dc130
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
42 changed files with 129 additions and 129 deletions

View file

@ -17,7 +17,7 @@
(defonce state (atom {}))
(defonce loader (atom false))
(def auth-l
(def auth-ref
(-> (l/key :auth)
(l/derive state)))

View file

@ -42,7 +42,7 @@
(def ^:const restricted?
(complement +unrestricted+))
(def route-l
(def route-ref
(-> (l/key :route)
(l/derive st/state)))
@ -77,8 +77,8 @@
(defn app-render
[own]
(let [route (mx/react route-l)
auth (mx/react st/auth-l)
(let [route (mx/react route-ref)
auth (mx/react st/auth-ref)
location (:id route)
params (:params route)]
(if (and (restricted? location) (not auth))
@ -104,7 +104,7 @@
(defn app-will-mount
[own]
(when @st/auth-l
(when @st/auth-ref
(rs/emit! (udu/fetch-profile)))
own)

View file

@ -76,7 +76,7 @@
(defn- login-page-will-mount
[own]
(when @st/auth-l
(when @st/auth-ref
(rt/go :dashboard/projects))
own)

View file

@ -31,11 +31,11 @@
;; --- Lenses
(def ^:private dashboard-l
(def ^:private dashboard-ref
(-> (l/key :dashboard)
(l/derive st/state)))
(def ^:private collections-by-id-l
(def ^:private collections-by-id-ref
(-> (comp (l/key :colors-by-id)
(ul/merge library/+color-collections-by-id+))
(l/derive st/state)))
@ -43,14 +43,14 @@
(defn- focus-collection
[collid]
(-> (l/key collid)
(l/derive collections-by-id-l)))
(l/derive collections-by-id-ref)))
;; --- Page Title
(defn page-title-render
[own coll]
(let [local (:rum/local own)
dashboard (mx/react dashboard-l)
dashboard (mx/react dashboard-ref)
own? (:builtin coll false)]
(letfn [(on-title-save [e]
(rs/emit! (dc/rename-collection (:id coll) (:coll-name @local)))
@ -96,8 +96,8 @@
(defn nav-render
[own]
(let [dashboard (mx/react dashboard-l)
collections-by-id (mx/react collections-by-id-l)
(let [dashboard (mx/react dashboard-ref)
collections-by-id (mx/react collections-by-id-ref)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
@ -141,7 +141,7 @@
(defn grid-render
[own]
(let [local (:rum/local own)
dashboard (mx/react dashboard-l)
dashboard (mx/react dashboard-ref)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)
@ -201,7 +201,7 @@
(defn menu-render
[]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
coll-id (:collection-id dashboard)
coll (mx/react (focus-collection coll-id))
ccount (count (:data coll)) ]

View file

@ -19,7 +19,7 @@
[uxbox.main.ui.users :as ui.u]
[uxbox.util.mixins :as mx]))
(def header-l
(def header-ref
(as-> (l/in [:dashboard]) $
(l/derive $ s/state)))
@ -31,7 +31,7 @@
(defn header-render
[own]
(let [local (mx/react header-l)
(let [local (mx/react header-ref)
projects? (= (:section local) :dashboard/projects)
elements? (= (:section local) :dashboard/elements)
icons? (= (:section local) :dashboard/icons)

View file

@ -25,7 +25,7 @@
;; --- Lenses
(def dashboard-l
(def dashboard-ref
(as-> (l/in [:dashboard]) $
(l/derive $ st/state)))
@ -33,7 +33,7 @@
(defn- page-title-render
[own coll]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
own? (:builtin coll false)]
(html
[:div.dashboard-title {}
@ -57,7 +57,7 @@
(defn nav-render
[own]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
@ -98,7 +98,7 @@
(defn grid-render
[own]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)

View file

@ -52,33 +52,33 @@
;; --- Lenses
(def ^:private dashboard-l
(def ^:private dashboard-ref
(-> (l/key :dashboard)
(l/derive st/state)))
(def ^:private collections-by-id-l
(def ^:private collections-by-id-ref
(-> (l/key :images-by-id)
(l/derive st/state)))
(def ^:private images-ordering-l
(def ^:private images-ordering-ref
(-> (l/in [:dashboard :images-order])
(l/derive st/state)))
(def ^:private images-filtering-l
(def ^:private images-filtering-ref
(-> (l/in [:dashboard :images-filter])
(l/derive st/state)))
(defn- focus-collection
[collid]
(-> (l/key collid)
(l/derive collections-by-id-l)))
(l/derive collections-by-id-ref)))
;; --- Page Title
(defn page-title-render
[own coll]
(let [local (:rum/local own)
dashboard (mx/react dashboard-l)
dashboard (mx/react dashboard-ref)
own? (:builtin coll false)]
(letfn [(persist [event]
(let [name (:coll-name @local)]
@ -136,13 +136,13 @@
(defn nav-render
[own]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
collections (if builtin?
(vals library/+image-collections-by-id+)
(vals (mx/react collections-by-id-l)))
(vals (mx/react collections-by-id-ref)))
show-builtin #(rs/emit! (di/set-collection-type :builtin))
show-own #(rs/emit! (di/set-collection-type :own))
new-coll #(rs/emit! (di/create-collection))
@ -181,7 +181,7 @@
(defn- grid-render
[own]
(let [local (:rum/local own)
dashboard (mx/react dashboard-l)
dashboard (mx/react dashboard-ref)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)
@ -189,8 +189,8 @@
coll (if builtin?
(get library/+image-collections-by-id+ coll-id)
(mx/react (focus-collection coll-id)))
images-filtering (mx/react images-filtering-l)
images-ordering (mx/react images-ordering-l)
images-filtering (mx/react images-filtering-ref)
images-ordering (mx/react images-ordering-ref)
images (->> (:images coll)
(remove nil?)
(filter-images-by images-filtering)
@ -264,7 +264,7 @@
(defn- sort-widget-render
[]
(let [ordering (mx/react images-ordering-l)
(let [ordering (mx/react images-ordering-ref)
on-change #(rs/emit! (di/set-images-ordering
(keyword (.-value (.-target %)))))]
(html
@ -307,7 +307,7 @@
:on-change on-term-change
:auto-focus true
:placeholder (tr "ds.project-search.placeholder")
:value (mx/react images-filtering-l)}]
:value (mx/react images-filtering-ref)}]
[:div.clear-search {:on-click on-clear} i/close]])))
(def ^:private search-widget
@ -320,7 +320,7 @@
(defn- menu-render
[]
(let [dashboard (mx/react dashboard-l)
(let [dashboard (mx/react dashboard-ref)
coll-id (:collection-id dashboard)
coll (mx/react (focus-collection coll-id))
icount (count (:images coll)) ]

View file

@ -62,15 +62,15 @@
;; --- Lenses
(def projects-by-id-l
(def projects-by-id-ref
(as-> (l/key :projects-by-id) $
(l/derive $ s/state)))
(def project-ordering-l
(def project-ordering-ref
(as-> (l/in [:dashboard :project-order]) $
(l/derive $ s/state)))
(def project-filtering-l
(def project-filtering-ref
(as-> (l/in [:dashboard :project-filter]) $
(l/derive $ s/state)))
@ -78,7 +78,7 @@
(defn sort-widget-render
[]
(let [ordering (mx/react project-ordering-l)
(let [ordering (mx/react project-ordering-ref)
on-change #(rs/emit! (dp/set-project-ordering
(keyword (.-value (.-target %)))))]
(html
@ -120,7 +120,7 @@
:on-change on-term-change
:auto-focus true
:placeholder (tr "ds.project-search.placeholder")
:value (mx/react project-filtering-l)}]
:value (mx/react project-filtering-ref)}]
[:div.clear-search
{:on-click on-clear}
i/close]])))
@ -135,7 +135,7 @@
(defn menu-render
[]
(let [projects (mx/react projects-by-id-l)
(let [projects (mx/react projects-by-id-ref)
pcount (count projects)]
(html
[:section.dashboard-bar
@ -190,9 +190,9 @@
(defn grid-render
[own]
(let [projects (mx/react projects-by-id-l)
ordering (mx/react project-ordering-l)
filtering (mx/react project-filtering-l)]
(let [projects (mx/react projects-by-id-ref)
ordering (mx/react project-ordering-ref)
filtering (mx/react project-filtering-ref)]
(letfn [(on-click [e]
(dom/prevent-default e)
(udl/open! :new-project))]

View file

@ -13,7 +13,7 @@
;; --- Lentes
(def ^:const ^:private lightbox-l
(def ^:const ^:private lightbox-ref
(-> (l/key :lightbox)
(l/derive st/state)))
@ -49,7 +49,7 @@
(defn- lightbox-render
[own]
(let [data (mx/react lightbox-l)
(let [data (mx/react lightbox-ref)
classes (classnames
:hide (nil? data)
:transparent (:transparent? data))]

View file

@ -12,7 +12,7 @@
;; --- Lenses
(def ^:const ^:private message-l
(def ^:const ^:private message-ref
(-> (l/key :message)
(l/derive st/state)))
@ -77,7 +77,7 @@
(defn messages-render
[own]
(let [message (mx/react message-l)]
(let [message (mx/react message-ref)]
(case (:type message)
:error (notification-box message)
:info (notification-box message)

View file

@ -19,7 +19,7 @@
[uxbox.main.ui.users :refer (user)]
[uxbox.util.mixins :as mx]))
(def ^:private section-l
(def ^:private section-ref
(-> (l/in [:route :id])
(l/derive st/state)))
@ -31,7 +31,7 @@
(defn header-render
[own]
(let [section (mx/react section-l)
(let [section (mx/react section-ref)
profile? (= section :settings/profile)
password? (= section :settings/password)
notifications? (= section :settings/notifications)]

View file

@ -37,7 +37,7 @@
(def assign-field-value
(partial udf/assign-field-value :profile/main))
(def ^:private profile-l
(def ^:private profile-ref
(-> (l/key :profile)
(l/derive st/state)))
@ -45,7 +45,7 @@
(defn profile-form-render
[own]
(let [form (merge (mx/react profile-l)
(let [form (merge (mx/react profile-ref)
(mx/react formdata))
errors (mx/react formerrors)
valid? (sc/valid? form udu/update-profile-schema)
@ -129,7 +129,7 @@
(first))]
(rs/emit! (udu/update-photo file))
(dom/clean-value! target)))]
(let [{:keys [photo]} (mx/react profile-l)
(let [{:keys [photo]} (mx/react profile-ref)
photo (if (or (str/empty? photo) (nil? photo))
"images/avatar.jpg"
photo)]

View file

@ -20,7 +20,7 @@
(defn- circle-component-render
[own shape]
(let [{:keys [id x y width height group]} shape
selected (mx/react common/selected-shapes-l)
selected (mx/react common/selected-shapes-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)
on-mouse-up #(common/on-mouse-up % shape)]

View file

@ -17,11 +17,11 @@
;; --- Lenses
(def ^:const selected-shapes-l
(def ^:const selected-shapes-ref
(-> (l/in [:workspace :selected])
(l/derive st/state)))
(def ^:const drawing-state-l
(def ^:const drawing-state-ref
(-> (l/in [:workspace :drawing])
(l/derive st/state)))
@ -30,7 +30,7 @@
(defn on-mouse-down
[event {:keys [id group] :as shape} selected]
(let [selected? (contains? selected id)
drawing? @drawing-state-l]
drawing? @drawing-state-ref]
(when-not (:blocked shape)
(cond
(or drawing?

View file

@ -40,7 +40,7 @@
(defn- group-component-render
[own shape]
(let [{:keys [id x y width height group]} shape
selected (mx/react common/selected-shapes-l)
selected (mx/react common/selected-shapes-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)
on-mouse-up #(common/on-mouse-up % shape)]

View file

@ -19,7 +19,7 @@
(defn- icon-component-render
[own shape]
(let [{:keys [id x y width height group]} shape
selected (mx/react common/selected-shapes-l)
selected (mx/react common/selected-shapes-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)
on-mouse-up #(common/on-mouse-up % shape)]

View file

@ -19,7 +19,7 @@
(defn- line-component-render
[own shape]
(let [{:keys [id x y width height group]} shape
selected (mx/react common/selected-shapes-l)
selected (mx/react common/selected-shapes-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)
on-mouse-up #(common/on-mouse-up % shape)]

View file

@ -20,7 +20,7 @@
(defn- rect-component-render
[own shape]
(let [{:keys [id x y width height group]} shape
selected (mx/react common/selected-shapes-l)
selected (mx/react common/selected-shapes-ref)
selected? (contains? selected id)
on-mouse-down #(common/on-mouse-down % shape selected)
on-mouse-up #(common/on-mouse-up % shape)]

View file

@ -26,7 +26,7 @@
(defn handle-mouse-down
[event local {:keys [id group] :as shape} selected]
(if (and (not (:blocked shape))
(or @common/drawing-state-l
(or @common/drawing-state-ref
(:edition @local)
(and group (:locked (geom/resolve-parent shape)))))
nil
@ -39,7 +39,7 @@
(defn- text-component-render
[own {:keys [id x1 y1 content group] :as shape}]
(let [selected (mx/react common/selected-shapes-l)
(let [selected (mx/react common/selected-shapes-ref)
selected? (and (contains? selected id)
(= (count selected) 1))
local (:rum/local own)]

View file

@ -50,13 +50,13 @@
;; --- User Widget
(def profile-l
(def profile-ref
(as-> (l/key :profile) $
(l/derive $ s/state)))
(defn user-render
[own]
(let [profile (mx/react profile-l)
(let [profile (mx/react profile-ref)
local (:rum/local own)
photo (if (str/empty? (:photo profile ""))
"/images/avatar.jpg"

View file

@ -50,8 +50,8 @@
dom (mx/ref-node own "workspace-canvas")]
;; Set initial scroll position
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-l))
(set! (.-scrollTop dom) (* c/canvas-start-scroll-y @wb/zoom-l))
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-ref))
(set! (.-scrollTop dom) (* c/canvas-start-scroll-y @wb/zoom-ref))
(assoc own ::sub1 sub1 ::sub2 sub2)))
@ -97,12 +97,12 @@
(rs/emit! (dw/decrease-zoom)))
(let [dom (mx/ref-node own "workspace-canvas")]
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-l))
(set! (.-scrollTop dom) (* c/canvas-start-scroll-y @wb/zoom-l)))))
(set! (.-scrollLeft dom) (* c/canvas-start-scroll-x @wb/zoom-ref))
(set! (.-scrollTop dom) (* c/canvas-start-scroll-y @wb/zoom-ref)))))
(defn- workspace-render
[own]
(let [{:keys [flags zoom page] :as workspace} (mx/react wb/workspace-l)
(let [{:keys [flags zoom page] :as workspace} (mx/react wb/workspace-ref)
left-sidebar? (not (empty? (keep flags [:layers :sitemap
:document-history])))
right-sidebar? (not (empty? (keep flags [:icons :drawtools

View file

@ -18,18 +18,18 @@
;; --- Lenses
(def workspace-l
(def workspace-ref
(-> (l/in [:workspace])
(l/derive st/state)))
(def project-l
(def project-ref
(letfn [(getter [state]
(let [project (get-in state [:workspace :project])]
(get-in state [:projects-by-id project])))]
(-> (l/lens getter)
(l/derive st/state))))
(def page-l
(def page-ref
(letfn [(getter [state]
(let [page (get-in state [:workspace :page])]
;; (println "page-l$getter" page)
@ -38,33 +38,33 @@
(-> (l/lens getter)
(l/derive st/state))))
(def ^:const selected-shapes-l
(def ^:const selected-shapes-ref
(as-> (l/in [:selected]) $
(l/derive $ workspace-l)))
(l/derive $ workspace-ref)))
(def ^:const toolboxes-l
(def ^:const toolboxes-ref
(as-> (l/in [:toolboxes]) $
(l/derive $ workspace-l)))
(l/derive $ workspace-ref)))
(def ^:const flags-l
(def ^:const flags-ref
(as-> (l/in [:flags]) $
(l/derive $ workspace-l)))
(l/derive $ workspace-ref)))
(def ^:const shapes-by-id-l
(def ^:const shapes-by-id-ref
(as-> (l/key :shapes-by-id) $
(l/derive $ st/state)))
(def ^:const zoom-l
(def ^:const zoom-ref
(-> (l/in [:workspace :zoom])
(l/derive st/state)))
(def ^:const alignment-l
(def ^:const alignment-ref
(letfn [(getter [flags]
(and (contains? flags :grid/indexed)
(contains? flags :grid/alignment)
(contains? flags :grid)))]
(-> (l/lens getter)
(l/derive flags-l))))
(l/derive flags-ref))))
;; --- Scroll Stream
@ -118,9 +118,9 @@
(defonce mouse-delta-s
(->> mouse-viewport-s
(rx/sample 10)
(rx/map #(gpt/divide % @zoom-l))
(rx/map #(gpt/divide % @zoom-ref))
(rx/mapcat (fn [point]
(if @alignment-l
(if @alignment-ref
(uds/align-point point)
(rx/of point))))
(rx/buffer 2 1)

View file

@ -47,7 +47,7 @@
(defn- canvas-render
[own {:keys [width height id] :as page}]
(let [workspace (mx/react uuwb/workspace-l)
(let [workspace (mx/react uuwb/workspace-ref)
flags (:flags workspace)]
(html
[:svg.page-canvas {:x c/canvas-start-x
@ -74,8 +74,8 @@
(defn viewport-render
[own]
(let [workspace (mx/react uuwb/workspace-l)
page (mx/react uuwb/page-l)
(let [workspace (mx/react uuwb/workspace-ref)
page (mx/react uuwb/page-ref)
flags (:flags workspace)
drawing? (:drawing workspace)
zoom (or (:zoom workspace) 1)]

View file

@ -21,7 +21,7 @@
;; --- Lenses
(def ^:const ^:private clipboard-l
(def ^:const ^:private clipboard-ref
(-> (l/key :clipboard)
(l/derive st/state)))
@ -34,7 +34,7 @@
(defn- clipboard-dialog-render
[own]
(let [clipboard (mx/react clipboard-l)]
(let [clipboard (mx/react clipboard-ref)]
(html
[:div.lightbox-body.clipboard
[:div.clipboard-list

View file

@ -30,7 +30,7 @@
;; TODO: move this lense under library ns.
(def ^:private collections-by-id-l
(def ^:private collections-by-id-ref
(-> (comp (l/in [:colors-by-id])
(ul/merge library/+color-collections-by-id+))
(l/derive st/state)))
@ -55,8 +55,8 @@
(defn- colorpalette-render
[own]
(let [local (:rum/local own)
flags (mx/react wb/flags-l)
collections-by-id (mx/react collections-by-id-l)
flags (mx/react wb/flags-ref)
collections-by-id (mx/react collections-by-id-ref)
collections (sort-by :name (vals collections-by-id))
collection (if-let [collid (:selected @local)]
(get collections-by-id collid)

View file

@ -68,7 +68,7 @@
(rx/map :type)
(rx/dedupe)
(rx/filter #(= "ui.shape.draw" %))
(rx/map #(:drawing @wb/workspace-l))
(rx/map #(:drawing @wb/workspace-ref))
(rx/filter identity))]
(rx/subscribe stream initialize)))
@ -84,7 +84,7 @@
(defn- initialize-icon-drawing
"A drawing handler for icons."
[shape]
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-l)
(let [{:keys [x y]} (gpt/divide @wb/mouse-canvas-a @wb/zoom-ref)
props {:x1 x :y1 y :x2 (+ x 100) :y2 (+ y 100)}
shape (geom/setup shape props)]
(rs/emit! (uds/add-shape shape)
@ -103,7 +103,7 @@
[shape]
(let [mouse (->> (rx/sample 10 wb/mouse-viewport-s)
(rx/mapcat (fn [point]
(if @wb/alignment-l
(if @wb/alignment-ref
(uds/align-point point)
(rx/of point))))
(rx/map #(gpt/subtract % canvas-coords)))
@ -127,7 +127,7 @@
(defn- on-draw
[[pt ctrl?]]
(let [pt (gpt/divide pt @wb/zoom-l)]
(let [pt (gpt/divide pt @wb/zoom-ref)]
(reset! drawing-position (assoc pt :lock ctrl?))))
(defn- on-draw-complete

View file

@ -20,7 +20,7 @@
(defn- grid-render
[own]
(let [options (:options (mx/react wb/page-l))
(let [options (:options (mx/react wb/page-ref))
color (:grid/color options "#cccccc")
width c/viewport-width
height c/viewport-height

View file

@ -30,7 +30,7 @@
(defn- coordenates-render
[own]
(let [zoom (mx/react wb/zoom-l)
(let [zoom (mx/react wb/zoom-ref)
coords (some-> (mx/react wb/mouse-canvas-a)
(gpt/divide zoom)
(gpt/round 1))
@ -70,8 +70,8 @@
(defn header-render
[own]
(let [page (mx/react wb/page-l)
flags (mx/react wb/flags-l)
(let [page (mx/react wb/page-ref)
flags (mx/react wb/flags-ref)
toggle #(rs/emit! (dw/toggle-flag %))
on-undo #(rs/emit! (udh/backwards-to-previous-version))
on-redo #(rs/emit! (udh/forward-to-next-version))

View file

@ -24,7 +24,7 @@
(defn watch-move-actions
[]
(let [initialize #(run! watch-movement @wb/selected-shapes-l)
(let [initialize #(run! watch-movement @wb/selected-shapes-ref)
stream (rx/filter #(= "ui.shape.move" (:type %)) uuc/actions-s)]
(rx/subscribe stream initialize)))
@ -38,6 +38,6 @@
(rx/take 1))
stream (->> wb/mouse-delta-s
(rx/take-until stoper))]
(when @wb/alignment-l
(when @wb/alignment-ref
(rs/emit! (uds/initial-align-shape shape)))
(rx/subscribe stream #(rs/emit! (uds/move-shape shape %)))))

View file

@ -40,7 +40,7 @@
(defn- recent-colors-render
[own {:keys [page id] :as shape} callback]
(let [shapes-by-id (mx/react wb/shapes-by-id-l)
(let [shapes-by-id (mx/react wb/shapes-by-id-ref)
shapes (->> (vals shapes-by-id)
(filter #(= (:page %) page)))
colors (calculate-colors shapes)]

View file

@ -38,7 +38,7 @@
stream (->> wb/mouse-delta-s
(rx/take-until stoper)
(rx/with-latest-from vector wb/mouse-ctrl-s))]
(when @wb/alignment-l
(when @wb/alignment-ref
(rs/emit! (uds/initial-vertext-align shape vid)))
(rx/subscribe stream #(handle-resize shape vid %))))

View file

@ -116,8 +116,8 @@
(defn- overlay-line-render
[own center pt]
(let [distance (-> (gpt/distance
(gpt/divide pt @wb/zoom-l)
(gpt/divide center @wb/zoom-l))
(gpt/divide pt @wb/zoom-ref)
(gpt/divide center @wb/zoom-ref))
(mth/precision 4))
angle (-> (gpt/angle pt center)
(mth/precision 4))
@ -139,7 +139,7 @@
(defn- ruler-render
[own]
(let [flags (mx/react wb/flags-l)]
(let [flags (mx/react wb/flags-ref)]
(when (contains? flags :ruler)
(overlay))))

View file

@ -28,7 +28,7 @@
;; --- Lenses
(def ^:const selected-shapes-l
(def ^:const selected-shapes-ref
(letfn [(getter [state]
(let [selected (get-in state [:workspace :selected])]
(mapv #(get-in state [:shapes-by-id %]) selected)))]
@ -112,7 +112,7 @@
(defn selection-handlers-render
[own]
(let [shapes (mx/react selected-shapes-l)
(let [shapes (mx/react selected-shapes-ref)
shapes-num (count shapes)]
(cond
(> shapes-num 1) (multiple-selection-handlers-render shapes)

View file

@ -73,7 +73,7 @@
(defn- translate-to-canvas
"Translate the given rect to the canvas coordinates system."
[rect]
(let [zoom @wb/zoom-l
(let [zoom @wb/zoom-ref
startx (* c/canvas-start-x zoom)
starty (* c/canvas-start-y zoom)]
(assoc rect

View file

@ -41,7 +41,7 @@
(defn- settings-form-render
[own]
(let [page (mx/react wb/page-l)
(let [page (mx/react wb/page-ref)
form (merge settings-form-defaults
(:options page)
(mx/react formdata))

View file

@ -27,7 +27,7 @@
(defn left-sidebar-render
[own]
(let [flags (mx/react wb/flags-l)]
(let [flags (mx/react wb/flags-ref)]
(html
[:aside#settings-bar.settings-bar.settings-bar-left
[:div.settings-bar-inside
@ -50,7 +50,7 @@
(defn right-sidebar-render
[own]
(let [flags (mx/react wb/flags-l)]
(let [flags (mx/react wb/flags-ref)]
(html
[:aside#settings-bar.settings-bar
[:div.settings-bar-inside

View file

@ -89,7 +89,7 @@
(defn draw-tools-render
[open-toolboxes]
(let [workspace (mx/react wb/workspace-l)
(let [workspace (mx/react wb/workspace-ref)
drawing (mx/react drawing-shape)
close #(rs/emit! (dw/toggle-flag :drawtools))
tools (->> (into [] +draw-tools+)

View file

@ -27,7 +27,7 @@
;; --- Lenses
(def ^:const history-l
(def ^:const history-ref
(as-> (l/in [:workspace :history]) $
(l/derive $ st/state)))
@ -119,8 +119,8 @@
(defn history-toolbox-render
[own]
(let [local (:rum/local own)
page (mx/react wb/page-l)
history (mx/react history-l)
page (mx/react wb/page-ref)
history (mx/react history-ref)
section (:section @local :main)
close #(rs/emit! (dw/toggle-flag :document-history))
main? (= section :main)
@ -155,7 +155,7 @@
(defn history-dialog-render
[own page]
(let [history (mx/react history-l)
(let [history (mx/react history-ref)
version (:selected history)
on-accept #(rs/emit! (udh/apply-selected-history page))
on-cancel #(rs/emit! (udh/deselect-page-history page))]

View file

@ -203,7 +203,7 @@
toggle-open (fn [event]
(dom/stop-propagation event)
(swap! local assoc :open (not open?)))
shapes-by-id (mx/react wb/shapes-by-id-l)
shapes-by-id (mx/react wb/shapes-by-id-ref)
classes (classnames
:selected selected?
:drag-top (= :top (:over @local))
@ -283,9 +283,9 @@
(defn layers-render
[own]
(let [workspace (mx/react wb/workspace-l)
(let [workspace (mx/react wb/workspace-ref)
selected (:selected workspace)
shapes-by-id (mx/react wb/shapes-by-id-l)
shapes-by-id (mx/react wb/shapes-by-id-ref)
page (mx/react (focus-page (:page workspace)))
close #(rs/emit! (udw/toggle-flag :layers))
duplicate #(rs/emit! (uds/duplicate-selected))

View file

@ -106,7 +106,7 @@
:name "options"
:mixins [mx/static (mx/local)]}))
(def ^:const selected-shape-l
(def ^:const selected-shape-ref
(letfn [(getter [state]
(let [selected (get-in state [:workspace :selected])]
(when (= 1 (count selected))
@ -116,7 +116,7 @@
(defn options-toolbox-render
[own]
(let [shape (mx/react selected-shape-l)
(let [shape (mx/react selected-shape-ref)
close #(rs/emit! (udw/toggle-flag :element-options))]
(html
[:div.elementa-options.tool-window

View file

@ -17,7 +17,7 @@
[uxbox.main.library :as library]
[uxbox.main.data.shapes :as uds]
[uxbox.main.data.lightbox :as udl]
[uxbox.main.ui.workspace.sidebar.sitemap :refer (pages-l)]
[uxbox.main.ui.workspace.sidebar.sitemap :refer (pages-ref)]
[uxbox.main.ui.icons :as i]
[uxbox.main.ui.lightbox :as lbx]
[uxbox.main.ui.colorpicker :as cp]
@ -177,7 +177,7 @@
(defn- pages-input-render
[own form-ref path]
(let [pages @pages-l]
(let [pages @pages-ref]
(when (and (not (:page @form-ref))
(pos? (count pages)))
(swap! form-ref assoc :page (:id (first pages))))

View file

@ -36,7 +36,7 @@
(filter #(= project (:project %)))
(sort-by :created-at))))
(def pages-l
(def pages-ref
(-> (l/lens resolve-page)
(l/derive st/state)))
@ -76,9 +76,9 @@
(defn sitemap-toolbox-render
[own]
(let [project (mx/react wb/project-l)
pages (mx/react pages-l)
current (mx/react wb/page-l)
(let [project (mx/react wb/project-ref)
pages (mx/react pages-ref)
current (mx/react wb/page-ref)
create #(udl/open! :page-form {:page {:project (:id project)}})
close #(rs/emit! (dw/toggle-flag :sitemap))]
(html