mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 09:08:31 -05:00
🐛 Fix naming consistency and page background forwarding
This commit is contained in:
parent
237af505f9
commit
d5b163f04d
3 changed files with 36 additions and 34 deletions
|
@ -120,8 +120,7 @@
|
|||
{:options-mode :design})
|
||||
|
||||
(def default-workspace-local
|
||||
{:zoom 1
|
||||
:selected (d/ordered-set)})
|
||||
{:zoom 1})
|
||||
|
||||
(defn ensure-layout
|
||||
[lname]
|
||||
|
@ -258,19 +257,20 @@
|
|||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [;; we maintain a cache of page state for user convenience
|
||||
;; with the exception of the selection; when user abandon
|
||||
;; the current page, the selection is lost
|
||||
page (get-in state [:workspace-data :pages-index page-id])
|
||||
page-id (:id page)
|
||||
local (-> state
|
||||
(get-in [:workspace-cache page-id] default-workspace-local)
|
||||
(if-let [{:keys [id] :as page} (get-in state [:workspace-data :pages-index page-id])]
|
||||
;; we maintain a cache of page state for user convenience with
|
||||
;; the exception of the selection; when user abandon the
|
||||
;; current page, the selection is lost
|
||||
(let [local (-> state
|
||||
(get-in [:workspace-cache id] default-workspace-local)
|
||||
(assoc :selected (d/ordered-set)))]
|
||||
(-> state
|
||||
(assoc :current-page-id page-id)
|
||||
(assoc :trimmed-page (select-keys page [:id :name]))
|
||||
(assoc :workspace-local local)
|
||||
(update-in [:route :params :query] assoc :page-id (str page-id)))))))
|
||||
(-> state
|
||||
(assoc :current-page-id id)
|
||||
(assoc :trimmed-page (dm/select-keys page [:id :name]))
|
||||
(assoc :workspace-local local)
|
||||
(update :workspace-global assoc :background-color (-> page :options :background))
|
||||
(update-in [:route :params :query] assoc :page-id (dm/str id))))
|
||||
state))))
|
||||
|
||||
(defn finalize-page
|
||||
[page-id]
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
file (obj/get props "file")
|
||||
layout (obj/get props "layout")
|
||||
|
||||
{:keys [vport] :as local} (mf/deref refs/workspace-local)
|
||||
{:keys [options-mode] :as wstate} (mf/deref refs/workspace-global)
|
||||
{:keys [vport] :as wlocal} (mf/deref refs/workspace-local)
|
||||
{:keys [options-mode] :as wglobal} (obj/get props "wglobal")
|
||||
|
||||
colorpalette? (:colorpalette layout)
|
||||
textpalette? (:textpalette layout)
|
||||
|
@ -51,7 +51,7 @@
|
|||
|
||||
on-resize
|
||||
(mf/use-callback
|
||||
(mf/deps (:vport local))
|
||||
(mf/deps vport)
|
||||
(fn [resize-type size]
|
||||
(when vport
|
||||
(st/emit! (dw/update-viewport-size resize-type size)))))
|
||||
|
@ -70,8 +70,8 @@
|
|||
[:& coordinates/coordinates {:colorpalette? colorpalette?}])
|
||||
|
||||
[:& viewport {:file file
|
||||
:local local
|
||||
:wstate wstate
|
||||
:wlocal wlocal
|
||||
:wglobal wglobal
|
||||
:selected selected
|
||||
:layout layout}]]]
|
||||
|
||||
|
@ -89,22 +89,20 @@
|
|||
(def trimmed-page-ref (l/derived :trimmed-page st/state =))
|
||||
|
||||
(mf/defc workspace-page
|
||||
[{:keys [file layout page-id] :as props}]
|
||||
[{:keys [file layout page-id wglobal] :as props}]
|
||||
|
||||
(mf/use-layout-effect
|
||||
(mf/deps page-id)
|
||||
(mf/with-effect [page-id]
|
||||
(if (nil? page-id)
|
||||
(st/emit! (dw/go-to-page))
|
||||
(st/emit! (dw/initialize-page page-id)))
|
||||
(fn []
|
||||
(if (nil? page-id)
|
||||
(st/emit! (dw/go-to-page))
|
||||
(st/emit! (dw/initialize-page page-id)))
|
||||
|
||||
(fn []
|
||||
(when page-id
|
||||
(st/emit! (dw/finalize-page page-id))))))
|
||||
(when page-id
|
||||
(st/emit! (dw/finalize-page page-id)))))
|
||||
|
||||
(when (mf/deref trimmed-page-ref)
|
||||
[:& workspace-content {:key (dm/str page-id)
|
||||
:file file
|
||||
:wglobal wglobal
|
||||
:layout layout}]))
|
||||
|
||||
(mf/defc workspace-loader
|
||||
|
@ -117,7 +115,10 @@
|
|||
[{:keys [project-id file-id page-id layout-name] :as props}]
|
||||
(let [file (mf/deref refs/workspace-file)
|
||||
project (mf/deref refs/workspace-project)
|
||||
layout (mf/deref refs/workspace-layout)]
|
||||
layout (mf/deref refs/workspace-layout)
|
||||
wglobal (mf/deref refs/workspace-global)
|
||||
|
||||
background-color (:background-color wglobal)]
|
||||
|
||||
;; Setting the layout preset by its name
|
||||
(mf/with-effect [layout-name]
|
||||
|
@ -142,7 +143,7 @@
|
|||
[:& (mf/provider ctx/current-team-id) {:value (:team-id project)}
|
||||
[:& (mf/provider ctx/current-project-id) {:value (:id project)}
|
||||
[:& (mf/provider ctx/current-page-id) {:value page-id}
|
||||
[:section#workspace
|
||||
[:section#workspace {:style {:background-color background-color}}
|
||||
(when (not (:hide-ui layout))
|
||||
[:& header {:file file
|
||||
:page-id page-id
|
||||
|
@ -156,6 +157,7 @@
|
|||
[:& workspace-page {:key (dm/str "page-" page-id)
|
||||
:page-id page-id
|
||||
:file file
|
||||
:wglobal wglobal
|
||||
:layout layout}]
|
||||
[:& workspace-loader])]]]]]))
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
;; --- Viewport
|
||||
|
||||
(mf/defc viewport
|
||||
[{:keys [local wstate selected layout file] :as props}]
|
||||
[{:keys [wlocal wglobal selected layout file] :as props}]
|
||||
(let [;; When adding data from workspace-local revisit `app.main.ui.workspace` to check
|
||||
;; that the new parameter is sent
|
||||
{:keys [edit-path
|
||||
|
@ -52,12 +52,12 @@
|
|||
vbox
|
||||
vport
|
||||
zoom
|
||||
edition]} local
|
||||
edition]} wlocal
|
||||
|
||||
{:keys [options-mode
|
||||
tooltip
|
||||
show-distances?
|
||||
picking-color?]} wstate
|
||||
picking-color?]} wglobal
|
||||
|
||||
;; CONTEXT
|
||||
page-id (mf/use-ctx ctx/current-page-id)
|
||||
|
|
Loading…
Add table
Reference in a new issue