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

🐛 Fixes problems with saved grids

This commit is contained in:
alonso.torres 2020-09-14 15:47:49 +02:00 committed by Andrey Antukh
parent 0b4887ed96
commit 8dc3165e54
4 changed files with 37 additions and 7 deletions

View file

@ -46,10 +46,38 @@
(<= % max-safe-int)))
;; Page Options
(s/def :internal.page.grid.color/value string?)
(s/def :internal.page.grid.color/opacity number?)
;; TODO: missing specs for :saved-grids
(s/def :internal.page.grid/size ::safe-integer)
(s/def :internal.page.grid/color
(s/keys :req-un [:internal.page.grid.color/value
:internal.page.grid.color/opacity]))
(s/def :internal.page.grid/type #{:stretch :left :center :right})
(s/def :internal.page.grid/item-length (s/nilable ::safe-integer))
(s/def :internal.page.grid/gutter (s/nilable ::safe-integer))
(s/def :internal.page.grid/margin (s/nilable ::safe-integer))
(s/def :internal.page.grid/square
(s/keys :req-un [:internal.page.grid/size
:internal.page.grid/color]))
(s/def :internal.page.grid/column
(s/keys :req-un [:internal.page.grid/size
:internal.page.grid/color
:internal.page.grid/type
:internal.page.grid/item-length
:internal.page.grid/gutter
:internal.page.grid/margin]))
(s/def :internal.page.grid/row :internal.page.grid/column)
(s/def :internal.page.options/background string?)
(s/def :internal.page.options/saved-grids
(s/keys :req-un [:internal.page.grid/square
:internal.page.grid/row
:internal.page.grid/column]))
(s/def :internal.page/options
(s/keys :opt-un [:internal.page.options/background]))

View file

@ -75,11 +75,13 @@
ptk/WatchEvent
(watch [_ state stream]
(let [pid (:current-page-id state)
prev-value (get-in state [:workspace-data pid :options :saved-grids type])]
prev-value (get-in state [:workspace-data :pages-index pid :options :saved-grids type])]
(rx/of (dwc/commit-changes [{:type :set-option
:page-id pid
:option [:saved-grids type]
:value params}]
[{:type :set-option
:page-id pid
:option [:saved-grids type]
:value prev-value}]
{:commit-local? true}))))))

View file

@ -140,10 +140,6 @@
(def workspace-page-options
(l/derived :options workspace-page))
;; TODO: revisit
(def workspace-saved-grids
(l/derived :saved-grids workspace-page-options))
(def workspace-frames
(l/derived cph/select-frames workspace-page-objects))

View file

@ -10,6 +10,7 @@
(ns app.main.ui.workspace.sidebar.options.frame-grid
(:require
[rumext.alpha :as mf]
[okulary.core :as l]
[app.util.dom :as dom]
[app.util.data :as d]
[app.common.math :as mth]
@ -26,6 +27,9 @@
[app.main.ui.components.dropdown :refer [dropdown]]
[app.util.i18n :as i18n :refer [tr t]]))
(def workspace-saved-grids
(l/derived :saved-grids refs/workspace-page-options))
(mf/defc advanced-options [{:keys [visible? on-close children]}]
(when visible?
[:*
@ -229,7 +233,7 @@
(mf/defc frame-grid [{:keys [shape]}]
(let [locale (i18n/use-locale)
id (:id shape)
default-grid-params (merge dw/default-grid-params (mf/deref refs/workspace-saved-grids))
default-grid-params (merge dw/default-grid-params (mf/deref workspace-saved-grids))
handle-create-grid #(st/emit! (dw/add-frame-grid id))
handle-remove-grid (fn [index] #(st/emit! (dw/remove-frame-grid id index)))
handle-edit-grid (fn [index] #(st/emit! (dw/set-frame-grid id index %)))