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