mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 00:01:40 +02:00
Merge branch 'staging' into develop
This commit is contained in:
commit
a85a65a554
15 changed files with 124 additions and 66 deletions
|
@ -697,7 +697,7 @@
|
|||
stopper (->> move-events
|
||||
(rx/debounce 100)
|
||||
(rx/take 1))
|
||||
scale (if shift? (gpt/point (:big nudge)) (gpt/point (:small nudge)))
|
||||
scale (if shift? (gpt/point (or (:big nudge) 10)) (gpt/point (or (:small nudge) 1)))
|
||||
mov-vec (gpt/multiply (get-displacement direction) scale)]
|
||||
|
||||
(rx/concat
|
||||
|
|
|
@ -82,12 +82,12 @@
|
|||
on-duplicate
|
||||
(fn [_]
|
||||
(apply st/emit! (map dd/duplicate-file files))
|
||||
(st/emit! (dm/success (tr "dashboard.success-duplicate-file"))))
|
||||
(st/emit! (dm/success (tr "dashboard.success-duplicate-file" (i18n/c (count files))))))
|
||||
|
||||
delete-fn
|
||||
(fn [_]
|
||||
(apply st/emit! (map dd/delete-file files))
|
||||
(st/emit! (dm/success (tr "dashboard.success-delete-file"))))
|
||||
(st/emit! (dm/success (tr "dashboard.success-delete-file" (i18n/c (count files))))))
|
||||
|
||||
on-delete
|
||||
(fn [event]
|
||||
|
|
|
@ -52,20 +52,19 @@
|
|||
(rx/throw error)))
|
||||
|
||||
(defn- on-success
|
||||
[form data]
|
||||
[profile data]
|
||||
(if (:changed data)
|
||||
(st/emit! (du/fetch-profile)
|
||||
(modal/hide))
|
||||
(let [email (get-in @form [:clean-data :email-1])
|
||||
message (tr "notifications.validation-email-sent" email)]
|
||||
(let [message (tr "notifications.validation-email-sent" (:email profile))]
|
||||
(st/emit! (dm/info message)
|
||||
(modal/hide)))))
|
||||
|
||||
(defn- on-submit
|
||||
[form _event]
|
||||
[profile form _event]
|
||||
(let [params {:email (get-in @form [:clean-data :email-1])}
|
||||
mdata {:on-error (partial on-error form)
|
||||
:on-success (partial on-success form)}]
|
||||
:on-success (partial on-success profile)}]
|
||||
(st/emit! (du/request-email-change (with-meta params mdata)))))
|
||||
|
||||
(mf/defc change-email-modal
|
||||
|
@ -77,7 +76,12 @@
|
|||
:validators [email-equality]
|
||||
:initial profile)
|
||||
on-close
|
||||
(mf/use-callback #(st/emit! (modal/hide)))]
|
||||
(mf/use-callback #(st/emit! (modal/hide)))
|
||||
|
||||
on-submit
|
||||
(mf/use-callback
|
||||
(mf/deps profile)
|
||||
(partial on-submit profile))]
|
||||
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.change-email-modal.form-container
|
||||
|
@ -86,7 +90,7 @@
|
|||
|
||||
[:div.modal-header
|
||||
[:div.modal-header-title
|
||||
[:h2 {:data-test "change-email-title"}
|
||||
[:h2 {:data-test "change-email-title"}
|
||||
(tr "modals.change-email.title")]]
|
||||
[:div.modal-close-button
|
||||
{:on-click on-close} i/close]]
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
(ns app.main.ui.viewer.comments
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.point :as gpt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
|
@ -27,21 +26,26 @@
|
|||
{::mf/wrap [mf/memo]
|
||||
::mf/wrap-props false}
|
||||
[]
|
||||
(let [local (mf/deref refs/comments-local)
|
||||
owner-filter (:owner-filter local)
|
||||
status-filter (:status-filter local)
|
||||
show-sidebar? (:show-sidebar? local)
|
||||
(let [{cmode :mode cshow :show show-sidebar? :show-sidebar?} (mf/deref refs/comments-local)
|
||||
|
||||
show-dropdown? (mf/use-state false)
|
||||
toggle-dropdown (mf/use-fn #(swap! show-dropdown? not))
|
||||
hide-dropdown (mf/use-fn #(reset! show-dropdown? false))
|
||||
|
||||
update-option (mf/use-fn
|
||||
(fn [event]
|
||||
(let [target (dom/get-current-target event)
|
||||
key (d/read-string (dom/get-attribute target "data-key"))
|
||||
val (d/read-string (dom/get-attribute target "data-val"))]
|
||||
(st/emit! (dcm/update-options {key val})))))]
|
||||
update-mode
|
||||
(mf/use-callback
|
||||
(fn [mode]
|
||||
(st/emit! (dcm/update-filters {:mode mode}))))
|
||||
|
||||
update-show
|
||||
(mf/use-callback
|
||||
(fn [mode]
|
||||
(st/emit! (dcm/update-filters {:show mode}))))
|
||||
|
||||
update-options
|
||||
(mf/use-callback
|
||||
(fn [mode]
|
||||
(st/emit! (dcm/update-options {:show-sidebar? mode}))))]
|
||||
|
||||
[:div.view-options {:on-click toggle-dropdown}
|
||||
[:span.label (tr "labels.comments")]
|
||||
|
@ -50,34 +54,26 @@
|
|||
:on-close hide-dropdown}
|
||||
|
||||
[:ul.dropdown.with-check
|
||||
[:li {:class (dom/classnames :selected (= :all owner-filter))
|
||||
:data-key ":owner-filter"
|
||||
:data-val ":all"
|
||||
:on-click update-option}
|
||||
[:li {:class (dom/classnames :selected (or (= :all cmode) (nil? cmode)))
|
||||
:on-click #(update-mode :all)}
|
||||
[:span.icon i/tick]
|
||||
[:span.label (tr "labels.show-all-comments")]]
|
||||
|
||||
[:li {:class (dom/classnames :selected (= :yours owner-filter))
|
||||
:data-key ":owner-filter"
|
||||
:data-val ":yours"
|
||||
:on-click update-option}
|
||||
[:li {:class (dom/classnames :selected (= :yours cmode))
|
||||
:on-click #(update-mode :yours)}
|
||||
[:span.icon i/tick]
|
||||
[:span.label (tr "labels.show-your-comments")]]
|
||||
|
||||
[:hr]
|
||||
|
||||
[:li {:class (dom/classnames :selected (= :pending status-filter))
|
||||
:data-key ":status-filter"
|
||||
:data-val (if (= :pending status-filter) ":all" ":pending")
|
||||
:on-click update-option}
|
||||
[:li {:class (dom/classnames :selected (= :pending cshow))
|
||||
:on-click #(update-show (if (= :pending cshow) :all :pending))}
|
||||
[:span.icon i/tick]
|
||||
[:span.label (tr "labels.hide-resolved-comments")]]
|
||||
|
||||
[:hr]
|
||||
[:li {:class (dom/classnames :selected show-sidebar?)
|
||||
:data-key ":show-sidebar?"
|
||||
:data-val (if show-sidebar? "false" "true")
|
||||
:on-click update-option}
|
||||
:on-click #(update-options (not show-sidebar?))}
|
||||
[:span.icon i/tick]
|
||||
[:span.label (tr "labels.show-comments-list")]]]]]))
|
||||
|
||||
|
|
|
@ -265,18 +265,19 @@
|
|||
|
||||
(mf/defc context-menu-path
|
||||
[{:keys [shapes disable-flatten? disable-booleans?]}]
|
||||
(let [multiple? (> (count shapes) 1)
|
||||
single? (= (count shapes) 1)
|
||||
(let [multiple? (> (count shapes) 1)
|
||||
single? (= (count shapes) 1)
|
||||
|
||||
has-group? (->> shapes (d/seek cph/group-shape?))
|
||||
has-bool? (->> shapes (d/seek cph/bool-shape?))
|
||||
has-frame? (->> shapes (d/seek cph/frame-shape?))
|
||||
has-group? (->> shapes (d/seek cph/group-shape?))
|
||||
has-bool? (->> shapes (d/seek cph/bool-shape?))
|
||||
has-frame? (->> shapes (d/seek cph/frame-shape?))
|
||||
has-path? (->> shapes (d/seek cph/path-shape?))
|
||||
|
||||
is-group? (and single? has-group?)
|
||||
is-bool? (and single? has-bool?)
|
||||
is-frame? (and single? has-frame?)
|
||||
is-group? (and single? has-group?)
|
||||
is-bool? (and single? has-bool?)
|
||||
is-frame? (and single? has-frame?)
|
||||
|
||||
do-start-editing (fn [] (timers/schedule #(st/emit! (dw/start-editing-selected))))
|
||||
do-start-editing (fn [] (timers/schedule #(st/emit! (dw/start-editing-selected))))
|
||||
do-transform-to-path #(st/emit! (dw/convert-selected-to-path))
|
||||
|
||||
make-do-bool
|
||||
|
@ -296,7 +297,7 @@
|
|||
:shortcut (sc/get-tooltip :start-editing)
|
||||
:on-click do-start-editing}])
|
||||
|
||||
(when-not (or disable-flatten? has-frame?)
|
||||
(when-not (or disable-flatten? has-frame? has-path?)
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.transform-to-path")
|
||||
:on-click do-transform-to-path}])
|
||||
|
||||
|
|
|
@ -330,7 +330,8 @@
|
|||
:show-artboard-names? show-artboard-names?
|
||||
:on-frame-enter on-frame-enter
|
||||
:on-frame-leave on-frame-leave
|
||||
:on-frame-select on-frame-select}]
|
||||
:on-frame-select on-frame-select
|
||||
:focus focus}]
|
||||
|
||||
(when show-prototypes?
|
||||
[:& widgets/frame-flows
|
||||
|
|
|
@ -17,15 +17,22 @@
|
|||
|
||||
(defn check-enabled [content selected-points]
|
||||
(let [segments (upt/get-segments content selected-points)
|
||||
num-segments (count segments)
|
||||
num-points (count selected-points)
|
||||
points-selected? (seq selected-points)
|
||||
segments-selected? (seq segments)]
|
||||
{:make-corner points-selected?
|
||||
:make-curve points-selected?
|
||||
segments-selected? (seq segments)
|
||||
;; max segments for n points is (n × (n -1)) / 2
|
||||
max-segments (-> num-points
|
||||
(* (- num-points 1))
|
||||
(/ 2))
|
||||
is-curve? (some #(upt/is-curve? content %) selected-points)]
|
||||
|
||||
{:make-corner (and points-selected? is-curve?)
|
||||
:make-curve (and points-selected? (not is-curve?))
|
||||
:add-node segments-selected?
|
||||
:remove-node points-selected?
|
||||
:merge-nodes segments-selected?
|
||||
:join-nodes (and points-selected? (>= num-points 2))
|
||||
:join-nodes (and points-selected? (>= num-points 2) (< num-segments max-segments))
|
||||
:separate-nodes segments-selected?}))
|
||||
|
||||
(mf/defc path-actions [{:keys [shape]}]
|
||||
|
|
|
@ -163,11 +163,15 @@
|
|||
on-frame-enter (unchecked-get props "on-frame-enter")
|
||||
on-frame-leave (unchecked-get props "on-frame-leave")
|
||||
on-frame-select (unchecked-get props "on-frame-select")
|
||||
frames (ctt/get-frames objects)]
|
||||
frames (ctt/get-frames objects)
|
||||
focus (unchecked-get props "focus")]
|
||||
|
||||
[:g.frame-titles
|
||||
(for [frame frames]
|
||||
(when (= (:parent-id frame) uuid/zero)
|
||||
(when (and
|
||||
(= (:parent-id frame) uuid/zero)
|
||||
(or (empty? focus)
|
||||
(contains? focus (:id frame))))
|
||||
[:& frame-title {:key (dm/str "frame-title-" (:id frame))
|
||||
:frame frame
|
||||
:selected? (contains? selected (:id frame))
|
||||
|
|
|
@ -74,6 +74,13 @@
|
|||
(assoc-in [:params :c2x] (:x h2))
|
||||
(assoc-in [:params :c2y] (:y h2)))))
|
||||
|
||||
(defn is-curve?
|
||||
[content point]
|
||||
(let [handlers (-> (upc/content->handlers content)
|
||||
(get point))
|
||||
handler-points (map #(upc/handler->point content (first %) (second %)) handlers)]
|
||||
(some #(not= point %) handler-points)))
|
||||
|
||||
(defn make-curve-point
|
||||
"Changes the content to make the point a 'curve'. The handlers will be positioned
|
||||
in the same vector that results from the previous->next points but with fixed length."
|
||||
|
@ -99,7 +106,6 @@
|
|||
:next-p (upc/command->point next)
|
||||
:command cmd)))))
|
||||
|
||||
|
||||
points (->> vectors (mapcat #(vector (:next-p %) (:prev-p %))) (remove nil?) (into #{}))]
|
||||
|
||||
(cond
|
||||
|
@ -124,8 +130,7 @@
|
|||
next-correction (when (some? next-h) (gpt/scale (gpt/to-vec next-h point) (/ 1 3)))
|
||||
|
||||
prev-h (when (some? prev-h) (gpt/add prev-h prev-correction))
|
||||
next-h (when (some? next-h) (gpt/add next-h next-correction))
|
||||
]
|
||||
next-h (when (some? next-h) (gpt/add next-h next-correction))]
|
||||
(cond-> content
|
||||
(and (= :line-to (:command cur-cmd)) (some? prev-p))
|
||||
(update index upc/update-curve-to prev-p prev-h)
|
||||
|
@ -147,7 +152,13 @@
|
|||
(= :line-to (:command command))
|
||||
(update index #(line->curve prev-p %))
|
||||
|
||||
(= :curve-to (:command command))
|
||||
(update index #(line->curve prev-p %))
|
||||
|
||||
(= :line-to (:command next-c))
|
||||
(update next-i #(line->curve point %))
|
||||
|
||||
(= :curve-to (:command next-c))
|
||||
(update next-i #(line->curve point %))))]
|
||||
(->> vectors (reduce add-curve content))))))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue