mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Merge pull request #4011 from penpot/alotor-bugfixes-7
Alotor bugfixes 7
This commit is contained in:
commit
0688f6a4a3
11 changed files with 65 additions and 35 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns app.common.geom.shapes.bool
|
(ns app.common.geom.shapes.bool
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.files.helpers :as cpf]
|
||||||
[app.common.svg.path.bool :as pb]
|
[app.common.svg.path.bool :as pb]
|
||||||
[app.common.svg.path.shapes-to-path :as stp]))
|
[app.common.svg.path.shapes-to-path :as stp]))
|
||||||
|
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
(let [extract-content-xf
|
(let [extract-content-xf
|
||||||
(comp (map (d/getf objects))
|
(comp (map (d/getf objects))
|
||||||
(filter (comp not :hidden))
|
(filter (comp not :hidden))
|
||||||
|
(remove cpf/svg-raw-shape?)
|
||||||
(map #(stp/convert-to-path % objects))
|
(map #(stp/convert-to-path % objects))
|
||||||
(map :content))
|
(map :content))
|
||||||
|
|
||||||
|
|
|
@ -827,7 +827,7 @@
|
||||||
0)))))
|
0)))))
|
||||||
|
|
||||||
(defn- add-component-for-swap
|
(defn- add-component-for-swap
|
||||||
[shape file-id id-new-component target-cell]
|
[shape file-id id-new-component index target-cell]
|
||||||
(dm/assert! (uuid? id-new-component))
|
(dm/assert! (uuid? id-new-component))
|
||||||
(dm/assert! (uuid? file-id))
|
(dm/assert! (uuid? file-id))
|
||||||
(ptk/reify ::add-component-for-swap
|
(ptk/reify ::add-component-for-swap
|
||||||
|
@ -837,7 +837,6 @@
|
||||||
libraries (wsh/get-libraries state)
|
libraries (wsh/get-libraries state)
|
||||||
|
|
||||||
objects (:objects page)
|
objects (:objects page)
|
||||||
index (find-shape-index objects (:parent-id shape) (:id shape))
|
|
||||||
position (gpt/point (:x shape) (:y shape))
|
position (gpt/point (:x shape) (:y shape))
|
||||||
changes (-> (pcb/empty-changes it (:id page))
|
changes (-> (pcb/empty-changes it (:id page))
|
||||||
(pcb/with-objects objects))
|
(pcb/with-objects objects))
|
||||||
|
@ -877,9 +876,11 @@
|
||||||
|
|
||||||
;; If the target parent is a grid layout we need to pass the target cell
|
;; If the target parent is a grid layout we need to pass the target cell
|
||||||
target-cell (when (ctl/grid-layout? parent)
|
target-cell (when (ctl/grid-layout? parent)
|
||||||
(ctl/get-cell-by-shape-id parent (:id shape)))]
|
(ctl/get-cell-by-shape-id parent (:id shape)))
|
||||||
|
|
||||||
|
index (find-shape-index objects (:parent-id shape) (:id shape))]
|
||||||
(rx/of (dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true})
|
(rx/of (dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true})
|
||||||
(add-component-for-swap shape file-id id-new-component target-cell)
|
(add-component-for-swap shape file-id id-new-component index target-cell)
|
||||||
(ptk/data-event :layout/update [(:parent-id shape)]))))))
|
(ptk/data-event :layout/update [(:parent-id shape)]))))))
|
||||||
|
|
||||||
(defn component-multi-swap
|
(defn component-multi-swap
|
||||||
|
|
|
@ -210,8 +210,9 @@
|
||||||
|
|
||||||
(defn search-snap-distance [selrect coord shapes-lt shapes-gt zoom]
|
(defn search-snap-distance [selrect coord shapes-lt shapes-gt zoom]
|
||||||
(->> (rx/combine-latest shapes-lt shapes-gt)
|
(->> (rx/combine-latest shapes-lt shapes-gt)
|
||||||
(rx/map (fn [[shapes-lt shapes-gt]]
|
(rx/map
|
||||||
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
|
(fn [[shapes-lt shapes-gt]]
|
||||||
|
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
|
||||||
|
|
||||||
(defn select-shapes-area
|
(defn select-shapes-area
|
||||||
[page-id frame-id selected objects area]
|
[page-id frame-id selected objects area]
|
||||||
|
@ -233,12 +234,12 @@
|
||||||
(rx/merge-map
|
(rx/merge-map
|
||||||
(fn [[frame selrect]]
|
(fn [[frame selrect]]
|
||||||
(let [vbox (deref refs/vbox)
|
(let [vbox (deref refs/vbox)
|
||||||
|
|
||||||
frame-id (->> shapes first :frame-id)
|
frame-id (->> shapes first :frame-id)
|
||||||
|
frame-sr (when-not (cfh/root? frame) (dm/get-prop frame :selrect))
|
||||||
|
bounds (d/nilv (grc/clip-rect frame-sr vbox) vbox)
|
||||||
selected (into #{} (map :id shapes))
|
selected (into #{} (map :id shapes))
|
||||||
areas (->> (gsh/get-areas
|
areas (->> (gsh/get-areas bounds selrect)
|
||||||
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox)
|
|
||||||
vbox)
|
|
||||||
selrect)
|
|
||||||
(d/mapm #(select-shapes-area page-id frame-id selected objects %2)))
|
(d/mapm #(select-shapes-area page-id frame-id selected objects %2)))
|
||||||
snap-x (search-snap-distance selrect :x (:left areas) (:right areas) zoom)
|
snap-x (search-snap-distance selrect :x (:left areas) (:right areas) zoom)
|
||||||
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas) zoom)]
|
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas) zoom)]
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
(swap! form assoc-in [:touched input-name] true)))
|
(swap! form assoc-in [:touched input-name] true)))
|
||||||
|
|
||||||
props (-> props
|
props (-> props
|
||||||
(dissoc :help-icon :form :trim :children :show-success?)
|
(dissoc :help-icon :form :trim :children :show-success? :auto-focus?)
|
||||||
(assoc :id (name input-name)
|
(assoc :id (name input-name)
|
||||||
:value value
|
:value value
|
||||||
:auto-focus auto-focus?
|
:auto-focus auto-focus?
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[cljs.spec.alpha :as s]
|
[cljs.spec.alpha :as s]
|
||||||
|
@ -74,6 +76,15 @@
|
||||||
:validators [(fm/validate-not-empty :name (tr "auth.name.not-all-space"))
|
:validators [(fm/validate-not-empty :name (tr "auth.name.not-all-space"))
|
||||||
(fm/validate-length :name fm/max-length-allowed (tr "auth.name.too-long"))]
|
(fm/validate-length :name fm/max-length-allowed (tr "auth.name.too-long"))]
|
||||||
:initial initial)
|
:initial initial)
|
||||||
|
handle-keydown
|
||||||
|
(mf/use-callback
|
||||||
|
(mf/deps)
|
||||||
|
(fn [e]
|
||||||
|
(when (kbd/enter? e)
|
||||||
|
(dom/prevent-default e)
|
||||||
|
(dom/stop-propagation e)
|
||||||
|
(on-submit form e))))
|
||||||
|
|
||||||
on-close #(st/emit! (modal/hide))]
|
on-close #(st/emit! (modal/hide))]
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-overlay)}
|
[:div {:class (stl/css :modal-overlay)}
|
||||||
|
@ -97,7 +108,8 @@
|
||||||
:form form
|
:form form
|
||||||
:name :name
|
:name :name
|
||||||
:placeholder "E.g. Design"
|
:placeholder "E.g. Design"
|
||||||
:label (tr "labels.create-team.placeholder")}]]
|
:label (tr "labels.create-team.placeholder")
|
||||||
|
:on-key-down handle-keydown}]]
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-footer)}
|
[:div {:class (stl/css :modal-footer)}
|
||||||
[:div {:class (stl/css :action-buttons)}
|
[:div {:class (stl/css :action-buttons)}
|
||||||
|
|
|
@ -114,6 +114,13 @@
|
||||||
(s/keys :req-un [::experience-design-tool]
|
(s/keys :req-un [::experience-design-tool]
|
||||||
:opt-un [::experience-design-tool-other]))
|
:opt-un [::experience-design-tool-other]))
|
||||||
|
|
||||||
|
(defn- step-1-form-validator
|
||||||
|
[errors data]
|
||||||
|
(let [planning (-> (:planning data) (str/trim))]
|
||||||
|
(cond-> errors
|
||||||
|
(= planning "")
|
||||||
|
(assoc :planning {:code "missing"}))))
|
||||||
|
|
||||||
(defn- step-3-form-validator
|
(defn- step-3-form-validator
|
||||||
[errors data]
|
[errors data]
|
||||||
(let [experience-design-tool (:experience-design-tool data)
|
(let [experience-design-tool (:experience-design-tool data)
|
||||||
|
@ -209,6 +216,7 @@
|
||||||
;; and we want to keep the filled info
|
;; and we want to keep the filled info
|
||||||
step-1-form (fm/use-form
|
step-1-form (fm/use-form
|
||||||
:initial {}
|
:initial {}
|
||||||
|
:validators [step-1-form-validator]
|
||||||
:spec ::questions-form-step-1)
|
:spec ::questions-form-step-1)
|
||||||
step-2-form (fm/use-form
|
step-2-form (fm/use-form
|
||||||
:initial {}
|
:initial {}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.viewer-content {
|
.viewer-content {
|
||||||
|
overflow: hidden;
|
||||||
grid-row: 2 / span 1;
|
grid-row: 2 / span 1;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: $s-252 auto;
|
grid-template-rows: $s-252 auto;
|
||||||
|
|
|
@ -913,9 +913,10 @@
|
||||||
[:button {:class (stl/css :layout-option) :on-click set-flex} "Flex layout"]
|
[:button {:class (stl/css :layout-option) :on-click set-flex} "Flex layout"]
|
||||||
[:button {:class (stl/css :layout-option) :on-click set-grid} "Grid layout"]]]])
|
[:button {:class (stl/css :layout-option) :on-click set-grid} "Grid layout"]]]])
|
||||||
|
|
||||||
[:button {:class (stl/css :remove-layout)
|
(when has-layout?
|
||||||
:on-click on-remove-layout}
|
[:button {:class (stl/css :remove-layout)
|
||||||
i/remove-refactor]]
|
:on-click on-remove-layout}
|
||||||
|
i/remove-refactor])]
|
||||||
|
|
||||||
[:div {:class (stl/css :title-actions)}
|
[:div {:class (stl/css :title-actions)}
|
||||||
(if ^boolean grid-enabled?
|
(if ^boolean grid-enabled?
|
||||||
|
@ -933,9 +934,10 @@
|
||||||
:data-value "flex"
|
:data-value "flex"
|
||||||
:on-click on-set-layout}
|
:on-click on-set-layout}
|
||||||
i/add-refactor])
|
i/add-refactor])
|
||||||
[:button {:class (stl/css :remove-layout)
|
(when has-layout?
|
||||||
:on-click on-remove-layout}
|
[:button {:class (stl/css :remove-layout)
|
||||||
i/remove-refactor]])]]
|
:on-click on-remove-layout}
|
||||||
|
i/remove-refactor])])]]
|
||||||
|
|
||||||
(when (and open? has-layout?)
|
(when (and open? has-layout?)
|
||||||
(when (not= :multiple layout-type)
|
(when (not= :multiple layout-type)
|
||||||
|
|
|
@ -407,7 +407,7 @@
|
||||||
[:div {:class (stl/css :row)}
|
[:div {:class (stl/css :row)}
|
||||||
[:& align-self-row {:is-col? is-col?
|
[:& align-self-row {:is-col? is-col?
|
||||||
:align-self align-self
|
:align-self align-self
|
||||||
:on-changer set-align-self}]])
|
:on-change set-align-self}]])
|
||||||
|
|
||||||
(when is-layout-child?
|
(when is-layout-child?
|
||||||
[:div {:class (stl/css :row)}
|
[:div {:class (stl/css :row)}
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
:on-pointer-up on-pointer-up}]])
|
:on-pointer-up on-pointer-up}]])
|
||||||
|
|
||||||
(mf/defc gradient-handler-transformed
|
(mf/defc gradient-handler-transformed
|
||||||
[{:keys [from-p to-p width-p from-color to-color zoom editing
|
[{:keys [from-p to-p width-p from-color to-color zoom editing transform
|
||||||
on-change-start on-change-finish on-change-width]}]
|
on-change-start on-change-finish on-change-width]}]
|
||||||
(let [moving-point (mf/use-var nil)
|
(let [moving-point (mf/use-var nil)
|
||||||
angle (+ 90 (gpt/angle from-p to-p))
|
angle (+ 90 (gpt/angle from-p to-p))
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
(reset! moving-point nil))]
|
(reset! moving-point nil))]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps @moving-point from-p to-p width-p)
|
(mf/deps @moving-point from-p to-p width-p transform)
|
||||||
(fn []
|
(fn []
|
||||||
(let [subs (->> st/stream
|
(let [subs (->> st/stream
|
||||||
(rx/filter mse/pointer-event?)
|
(rx/filter mse/pointer-event?)
|
||||||
|
@ -159,17 +159,18 @@
|
||||||
(rx/map mse/get-pointer-position)
|
(rx/map mse/get-pointer-position)
|
||||||
(rx/subs!
|
(rx/subs!
|
||||||
(fn [pt]
|
(fn [pt]
|
||||||
(case @moving-point
|
(let [pt (gpt/transform pt transform)]
|
||||||
:from-p (when on-change-start (on-change-start pt))
|
(case @moving-point
|
||||||
:to-p (when on-change-finish (on-change-finish pt))
|
:from-p (when on-change-start (on-change-start pt))
|
||||||
:width-p (when on-change-width
|
:to-p (when on-change-finish (on-change-finish pt))
|
||||||
(let [width-v (gpt/unit (gpt/to-vec from-p width-p))
|
:width-p (when on-change-width
|
||||||
distance (gpt/point-line-distance pt from-p to-p)
|
(let [width-v (gpt/unit (gpt/to-vec from-p width-p))
|
||||||
new-width-p (gpt/add
|
distance (gpt/point-line-distance pt from-p to-p)
|
||||||
from-p
|
new-width-p (gpt/add
|
||||||
(gpt/multiply width-v (gpt/point distance)))]
|
from-p
|
||||||
(on-change-width new-width-p)))
|
(gpt/multiply width-v (gpt/point distance)))]
|
||||||
nil))))]
|
(on-change-width new-width-p)))
|
||||||
|
nil)))))]
|
||||||
(fn [] (rx/dispose! subs)))))
|
(fn [] (rx/dispose! subs)))))
|
||||||
[:g.gradient-handlers
|
[:g.gradient-handlers
|
||||||
[:defs
|
[:defs
|
||||||
|
@ -295,6 +296,7 @@
|
||||||
:width-p (when (= :radial (:type gradient)) width-p)
|
:width-p (when (= :radial (:type gradient)) width-p)
|
||||||
:from-color {:value start-color :opacity start-opacity}
|
:from-color {:value start-color :opacity start-opacity}
|
||||||
:to-color {:value end-color :opacity end-opacity}
|
:to-color {:value end-color :opacity end-opacity}
|
||||||
|
:transform transform
|
||||||
:zoom zoom
|
:zoom zoom
|
||||||
:on-change-start on-change-start
|
:on-change-start on-change-start
|
||||||
:on-change-finish on-change-finish
|
:on-change-finish on-change-finish
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.files.helpers :as cph]
|
||||||
[app.common.geom.rect :as grc]
|
[app.common.geom.rect :as grc]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
@ -212,9 +213,9 @@
|
||||||
gt-side (if (= coord :x) :right :bottom)
|
gt-side (if (= coord :x) :right :bottom)
|
||||||
|
|
||||||
vbox (deref refs/vbox)
|
vbox (deref refs/vbox)
|
||||||
areas (gsh/get-areas
|
frame-sr (when-not (cph/root? frame) (dm/get-prop frame :selrect))
|
||||||
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox) vbox)
|
bounds (d/nilv (grc/clip-rect frame-sr vbox) vbox)
|
||||||
selrect)
|
areas (gsh/get-areas bounds selrect)
|
||||||
|
|
||||||
query-side
|
query-side
|
||||||
(fn [side]
|
(fn [side]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue