0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-12 18:18:24 -05:00

Update rumext and adapt code to changes.

This commit is contained in:
Andrey Antukh 2019-07-21 19:10:04 +02:00
parent 14d97511e6
commit 125e7375c0
16 changed files with 58 additions and 59 deletions

View file

@ -4,7 +4,7 @@
com.cognitect/transit-cljs {:mvn/version "0.8.256"} com.cognitect/transit-cljs {:mvn/version "0.8.256"}
funcool/rumext {:git/url "https://github.com/funcool/rumext.git" funcool/rumext {:git/url "https://github.com/funcool/rumext.git"
:sha "19d7a87725bdd621084dc6e5e160f57bf2534d5a"} :sha "18739f966f12ff7aab3a9bde1fe37a5594f46b8d"}
cljsjs/react-dom-server {:mvn/version "16.8.6-0"} cljsjs/react-dom-server {:mvn/version "16.8.6-0"}

View file

@ -1,6 +1,6 @@
(ns uxbox.main.ui.dashboard (ns uxbox.main.ui.dashboard
(:require (:require
[rumext.core :as mx :include-macros true] [rumext.alpha :as mf]
[uxbox.main.ui.dashboard.header :refer [header]] [uxbox.main.ui.dashboard.header :refer [header]]
[uxbox.main.ui.dashboard.projects :as projects] [uxbox.main.ui.dashboard.projects :as projects]
;; [uxbox.main.ui.dashboard.elements :as elements] ;; [uxbox.main.ui.dashboard.elements :as elements]
@ -15,9 +15,8 @@
(def images-page images/images-page) (def images-page images/images-page)
(def colors-page colors/colors-page) (def colors-page colors/colors-page)
(mx/defc dashboard (mf/defc dashboard
[props] [props]
(prn "dashboard" props)
[:main.dashboard-main [:main.dashboard-main
(messages-widget) (messages-widget)
(header) (header)

View file

@ -41,7 +41,7 @@
;; --- Page Title ;; --- Page Title
(mf/def page-title (mf/def page-title
:mixins [(mf/local) mf/static mf/reactive] :mixins [(mf/local) mf/memo mf/reactive]
:render :render
(fn [{:keys [::mf/local] :as own} (fn [{:keys [::mf/local] :as own}
@ -93,7 +93,7 @@
;; --- Nav ;; --- Nav
(mf/def nav-item (mf/def nav-item
:mixins [(mf/local) mf/static] :mixins [(mf/local) mf/memo]
:render :render
(fn [{:keys [::mf/local] :as own} (fn [{:keys [::mf/local] :as own}
@ -134,7 +134,7 @@
(tr "ds.num-elements" (t/c colors))]])))) (tr "ds.num-elements" (t/c colors))]]))))
(mf/def nav (mf/def nav
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own {:keys [id type] :as props}] (fn [own {:keys [id type] :as props}]
@ -179,7 +179,7 @@
[:span (tr "ds.color-new")]]) [:span (tr "ds.color-new")]])
(mf/def grid-options-tooltip (mf/def grid-options-tooltip
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own {:keys [selected on-select title]}] (fn [own {:keys [selected on-select title]}]
@ -202,7 +202,7 @@
[:a {:on-click #(on-select % id)} name]])]))) [:a {:on-click #(on-select % id)} name]])])))
(mf/def grid-options (mf/def grid-options
:mixins [mf/static (mf/local)] :mixins [mf/memo (mf/local)]
:render :render
(fn [{:keys [::mf/local] :as own} (fn [{:keys [::mf/local] :as own}
@ -267,7 +267,7 @@
(mf/def grid-item (mf/def grid-item
:key-fn :color :key-fn :color
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [color selected?] :as props}] (fn [own {:keys [color selected?] :as props}]
@ -285,7 +285,7 @@
[:span.color-data (apply str "RGB " (interpose ", " (hex->rgb color)))]]))) [:span.color-data (apply str "RGB " (interpose ", " (hex->rgb color)))]])))
(mf/def grid (mf/def grid
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [selected ::coll] :as props}] (fn [own {:keys [selected ::coll] :as props}]
@ -301,7 +301,7 @@
(grid-item {:color color :selected? selected?})))]]))) (grid-item {:color color :selected? selected?})))]])))
(mf/def content (mf/def content
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -323,7 +323,7 @@
(mf/def colors-page (mf/def colors-page
:key-fn identity :key-fn identity
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:init :init
(fn [own props] (fn [own props]

View file

@ -14,7 +14,7 @@
[uxbox.main.data.projects :as dp] [uxbox.main.data.projects :as dp]
[uxbox.main.store :as st] [uxbox.main.store :as st]
[uxbox.main.ui.navigation :as nav] [uxbox.main.ui.navigation :as nav]
[uxbox.main.ui.users :as ui.u] [uxbox.main.ui.users :refer [user]]
[uxbox.util.i18n :refer (tr)] [uxbox.util.i18n :refer (tr)]
[uxbox.util.router :as rt])) [uxbox.util.router :as rt]))
@ -57,6 +57,6 @@
[:li {:class (when colors? "current")} [:li {:class (when colors? "current")}
(header-link {:section :dashboard/colors (header-link {:section :dashboard/colors
:content (tr "ds.colors")})]] :content (tr "ds.colors")})]]
(ui.u/user)]))) [:& user]])))

View file

@ -73,7 +73,7 @@
;; --- Page Title ;; --- Page Title
(mf/def page-title (mf/def page-title
:mixins [(mf/local) mf/static] :mixins [(mf/local) mf/memo]
:render :render
(fn [{:keys [::mf/local] :as own} {:keys [id type] :as coll}] (fn [{:keys [::mf/local] :as own} {:keys [id type] :as coll}]
@ -134,7 +134,7 @@
(mf/def nav-item (mf/def nav-item
:key-fn :id :key-fn :id
:mixins [(mf/local) mf/static mf/reactive] :mixins [(mf/local) mf/memo mf/reactive]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -180,7 +180,7 @@
(tr "ds.num-elements" (t/c num-icons))]])))) (tr "ds.num-elements" (t/c num-icons))]]))))
(mf/def nav (mf/def nav
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own {:keys [id type] :as props}] (fn [own {:keys [id type] :as props}]
@ -239,7 +239,7 @@
:on-change on-file-selected}]])) :on-change on-file-selected}]]))
(mf/def grid-options-tooltip (mf/def grid-options-tooltip
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own {:keys [selected on-select title]}] (fn [own {:keys [selected on-select title]}]
@ -264,7 +264,7 @@
[:a {:on-click #(on-select % id)} name]])]))) [:a {:on-click #(on-select % id)} name]])])))
(mf/def grid-options (mf/def grid-options
:mixins [(mf/local) mf/static] :mixins [(mf/local) mf/memo]
:render :render
(fn [{:keys [::mf/local] :as own} (fn [{:keys [::mf/local] :as own}
@ -335,7 +335,7 @@
(mf/def grid-item (mf/def grid-item
:key-fn :id :key-fn :id
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [id created-at ::selected? ::edition?] :as icon}] (fn [own {:keys [id created-at ::selected? ::edition?] :as icon}]
(letfn [(toggle-selection [event] (letfn [(toggle-selection [event]
@ -405,7 +405,7 @@
;; --- Menu ;; --- Menu
(mf/def menu (mf/def menu
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -449,7 +449,7 @@
i/close]]]])))) i/close]]]]))))
(mf/def content (mf/def content
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -474,7 +474,7 @@
(mf/def icons-page (mf/def icons-page
:key-fn identity :key-fn identity
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:init :init
(fn [own props] (fn [own props]

View file

@ -123,7 +123,7 @@
(mf/def nav-item (mf/def nav-item
:key-fn :id :key-fn :id
:mixins [(mf/local) mf/static mf/reactive] :mixins [(mf/local) mf/memo mf/reactive]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -167,7 +167,7 @@
(tr "ds.num-elements" (t/c (or num-images (mf/react (::num-images-ref own)))))]]))) (tr "ds.num-elements" (t/c (or num-images (mf/react (::num-images-ref own)))))]])))
(mf/def nav (mf/def nav
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own {:keys [id type] :as props}] (fn [own {:keys [id type] :as props}]
@ -209,7 +209,7 @@
;; --- Grid ;; --- Grid
(mf/def grid-form (mf/def grid-form
:mixins #{mf/static} :mixins #{mf/memo}
:init :init
(fn [own props] (fn [own props]
@ -238,7 +238,7 @@
:on-change on-file-selected}]])))) :on-change on-file-selected}]]))))
(mf/def grid-options-tooltip (mf/def grid-options-tooltip
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own {:keys [selected on-select title]}] (fn [own {:keys [selected on-select title]}]
@ -333,7 +333,7 @@
(mf/def grid-item (mf/def grid-item
:key-fn :id :key-fn :id
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [id created-at ::selected? ::edition?] :as image}] (fn [own {:keys [id created-at ::selected? ::edition?] :as image}]
@ -399,7 +399,7 @@
;; --- Menu ;; --- Menu
(mf/def menu (mf/def menu
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
;; :init ;; :init
;; (fn [own {:keys [id] :as props}] ;; (fn [own {:keys [id] :as props}]
@ -448,7 +448,7 @@
i/close]]]])))) i/close]]]]))))
(mf/def content (mf/def content
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:init :init
(fn [own {:keys [id] :as props}] (fn [own {:keys [id] :as props}]
@ -472,7 +472,7 @@
(mf/def images-page (mf/def images-page
:key-fn identity :key-fn identity
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:init :init
(fn [own props] (fn [own props]

View file

@ -61,7 +61,7 @@
;; --- Menu (Filter & Sort) ;; --- Menu (Filter & Sort)
(mf/def menu (mf/def menu
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:init :init
(fn [own props] (fn [own props]
(assoc own ::num-projects (-> (comp (l/key :projects) (assoc own ::num-projects (-> (comp (l/key :projects)
@ -111,7 +111,7 @@
;; --- Grid Item Thumbnail ;; --- Grid Item Thumbnail
(mf/def grid-item-thumbnail (mf/def grid-item-thumbnail
:mixins #{mf/static} :mixins #{mf/memo}
:init :init
(fn [own project] (fn [own project]
@ -140,7 +140,7 @@
(mf/def grid-item (mf/def grid-item
:key-fn :id :key-fn :id
:mixins #{mf/static (mf/local)} :mixins #{mf/memo (mf/local)}
:render :render
(fn [{:keys [::mf/local] :as own} project] (fn [{:keys [::mf/local] :as own} project]
@ -194,7 +194,7 @@
;; --- Grid ;; --- Grid
(mf/def grid (mf/def grid
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:init :init
(fn [own props] (fn [own props]
@ -222,7 +222,7 @@
;; --- Projects Page ;; --- Projects Page
(mf/def projects-page (mf/def projects-page
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:init :init
(fn [own props] (fn [own props]

View file

@ -247,7 +247,7 @@
:fill "transparent"}}]])) :fill "transparent"}}]]))
(mf/def selection-handlers (mf/def selection-handlers
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own props] (fn [own props]
(let [shapes (mf/react selected-shapes-ref) (let [shapes (mf/react selected-shapes-ref)

View file

@ -66,7 +66,7 @@
(mf/def workspace (mf/def workspace
:key-fn vector :key-fn vector
:mixins #{mf/static :mixins #{mf/memo
mf/reactive mf/reactive
shortcuts-mixin} shortcuts-mixin}

View file

@ -37,7 +37,7 @@
;; --- Background ;; --- Background
(mf/def background (mf/def background
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [background] :as metadata}] (fn [own {:keys [background] :as metadata}]
[:rect [:rect
@ -49,7 +49,7 @@
;; --- Coordinates Widget ;; --- Coordinates Widget
(mf/def coordinates (mf/def coordinates
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own props] (fn [own props]
(let [zoom (mf/react refs/selected-zoom) (let [zoom (mf/react refs/selected-zoom)
@ -69,7 +69,7 @@
(l/derive refs/workspace))) (l/derive refs/workspace)))
(mf/def selrect (mf/def selrect
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own props] (fn [own props]
(when-let [rect (mf/react selrect-ref)] (when-let [rect (mf/react selrect-ref)]
@ -95,7 +95,7 @@
nil)) nil))
(mf/def cursor-tooltip (mf/def cursor-tooltip
:mixins [mf/reactive mf/static] :mixins [mf/reactive mf/memo]
:render :render
(fn [own tooltip] (fn [own tooltip]
(let [coords (mf/react refs/window-mouse-position)] (let [coords (mf/react refs/window-mouse-position)]
@ -109,7 +109,7 @@
;; --- Canvas ;; --- Canvas
(mf/def canvas (mf/def canvas
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own {:keys [page zoom] :as props}] (fn [own {:keys [page zoom] :as props}]
(let [{:keys [metadata id]} page (let [{:keys [metadata id]} page

View file

@ -18,7 +18,7 @@
(declare horizontal-line) (declare horizontal-line)
(mf/def grid (mf/def grid
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own props] (fn [own props]
(let [options (:metadata (mf/react refs/selected-page)) (let [options (:metadata (mf/react refs/selected-page))

View file

@ -18,7 +18,7 @@
[uxbox.main.data.undo :as udu] [uxbox.main.data.undo :as udu]
[uxbox.main.data.lightbox :as udl] [uxbox.main.data.lightbox :as udl]
[uxbox.main.ui.workspace.clipboard] [uxbox.main.ui.workspace.clipboard]
[uxbox.main.ui.users :as ui.u] [uxbox.main.ui.users :refer [user]]
[uxbox.main.ui.navigation :as nav] [uxbox.main.ui.navigation :as nav]
[uxbox.util.router :as r] [uxbox.util.router :as r]
[uxbox.util.data :refer [index-of]] [uxbox.util.data :refer [index-of]]
@ -146,4 +146,4 @@
:on-click #(on-view-clicked % project page)} :on-click #(on-view-clicked % project page)}
i/play]] i/play]]
(zoom-widget)] (zoom-widget)]
(ui.u/user)])) [:& user]]))

View file

@ -105,7 +105,7 @@
;; --- Horizontal Rule Ticks (Component) ;; --- Horizontal Rule Ticks (Component)
(mf/def horizontal-rule-ticks (mf/def horizontal-rule-ticks
:mixins #{mf/static} :mixins #{mf/memo}
:render :render
(fn [own zoom] (fn [own zoom]
(let [zoom (or zoom 1) (let [zoom (or zoom 1)
@ -118,7 +118,7 @@
;; --- Vertical Rule Ticks (Component) ;; --- Vertical Rule Ticks (Component)
(mf/def vertical-rule-ticks (mf/def vertical-rule-ticks
:mixins #{mf/static} :mixins #{mf/memo}
:render :render
(fn [own zoom] (fn [own zoom]
(let [zoom (or zoom 1) (let [zoom (or zoom 1)
@ -131,7 +131,7 @@
;; --- Horizontal Rule (Component) ;; --- Horizontal Rule (Component)
(mf/def horizontal-rule (mf/def horizontal-rule
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:render :render
(fn [own props] (fn [own props]
(let [scroll (mf/react refs/workspace-scroll) (let [scroll (mf/react refs/workspace-scroll)
@ -149,7 +149,7 @@
;; --- Vertical Rule (Component) ;; --- Vertical Rule (Component)
(mf/def vertical-rule (mf/def vertical-rule
:mixins #{mf/static mf/reactive} :mixins #{mf/memo mf/reactive}
:render :render
(fn [own props] (fn [own props]
(let [scroll (mf/react refs/workspace-scroll) (let [scroll (mf/react refs/workspace-scroll)

View file

@ -22,7 +22,7 @@
;; --- History Item (Component) ;; --- History Item (Component)
(mf/def history-item (mf/def history-item
:mixins [mf/static] :mixins [mf/memo]
:key-fn :id :key-fn :id
:render :render
(fn [own {:keys [::selected] :as item}] (fn [own {:keys [::selected] :as item}]
@ -47,7 +47,7 @@
;; --- History List (Component) ;; --- History List (Component)
(mf/def history-list (mf/def history-list
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own {:keys [selected items min-version] :as history}] (fn [own {:keys [selected items min-version] :as history}]
(let [items (reverse (sort-by :version items)) (let [items (reverse (sort-by :version items))
@ -65,7 +65,7 @@
;; --- History Pinned List (Component) ;; --- History Pinned List (Component)
(mf/def history-pinned-list (mf/def history-pinned-list
:mixins [mf/static] :mixins [mf/memo]
:render :render
(fn [own {:keys [pinned selected] :as history}] (fn [own {:keys [pinned selected] :as history}]
[:ul.history-content [:ul.history-content
@ -76,7 +76,7 @@
;; --- History Toolbox (Component) ;; --- History Toolbox (Component)
(mf/def history-toolbox (mf/def history-toolbox
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:init :init
(fn [own page-id] (fn [own page-id]
@ -119,7 +119,7 @@
;; --- History Dialog ;; --- History Dialog
(mf/def history-dialog (mf/def history-dialog
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own] (fn [own]
(let [history (mf/react refs/history) (let [history (mf/react refs/history)

View file

@ -91,7 +91,7 @@
;; --- Shape Name (Component) ;; --- Shape Name (Component)
(mf/def shape-name (mf/def shape-name
:mixins [mf/static (mf/local)] :mixins [mf/memo (mf/local)]
:render :render
(fn [{:keys [::mf/local] :as own} {:keys [id] :as shape}] (fn [{:keys [::mf/local] :as own} {:keys [id] :as shape}]
(letfn [(on-blur [event] (letfn [(on-blur [event]

View file

@ -26,7 +26,7 @@
[uxbox.util.router :as r])) [uxbox.util.router :as r]))
(mf/def page-item (mf/def page-item
:mixins [(mf/local) mf/static mf/reactive] :mixins [(mf/local) mf/memo mf/reactive]
:key-fn :id :key-fn :id
:render :render
@ -107,7 +107,7 @@
[:a {:on-click on-delete} i/trash])]]])))) [:a {:on-click on-delete} i/trash])]]]))))
(mf/def sitemap-toolbox (mf/def sitemap-toolbox
:mixins [mf/static mf/reactive] :mixins [mf/memo mf/reactive]
:render :render
(fn [own current-page-id] (fn [own current-page-id]