0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Replace rum/react with mx/react.

This commit is contained in:
Andrey Antukh 2016-07-09 18:32:38 +03:00
parent a3d0358bdf
commit 5dc4dec1e0
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
47 changed files with 99 additions and 99 deletions

View file

@ -77,8 +77,8 @@
(defn app-render
[own]
(let [route (rum/react route-l)
auth (rum/react st/auth-l)
(let [route (mx/react route-l)
auth (mx/react st/auth-l)
location (:id route)
params (:params route)]
(if (and (restricted? location) (not auth))

View file

@ -43,8 +43,8 @@
(defn- form-render
[own token]
(let [form (rum/react form-data)
errors (rum/react form-errors)
(let [form (mx/react form-data)
errors (mx/react form-errors)
valid? (us/valid? form schema)]
(letfn [(on-change [field event]
(let [value (dom/event->value event)]

View file

@ -43,8 +43,8 @@
(defn- form-render
[own]
(let [form (rum/react form-data)
errors (rum/react form-errors)
(let [form (mx/react form-data)
errors (mx/react form-errors)
valid? (us/valid? form schema)]
(letfn [(on-change [field event]
(let [value (dom/event->value event)]

View file

@ -40,8 +40,8 @@
(defn- register-form-render
[own]
(let [form (rum/react form-data)
errors (rum/react form-errors)
(let [form (mx/react form-data)
errors (mx/react form-errors)
valid? (us/valid? form uda/register-schema)]
(letfn [(on-change [field event]
(let [value (dom/event->value event)]

View file

@ -50,7 +50,7 @@
(defn page-title-render
[own coll]
(let [local (:rum/local own)
dashboard (rum/react dashboard-l)
dashboard (mx/react dashboard-l)
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 (rum/react dashboard-l)
collections-by-id (rum/react collections-by-id-l)
(let [dashboard (mx/react dashboard-l)
collections-by-id (mx/react collections-by-id-l)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
@ -141,11 +141,11 @@
(defn grid-render
[own]
(let [local (:rum/local own)
dashboard (rum/react dashboard-l)
dashboard (mx/react dashboard-l)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)
coll (rum/react (focus-collection coll-id))
coll (mx/react (focus-collection coll-id))
toggle-color-check (fn [color]
(swap! local update :selected #(if (% color) (disj % color) (conj % color))))
delete-selected #(rs/emit! (dc/remove-colors (:id coll) (:selected @local)))]
@ -201,9 +201,9 @@
(defn menu-render
[]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
coll-id (:collection-id dashboard)
coll (rum/react (focus-collection coll-id))
coll (mx/react (focus-collection coll-id))
ccount (count (:data coll)) ]
(html
[:section.dashboard-bar.library-gap

View file

@ -31,7 +31,7 @@
(defn header-render
[own]
(let [local (rum/react header-l)
(let [local (mx/react header-l)
projects? (= (:section local) :dashboard/projects)
elements? (= (:section local) :dashboard/elements)
icons? (= (:section local) :dashboard/icons)

View file

@ -33,7 +33,7 @@
(defn- page-title-render
[own coll]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
own? (:builtin coll false)]
(html
[:div.dashboard-title {}
@ -57,7 +57,7 @@
(defn nav-render
[own]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
@ -98,7 +98,7 @@
(defn grid-render
[own]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)

View file

@ -78,7 +78,7 @@
(defn page-title-render
[own coll]
(let [local (:rum/local own)
dashboard (rum/react dashboard-l)
dashboard (mx/react dashboard-l)
own? (:builtin coll false)]
(letfn [(persist [event]
(let [name (:coll-name @local)]
@ -136,13 +136,13 @@
(defn nav-render
[own]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
collid (:collection-id dashboard)
own? (= (:collection-type dashboard) :own)
builtin? (= (:collection-type dashboard) :builtin)
collections (if builtin?
(vals library/+image-collections-by-id+)
(vals (rum/react collections-by-id-l)))
(vals (mx/react collections-by-id-l)))
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,16 +181,16 @@
(defn- grid-render
[own]
(let [local (:rum/local own)
dashboard (rum/react dashboard-l)
dashboard (mx/react dashboard-l)
coll-type (:collection-type dashboard)
coll-id (:collection-id dashboard)
own? (= coll-type :own)
builtin? (= coll-type :builtin)
coll (if builtin?
(get library/+image-collections-by-id+ coll-id)
(rum/react (focus-collection coll-id)))
images-filtering (rum/react images-filtering-l)
images-ordering (rum/react images-ordering-l)
(mx/react (focus-collection coll-id)))
images-filtering (mx/react images-filtering-l)
images-ordering (mx/react images-ordering-l)
images (->> (:images coll)
(remove nil?)
(filter-images-by images-filtering)
@ -264,7 +264,7 @@
(defn- sort-widget-render
[]
(let [ordering (rum/react images-ordering-l)
(let [ordering (mx/react images-ordering-l)
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 (rum/react images-filtering-l)}]
:value (mx/react images-filtering-l)}]
[:div.clear-search {:on-click on-clear} i/close]])))
(def ^:private search-widget
@ -320,9 +320,9 @@
(defn- menu-render
[]
(let [dashboard (rum/react dashboard-l)
(let [dashboard (mx/react dashboard-l)
coll-id (:collection-id dashboard)
coll (rum/react (focus-collection coll-id))
coll (mx/react (focus-collection coll-id))
icount (count (:images coll)) ]
(html
[:section.dashboard-bar.library-gap

View file

@ -78,7 +78,7 @@
(defn sort-widget-render
[]
(let [ordering (rum/react project-ordering-l)
(let [ordering (mx/react project-ordering-l)
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 (rum/react project-filtering-l)}]
:value (mx/react project-filtering-l)}]
[:div.clear-search
{:on-click on-clear}
i/close]])))
@ -135,7 +135,7 @@
(defn menu-render
[]
(let [projects (rum/react projects-by-id-l)
(let [projects (mx/react projects-by-id-l)
pcount (count projects)]
(html
[:section.dashboard-bar
@ -190,9 +190,9 @@
(defn grid-render
[own]
(let [projects (rum/react projects-by-id-l)
ordering (rum/react project-ordering-l)
filtering (rum/react project-filtering-l)]
(let [projects (mx/react projects-by-id-l)
ordering (mx/react project-ordering-l)
filtering (mx/react project-filtering-l)]
(letfn [(on-click [e]
(dom/prevent-default e)
(udl/open! :new-project))]

View file

@ -53,7 +53,7 @@
(defn- lightbox-render
[own]
(let [data (rum/react lightbox-l)
(let [data (mx/react lightbox-l)
classes (classnames
:hide (nil? data)
:transparent (:transparent? data))]

View file

@ -26,7 +26,7 @@
(defn loader-render
[own]
(when (rum/react st/loader)
(when (mx/react st/loader)
(html
[:div.loader-content i/loader])))

View file

@ -77,7 +77,7 @@
(defn messages-render
[own]
(let [message (rum/react message-l)]
(let [message (mx/react message-l)]
(case (:type message)
:error (notification-box message)
:info (notification-box message)

View file

@ -31,7 +31,7 @@
(defn header-render
[own]
(let [section (rum/react section-l)
(let [section (mx/react section-l)
profile? (= section :settings/profile)
password? (= section :settings/password)
notifications? (= section :settings/notifications)]

View file

@ -39,8 +39,8 @@
(defn password-form-render
[own]
(let [form (rum/react formdata)
errors (rum/react formerrors)
(let [form (mx/react formdata)
errors (mx/react formerrors)
valid? (sc/valid? form udu/update-password-schema)]
(letfn [(on-field-change [field event]
(let [value (dom/event->value event)]

View file

@ -45,9 +45,9 @@
(defn profile-form-render
[own]
(let [form (merge (rum/react profile-l)
(rum/react formdata))
errors (rum/react formerrors)
(let [form (merge (mx/react profile-l)
(mx/react formdata))
errors (mx/react formerrors)
valid? (sc/valid? form udu/update-profile-schema)
theme (get-in form [:metadata :theme] "light")]
@ -129,7 +129,7 @@
(first))]
(rs/emit! (udu/update-photo file))
(dom/clean-value! target)))]
(let [{:keys [photo]} (rum/react profile-l)
(let [{:keys [photo]} (mx/react profile-l)
photo (if (or (str/empty? photo) (nil? photo))
"images/avatar.jpg"
photo)]

View file

@ -20,7 +20,7 @@
(defn- shape-render
[own id]
(let [shape (rum/react (focus-shape id))]
(let [shape (mx/react (focus-shape id))]
(when-not (:hidden shape)
(render-component shape))))

View file

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

View file

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

View file

@ -39,7 +39,7 @@
(defn- text-component-render
[own {:keys [id x1 y1 content group] :as shape}]
(let [selected (rum/react common/selected-shapes-l)
(let [selected (mx/react common/selected-shapes-l)
selected? (and (contains? selected id)
(= (count selected) 1))
local (:rum/local own)]

View file

@ -56,7 +56,7 @@
(defn user-render
[own]
(let [profile (rum/react profile-l)
(let [profile (mx/react profile-l)
local (:rum/local own)
photo (if (str/empty? (:photo profile ""))
"/images/avatar.jpg"

View file

@ -102,7 +102,7 @@
(defn- workspace-render
[own]
(let [{:keys [flags zoom page] :as workspace} (rum/react wb/workspace-l)
(let [{:keys [flags zoom page] :as workspace} (mx/react wb/workspace-l)
left-sidebar? (not (empty? (keep flags [:layers :sitemap
:document-history])))
right-sidebar? (not (empty? (keep flags [:icons :drawtools

View file

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

View file

@ -34,7 +34,7 @@
(defn- clipboard-dialog-render
[own]
(let [clipboard (rum/react clipboard-l)]
(let [clipboard (mx/react clipboard-l)]
(html
[:div.lightbox-body.clipboard
[:div.clipboard-list

View file

@ -55,8 +55,8 @@
(defn- colorpalette-render
[own]
(let [local (:rum/local own)
flags (rum/react wb/flags-l)
collections-by-id (rum/react collections-by-id-l)
flags (mx/react wb/flags-l)
collections-by-id (mx/react collections-by-id-l)
collections (sort-by :name (vals collections-by-id))
collection (if-let [collid (:selected @local)]
(get collections-by-id collid)

View file

@ -33,7 +33,7 @@
(defn- colorpicker-render
[own {:keys [x y shape attr] :as opts}]
(let [shape (rum/react (focus-shape shape))
(let [shape (mx/react (focus-shape shape))
left (- x 260)
top (- y 50)]
(letfn [(change-color [color]

View file

@ -34,8 +34,8 @@
(defn- draw-area-render
[own]
(let [shape (rum/react drawing-shape)
position (rum/react drawing-position)]
(let [shape (mx/react drawing-shape)
position (mx/react drawing-position)]
(when (and shape position)
(-> (assoc shape :drawing? true)
(geom/resize position)

View file

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

View file

@ -30,8 +30,8 @@
(defn- coordenates-render
[own]
(let [zoom (rum/react wb/zoom-l)
coords (some-> (rum/react wb/mouse-canvas-a)
(let [zoom (mx/react wb/zoom-l)
coords (some-> (mx/react wb/mouse-canvas-a)
(gpt/divide zoom)
(gpt/round 1))
increase #(rs/emit! (dw/increase-zoom))
@ -70,8 +70,8 @@
(defn header-render
[own]
(let [page (rum/react wb/page-l)
flags (rum/react wb/flags-l)
(let [page (mx/react wb/page-l)
flags (mx/react wb/flags-l)
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

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

View file

@ -145,7 +145,7 @@
(defn- ruler-render
[own]
(let [flags (rum/react wb/flags-l)]
(let [flags (mx/react wb/flags-l)]
(when (contains? flags :ruler)
(overlay))))

View file

@ -144,7 +144,7 @@
(defn horizontal-rule-render
[own zoom]
(let [scroll (rum/react wb/scroll-a)
(let [scroll (mx/react wb/scroll-a)
scroll-x (:x scroll)
translate-x (- (- c/canvas-scroll-padding) (:x scroll))]
(html
@ -164,7 +164,7 @@
(defn vertical-rule-render
[own zoom]
(let [scroll (rum/react wb/scroll-a)
(let [scroll (mx/react wb/scroll-a)
scroll-y (:y scroll)
translate-y (- (- c/canvas-scroll-padding) (:y scroll))]
(html

View file

@ -112,7 +112,7 @@
(defn selection-handlers-render
[own]
(let [shapes (rum/react selected-shapes-l)
(let [shapes (mx/react selected-shapes-l)
shapes-num (count shapes)]
(cond
(> shapes-num 1) (multiple-selection-handlers-render shapes)

View file

@ -27,7 +27,7 @@
(defn- selrect-render
[own]
(when-let [data (rum/react position)]
(when-let [data (mx/react position)]
(let [{:keys [x y width height]} (selrect->rect data)]
(html
[:rect.selection-rect

View file

@ -41,11 +41,11 @@
(defn- settings-form-render
[own]
(let [page (rum/react wb/page-l)
(let [page (mx/react wb/page-l)
form (merge settings-form-defaults
(:options page)
(rum/react formdata))
errors (rum/react formerrors)]
(mx/react formdata))
errors (mx/react formerrors)]
(letfn [(on-field-change [field event]
(let [value (dom/event->value event)
value (parse-int value "")]

View file

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

View file

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

View file

@ -119,8 +119,8 @@
(defn history-toolbox-render
[own]
(let [local (:rum/local own)
page (rum/react wb/page-l)
history (rum/react history-l)
page (mx/react wb/page-l)
history (mx/react history-l)
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 (rum/react history-l)
(let [history (mx/react history-l)
version (:selected history)
on-accept #(rs/emit! (udh/apply-selected-history page))
on-cancel #(rs/emit! (udh/deselect-page-history page))]

View file

@ -61,7 +61,7 @@
(defn icons-render
[own]
(let [local (:rum/local own)
drawing (rum/react drawing-shape)
drawing (mx/react drawing-shape)
collid (:collid @local)
icons (get-in library/+icon-collections-by-id+ [collid :icons])
on-close #(rs/emit! (dw/toggle-flag :icons))

View file

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

View file

@ -116,7 +116,7 @@
(defn options-toolbox-render
[own]
(let [shape (rum/react selected-shape-l)
(let [shape (mx/react selected-shape-l)
close #(rs/emit! (udw/toggle-flag :element-options))]
(html
[:div.elementa-options.tool-window

View file

@ -73,9 +73,9 @@
(defn sitemap-toolbox-render
[own]
(let [project (rum/react wb/project-l)
pages (rum/react pages-l)
current (rum/react wb/page-l)
(let [project (mx/react wb/project-l)
pages (mx/react pages-l)
current (mx/react wb/page-l)
create #(udl/open! :page-form {:page {:project (:id project)}})
close #(rs/emit! (dw/toggle-flag :sitemap))]
(html

View file

@ -49,7 +49,7 @@
(defn app-render
[own]
(let [location (rum/react route-id-ref)]
(let [location (mx/react route-id-ref)]
(case location
:view/notfound (notfound-page)
:view/viewer (viewer-page)

View file

@ -52,7 +52,7 @@
:will-unmount viewer-page-will-unmount
:will-mount viewer-page-will-mount}
[own]
(let [flags (rum/react flags-ref)
(let [flags (mx/react flags-ref)
sitemap? (contains? flags :sitemap)]
[:section.view-content
(when sitemap?

View file

@ -37,9 +37,9 @@
(defn- sitemap-render
[own]
(let [project-name (rum/react project-name-ref)
pages (rum/react pages-ref)
selected (rum/react selected-ref)
(let [project-name (mx/react project-name-ref)
pages (mx/react pages-ref)
selected (mx/react selected-ref)
on-click #(rs/emit! (dv/select-page %))]
(html
[:div.view-sitemap