💄 Format frontend code

This commit is contained in:
Andrey Antukh 2024-01-05 14:23:30 +01:00 committed by Alonso Torres
parent b6ecc8b1be
commit 833871df65
150 changed files with 1735 additions and 1770 deletions

View file

@ -3,6 +3,7 @@
:remove-surrounding-whitespace? true :remove-surrounding-whitespace? true
:remove-consecutive-blank-lines? false :remove-consecutive-blank-lines? false
:extra-indents {rumext.v2/fnc [[:inner 0]] :extra-indents {rumext.v2/fnc [[:inner 0]]
cljs.test/async [[:inner 0]]
promesa.exec/thread [[:inner 0]] promesa.exec/thread [[:inner 0]]
specify! [[:inner 0] [:inner 1]]} specify! [[:inner 0] [:inner 1]]}
} }

View file

@ -133,8 +133,8 @@
(rx/reduce conj []) (rx/reduce conj [])
(rx/with-latest-from files-stream) (rx/with-latest-from files-stream)
(rx/merge-map (fn [[data _]] (rx/merge-map (fn [[data _]]
(->> (uz/compress-files data) (->> (uz/compress-files data)
(rx/map #(vector file %))))))))) (rx/map #(vector file %)))))))))
(deftype File [^:mutable file] (deftype File [^:mutable file]
Object Object
@ -263,4 +263,4 @@
(File. (fb/create-file name))) (File. (fb/create-file name)))
(defn exports [] (defn exports []
#js { :createFile create-file-export }) #js {:createFile create-file-export})

View file

@ -22,7 +22,7 @@
(fn [resolve reject] (fn [resolve reject]
(->> (r/render-page data) (->> (r/render-page data)
(rx/take 1) (rx/take 1)
(rx/subs! resolve reject))) ))) (rx/subs! resolve reject))))))
(defn exports [] (defn exports []
#js {:renderPage render-page-export}) #js {:renderPage render-page-export})

View file

@ -171,14 +171,14 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [share-id (-> state :viewer-local :share-id)] (let [share-id (-> state :viewer-local :share-id)]
(->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id}) (->> (rp/cmd! :update-comment-thread {:id id :is-resolved is-resolved :share-id share-id})
(rx/catch (fn [{:keys [type code] :as cause}] (rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction) (if (and (= type :restriction)
(= code :max-quote-reached)) (= code :max-quote-reached))
(rx/throw cause) (rx/throw cause)
(rx/throw {:type :comment-error})))) (rx/throw {:type :comment-error}))))
(rx/ignore)))))) (rx/ignore))))))
(defn add-comment (defn add-comment
[thread content] [thread content]
@ -196,16 +196,16 @@
(ptk/reify ::create-comment (ptk/reify ::create-comment
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [share-id (-> state :viewer-local :share-id)] (let [share-id (-> state :viewer-local :share-id)]
(rx/concat (rx/concat
(->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id}) (->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id})
(rx/map #(partial created %)) (rx/map #(partial created %))
(rx/catch (fn [{:keys [type code] :as cause}] (rx/catch (fn [{:keys [type code] :as cause}]
(if (and (= type :restriction) (if (and (= type :restriction)
(= code :max-quote-reached)) (= code :max-quote-reached))
(rx/throw cause) (rx/throw cause)
(rx/throw {:type :comment-error}))))) (rx/throw {:type :comment-error})))))
(rx/of (refresh-comment-thread thread)))))))) (rx/of (refresh-comment-thread thread))))))))
(defn update-comment (defn update-comment
[{:keys [id content thread-id] :as comment}] [{:keys [id content thread-id] :as comment}]
@ -309,14 +309,14 @@
(-> (->
(assoc-in (conj path :position) (:position comment-thread)) (assoc-in (conj path :position) (:position comment-thread))
(assoc-in (conj path :frame-id) (:frame-id comment-thread)))))) (assoc-in (conj path :frame-id) (:frame-id comment-thread))))))
(fetched [[users comments] state] (fetched [[users comments] state]
(let [pages (-> (get-in state [:workspace-data :pages]) (let [pages (-> (get-in state [:workspace-data :pages])
set) set)
comments (filter #(contains? pages (:page-id %)) comments) comments (filter #(contains? pages (:page-id %)) comments)
state (-> state state (-> state
(assoc :comment-threads (d/index-by :id comments)) (assoc :comment-threads (d/index-by :id comments))
(update :current-file-comments-users merge (d/index-by :id users)))] (update :current-file-comments-users merge (d/index-by :id users)))]
(reduce set-comment-threds state comments)))] (reduce set-comment-threds state comments)))]
(ptk/reify ::retrieve-comment-threads (ptk/reify ::retrieve-comment-threads
ptk/WatchEvent ptk/WatchEvent
@ -491,23 +491,23 @@
([thread] ([thread]
(update-comment-thread-frame thread uuid/zero)) (update-comment-thread-frame thread uuid/zero))
([thread frame-id] ([thread frame-id]
(dm/assert! (dm/assert!
"expected valid comment thread" "expected valid comment thread"
(check-comment-thread! thread)) (check-comment-thread! thread))
(ptk/reify ::update-comment-thread-frame (ptk/reify ::update-comment-thread-frame
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [thread-id (:id thread)] (let [thread-id (:id thread)]
(assoc-in state [:comment-threads thread-id :frame-id] frame-id))) (assoc-in state [:comment-threads thread-id :frame-id] frame-id)))
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(let [thread-id (:id thread)] (let [thread-id (:id thread)]
(->> (rp/cmd! :update-comment-thread-frame {:id thread-id :frame-id frame-id}) (->> (rp/cmd! :update-comment-thread-frame {:id thread-id :frame-id frame-id})
(rx/catch #(rx/throw {:type :comment-error :code :update-comment-thread-frame})) (rx/catch #(rx/throw {:type :comment-error :code :update-comment-thread-frame}))
(rx/ignore))))))) (rx/ignore)))))))
(defn detach-comment-thread (defn detach-comment-thread
"Detach comment threads that are inside a frame when that frame is deleted" "Detach comment threads that are inside a frame when that frame is deleted"

View file

@ -306,8 +306,8 @@
(ptk/reify ::fetch-builtin-templates (ptk/reify ::fetch-builtin-templates
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(->> (rp/cmd! :get-builtin-templates) (->> (rp/cmd! :get-builtin-templates)
(rx/map builtin-templates-fetched))))) (rx/map builtin-templates-fetched)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Data Selection ;; Data Selection
@ -320,7 +320,7 @@
(update [_ state] (update [_ state]
(update state :dashboard-local (update state :dashboard-local
assoc :selected-files #{} assoc :selected-files #{}
:selected-project nil)))) :selected-project nil))))
(defn toggle-file-select (defn toggle-file-select
[{:keys [id project-id] :as file}] [{:keys [id project-id] :as file}]
@ -377,10 +377,10 @@
:or {on-success identity :or {on-success identity
on-error rx/throw}} (meta params) on-error rx/throw}} (meta params)
features (features/get-enabled-features state)] features (features/get-enabled-features state)]
params {:name name params {:name name
:emails #{emails} :emails #{emails}
:role role :role role
:features features} :features features}
(->> (rp/cmd! :create-team-with-invitations params) (->> (rp/cmd! :create-team-with-invitations params)
(rx/tap on-success) (rx/tap on-success)
(rx/map team-created) (rx/map team-created)
@ -817,7 +817,7 @@
(d/update-in-when [:dashboard-files id :is-shared] (constantly is-shared)) (d/update-in-when [:dashboard-files id :is-shared] (constantly is-shared))
(d/update-in-when [:dashboard-recent-files id :is-shared] (constantly is-shared)) (d/update-in-when [:dashboard-recent-files id :is-shared] (constantly is-shared))
(cond-> (cond->
(not is-shared) (not is-shared)
(d/update-when :dashboard-shared-files dissoc id)))) (d/update-when :dashboard-shared-files dissoc id))))
ptk/WatchEvent ptk/WatchEvent
@ -1010,9 +1010,9 @@
(let [team-id (:current-team-id state)] (let [team-id (:current-team-id state)]
(if (empty? term) (if (empty? term)
(do (do
(dom/focus! (dom/get-element "search-input")) (dom/focus! (dom/get-element "search-input"))
(rx/of (rt/nav :dashboard-search (rx/of (rt/nav :dashboard-search
{:team-id team-id}))) {:team-id team-id})))
(rx/of (rt/nav :dashboard-search (rx/of (rt/nav :dashboard-search
{:team-id team-id} {:team-id team-id}
{:search-term term}))))) {:search-term term})))))

View file

@ -59,16 +59,16 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ stream] (watch [_ _ stream]
(rx/merge (rx/merge
(let [stoper (rx/filter (ptk/type? ::hide) stream)] (let [stoper (rx/filter (ptk/type? ::hide) stream)]
(->> stream (->> stream
(rx/filter (ptk/type? :app.util.router/navigate)) (rx/filter (ptk/type? :app.util.router/navigate))
(rx/map (constantly hide)) (rx/map (constantly hide))
(rx/take-until stoper))) (rx/take-until stoper)))
(when (:timeout data) (when (:timeout data)
(let [stoper (rx/filter (ptk/type? ::show) stream)] (let [stoper (rx/filter (ptk/type? ::show) stream)]
(->> (rx/of hide) (->> (rx/of hide)
(rx/delay (:timeout data)) (rx/delay (:timeout data))
(rx/take-until stoper)))))))) (rx/take-until stoper))))))))
(def hide (def hide
(ptk/reify ::hide (ptk/reify ::hide

View file

@ -131,8 +131,8 @@
(when profile (when profile
(swap! storage assoc :profile profile) (swap! storage assoc :profile profile)
(i18n/set-locale! (:lang profile)) (i18n/set-locale! (:lang profile))
(when (not= previous-email email) (when (not= previous-email email)
(swap! storage dissoc ::current-team-id))))))) (swap! storage dissoc ::current-team-id)))))))
(defn fetch-profile (defn fetch-profile
[] []

View file

@ -66,10 +66,10 @@
(-> state (-> state
(assoc :current-file-id file-id) (assoc :current-file-id file-id)
(update :viewer-local (update :viewer-local
(fn [lstate] (fn [lstate]
(if (nil? lstate) (if (nil? lstate)
default-local-state default-local-state
lstate))) lstate)))
(assoc-in [:viewer-local :share-id] share-id) (assoc-in [:viewer-local :share-id] share-id)
(assoc-in [:viewer-local :interactions-show?] interactions-show?))) (assoc-in [:viewer-local :interactions-show?] interactions-show?)))
@ -202,10 +202,10 @@
"fill" zoom-to-fill "fill" zoom-to-fill
nil)) nil))
(rx/of (rx/of
(cond (cond
(some? frame-id) (go-to-frame (uuid frame-id)) (some? frame-id) (go-to-frame (uuid frame-id))
(some? index) (go-to-frame-by-index index) (some? index) (go-to-frame-by-index index)
:else (go-to-frame-auto))))))))) :else (go-to-frame-auto)))))))))
(defn fetch-comment-threads (defn fetch-comment-threads
[{:keys [file-id page-id share-id] :as params}] [{:keys [file-id page-id share-id] :as params}]
@ -297,9 +297,9 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [srect (as-> (get-in state [:route :query-params :page-id]) % (let [srect (as-> (get-in state [:route :query-params :page-id]) %
(get-in state [:viewer :pages % :frames]) (get-in state [:viewer :pages % :frames])
(nth % (get-in state [:route :query-params :index])) (nth % (get-in state [:route :query-params :index]))
(get % :selrect)) (get % :selrect))
orig-size (get-in state [:viewer-local :viewport-size]) orig-size (get-in state [:viewer-local :viewport-size])
wdiff (/ (:width orig-size) (:width srect)) wdiff (/ (:width orig-size) (:width srect))
hdiff (/ (:height orig-size) (:height srect)) hdiff (/ (:height orig-size) (:height srect))
@ -514,9 +514,9 @@
(some? animation) (some? animation)
(assoc-in [:viewer-animations (:id frame)] (assoc-in [:viewer-animations (:id frame)]
{:kind :go-to-frame {:kind :go-to-frame
:orig-frame-id (:id frame) :orig-frame-id (:id frame)
:animation animation})))) :animation animation}))))
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]

View file

@ -316,8 +316,8 @@
(rx/take 1) (rx/take 1)
(rx/map #(go-to-component (uuid/uuid component-id)))))) (rx/map #(go-to-component (uuid/uuid component-id))))))
(rx/take-until (rx/take-until
(rx/filter (ptk/type? ::fetch-bundle) stream)))))) (rx/filter (ptk/type? ::fetch-bundle) stream))))))
(defn initialize-file (defn initialize-file
[project-id file-id] [project-id file-id]
@ -1038,12 +1038,12 @@
shapes-to-select shapes-to-select
(->> selected (->> selected
(reduce (reduce
(fn [result shape-id] (fn [result shape-id]
(let [parent-id (dm/get-in objects [shape-id :parent-id])] (let [parent-id (dm/get-in objects [shape-id :parent-id])]
(if (and (some? parent-id) (not= parent-id uuid/zero)) (if (and (some? parent-id) (not= parent-id uuid/zero))
(conj result parent-id) (conj result parent-id)
(conj result shape-id)))) (conj result shape-id))))
(d/ordered-set)))] (d/ordered-set)))]
(rx/of (dws/select-shapes shapes-to-select)))))) (rx/of (dws/select-shapes shapes-to-select))))))
;; --- Change Page Order (D&D Ordering) ;; --- Change Page Order (D&D Ordering)
@ -1470,17 +1470,17 @@
no-bool-shapes? (->> all-selected (some (comp #{:frame :text} :type)))] no-bool-shapes? (->> all-selected (some (comp #{:frame :text} :type)))]
(if (and (some? shape) (not (contains? selected (:id shape)))) (if (and (some? shape) (not (contains? selected (:id shape))))
(rx/concat (rx/concat
(rx/of (dws/select-shape (:id shape))) (rx/of (dws/select-shape (:id shape)))
(rx/of (show-shape-context-menu params))) (rx/of (show-shape-context-menu params)))
(rx/of (show-context-menu (rx/of (show-context-menu
(-> params (-> params
(assoc (assoc
:kind :shape :kind :shape
:disable-booleans? (or no-bool-shapes? not-group-like?) :disable-booleans? (or no-bool-shapes? not-group-like?)
:disable-flatten? no-bool-shapes? :disable-flatten? no-bool-shapes?
:selected (conj selected (:id shape))))))))))) :selected (conj selected (:id shape)))))))))))
(defn show-page-item-context-menu (defn show-page-item-context-menu
[{:keys [position page] :as params}] [{:keys [position page] :as params}]
@ -1488,8 +1488,8 @@
(ptk/reify ::show-page-item-context-menu (ptk/reify ::show-page-item-context-menu
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (show-context-menu (rx/of (show-context-menu
(-> params (assoc :kind :page :selected (:id page)))))))) (-> params (assoc :kind :page :selected (:id page))))))))
(defn show-track-context-menu (defn show-track-context-menu
[{:keys [grid-id type index] :as params}] [{:keys [grid-id type index] :as params}]
@ -1902,7 +1902,7 @@
;; - Align it to the limits on the x and y axis ;; - Align it to the limits on the x and y axis
;; - Respect the distance of the object to the right and bottom in the original frame ;; - Respect the distance of the object to the right and bottom in the original frame
(gpt/point paste-x paste-y))] (gpt/point paste-x paste-y))]
[frame-id frame-id delta (dec (count (:shapes selected-frame-obj )))])) [frame-id frame-id delta (dec (count (:shapes selected-frame-obj)))]))
(empty? page-selected) (empty? page-selected)
(let [frame-id (ctst/top-nested-frame page-objects position) (let [frame-id (ctst/top-nested-frame page-objects position)
@ -1953,8 +1953,7 @@
(ptk/reify ::paste-shapes (ptk/reify ::paste-shapes
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(let [ (let [file-id (:current-file-id state)
file-id (:current-file-id state)
page (wsh/lookup-page state) page (wsh/lookup-page state)
media-idx (->> (:media pdata) media-idx (->> (:media pdata)
@ -2216,23 +2215,23 @@
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(let [data (get state :workspace-data) (let [data (get state :workspace-data)
update-fn update-fn
(fn [component] (fn [component]
;; NOTE: we need to ensure the component exists, ;; NOTE: we need to ensure the component exists,
;; because there are small possibilities of race ;; because there are small possibilities of race
;; conditions with component deletion. ;; conditions with component deletion.
(when component (when component
(if (nil? annotation) (if (nil? annotation)
(dissoc component :annotation) (dissoc component :annotation)
(assoc component :annotation annotation)))) (assoc component :annotation annotation))))
changes (-> (pcb/empty-changes it) changes (-> (pcb/empty-changes it)
(pcb/with-library-data data) (pcb/with-library-data data)
(pcb/update-component id update-fn))] (pcb/update-component id update-fn))]
(rx/of (dch/commit-changes changes)))))) (rx/of (dch/commit-changes changes))))))
(defn set-annotations-expanded (defn set-annotations-expanded
[expanded?] [expanded?]

View file

@ -19,12 +19,12 @@
(update [_ state] (update [_ state]
(let [expand-fn (fn [expanded] (let [expand-fn (fn [expanded]
(merge expanded (merge expanded
(->> ids (->> ids
(map #(cfh/get-parent-ids objects %)) (map #(cfh/get-parent-ids objects %))
flatten flatten
(remove #(= % uuid/zero)) (remove #(= % uuid/zero))
(map (fn [id] {id true})) (map (fn [id] {id true}))
(into {}))))] (into {}))))]
(update-in state [:workspace-local :expanded] expand-fn))))) (update-in state [:workspace-local :expanded] expand-fn)))))

View file

@ -332,9 +332,9 @@
(ptk/reify ::reorder-strokes (ptk/reify ::reorder-strokes
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (dch/update-shapes (rx/of (dch/update-shapes
ids ids
#(swap-attrs % :strokes index new-index)))))) #(swap-attrs % :strokes index new-index))))))
(defn picker-for-selected-shape (defn picker-for-selected-shape
[] []
@ -529,9 +529,9 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update state :colorpicker (update state :colorpicker
(fn [state] (fn [state]
(-> state (-> state
(assoc :type tab))))))) (assoc :type tab)))))))
(defn finalize-colorpicker (defn finalize-colorpicker
[] []
@ -622,10 +622,10 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update state :colorpicker (update state :colorpicker
(fn [state] (fn [state]
(-> state (-> state
(assoc :type :color) (assoc :type :color)
(dissoc :editing-stop :stops :gradient))))))) (dissoc :editing-stop :stops :gradient)))))))
(defn activate-colorpicker-gradient (defn activate-colorpicker-gradient
[type] [type]
@ -642,13 +642,13 @@
(d/dissoc-in [:current-color :image]) (d/dissoc-in [:current-color :image])
(cond-> (not (:stops state)) (cond-> (not (:stops state))
(assoc :editing-stop 0 (assoc :editing-stop 0
:stops [(-> color :stops [(-> color
(assoc :offset 0) (assoc :offset 0)
(materialize-color-components)) (materialize-color-components))
(-> color (-> color
(assoc :alpha 0) (assoc :alpha 0)
(assoc :offset 1) (assoc :offset 1)
(materialize-color-components))]))))))))) (materialize-color-components))])))))))))
(defn activate-colorpicker-image (defn activate-colorpicker-image
[] []
@ -656,10 +656,10 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(update state :colorpicker (update state :colorpicker
(fn [state] (fn [state]
(-> state (-> state
(assoc :type :image) (assoc :type :image)
(dissoc :editing-stop :stops :gradient))))))) (dissoc :editing-stop :stops :gradient)))))))
(defn select-color (defn select-color
[position add-color] [position add-color]
@ -671,13 +671,13 @@
shape (first shapes) shape (first shapes)
fills (if (cfh/text-shape? shape) fills (if (cfh/text-shape? shape)
(:fills (dwt/current-text-values (:fills (dwt/current-text-values
{:editor-state (dm/get-in state [:workspace-editor-state (:id shape)]) {:editor-state (dm/get-in state [:workspace-editor-state (:id shape)])
:shape shape :shape shape
:attrs (conj dwt/text-fill-attrs :fills)})) :attrs (conj dwt/text-fill-attrs :fills)}))
(:fills shape)) (:fills shape))
fill (first fills) fill (first fills)
single? (and (= 1 (count selected)) single? (and (= 1 (count selected))
(= 1 (count fills))) (= 1 (count fills)))
data (if single? data (if single?
(d/without-nils {:color (:fill-color fill) (d/without-nils {:color (:fill-color fill)
:opacity (:fill-opacity fill) :opacity (:fill-opacity fill)
@ -685,13 +685,13 @@
{:color "#406280" {:color "#406280"
:opacity 1})] :opacity 1})]
(rx/of (md/show :colorpicker (rx/of (md/show :colorpicker
{:x (:x position) {:x (:x position)
:y (:y position) :y (:y position)
:on-accept add-color :on-accept add-color
:data data :data data
:position :right}) :position :right})
(ptk/event ::ev/event {::ev/name "add-asset-to-library" (ptk/event ::ev/event {::ev/name "add-asset-to-library"
:asset-type "color"})))))) :asset-type "color"}))))))
(defn get-active-color-tab (defn get-active-color-tab
[] []

View file

@ -42,7 +42,7 @@
(rx/filter mse/mouse-click-event?) (rx/filter mse/mouse-click-event?)
(rx/switch-map #(rx/take 1 ms/mouse-position)) (rx/switch-map #(rx/take 1 ms/mouse-position))
(rx/with-latest-from ms/keyboard-space) (rx/with-latest-from ms/keyboard-space)
(rx/filter (fn [[_ space]] (not space)) ) (rx/filter (fn [[_ space]] (not space)))
(rx/map first) (rx/map first)
(rx/map handle-comment-layer-click) (rx/map handle-comment-layer-click)
(rx/take-until stoper)) (rx/take-until stoper))

View file

@ -169,7 +169,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn toggle-toolbar-visibility (defn toggle-toolbar-visibility
[] []
(ptk/reify ::toggle-toolbar-visibility (ptk/reify ::toggle-toolbar-visibility
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
@ -180,7 +180,7 @@
(ptk/reify ::hide-toolbar (ptk/reify ::hide-toolbar
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(assoc-in state [:workspace-local :hide-toolbar] true)))) (assoc-in state [:workspace-local :hide-toolbar] true))))
(defn show-toolbar (defn show-toolbar
[] []

View file

@ -82,7 +82,7 @@
(rx/merge (rx/merge
(rx/of (handle-drawing type)) (rx/of (handle-drawing type))
(->> stream (->> stream
(rx/filter (ptk/type? ::common/handle-finish-drawing) ) (rx/filter (ptk/type? ::common/handle-finish-drawing))
(rx/take 1) (rx/take 1)
(rx/map #(fn [state] (update state :workspace-drawing dissoc :lock))))))))))) (rx/map #(fn [state] (update state :workspace-drawing dissoc :lock)))))))))))

View file

@ -25,8 +25,8 @@
[node] [node]
(let [fonts (deref fonts/fontsdb)] (let [fonts (deref fonts/fontsdb)]
(and (and
(some? (:font-family node)) (some? (:font-family node))
(nil? (get fonts (:font-id node)))))) (nil? (get fonts (:font-id node))))))
(defn calculate-alternative-font-id (defn calculate-alternative-font-id
[value] [value]
@ -66,9 +66,9 @@
(defn fix-deleted-font-component (defn fix-deleted-font-component
[component] [component]
(update component (update component
:objects :objects
(fn [objects] (fn [objects]
(d/mapm #(fix-deleted-font-shape %2) objects)))) (d/mapm #(fix-deleted-font-shape %2) objects))))
(defn fix-deleted-font-typography (defn fix-deleted-font-typography
[typography] [typography]
@ -84,8 +84,8 @@
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
ids (into #{} ids (into #{}
(comp (filter should-fix-deleted-font-shape?) (map :id)) (comp (filter should-fix-deleted-font-shape?) (map :id))
(vals objects)) (vals objects))
components (->> (wsh/lookup-local-components state) components (->> (wsh/lookup-local-components state)
(vals) (vals)
@ -93,11 +93,11 @@
component-changes component-changes
(into [] (into []
(map (fn [component] (map (fn [component]
{:type :mod-component {:type :mod-component
:id (:id component) :id (:id component)
:objects (-> (fix-deleted-font-component component) :objects)})) :objects (-> (fix-deleted-font-component component) :objects)}))
components) components)
typographies (->> (get-in state [:workspace-data :typographies]) typographies (->> (get-in state [:workspace-data :typographies])
(vals) (vals)
@ -105,25 +105,25 @@
typography-changes typography-changes
(into [] (into []
(map (fn [typography] (map (fn [typography]
{:type :mod-typography {:type :mod-typography
:typography (fix-deleted-font-typography typography)})) :typography (fix-deleted-font-typography typography)}))
typographies)] typographies)]
(rx/concat (rx/concat
(rx/of (dch/update-shapes ids #(fix-deleted-font-shape %) {:reg-objects? false (rx/of (dch/update-shapes ids #(fix-deleted-font-shape %) {:reg-objects? false
:save-undo? false :save-undo? false
:ignore-tree true})) :ignore-tree true}))
(if (empty? component-changes) (if (empty? component-changes)
(rx/empty) (rx/empty)
(rx/of (dch/commit-changes {:origin it (rx/of (dch/commit-changes {:origin it
:redo-changes component-changes :redo-changes component-changes
:undo-changes [] :undo-changes []
:save-undo? false}))) :save-undo? false})))
(if (empty? typography-changes) (if (empty? typography-changes)
(rx/empty) (rx/empty)
(rx/of (dch/commit-changes {:origin it (rx/of (dch/commit-changes {:origin it
:redo-changes typography-changes :redo-changes typography-changes
:undo-changes [] :undo-changes []
:save-undo? false})))))))) :save-undo? false}))))))))

View file

@ -76,6 +76,6 @@
(watch [it state _] (watch [it state _]
(let [page (wsh/lookup-page state)] (let [page (wsh/lookup-page state)]
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/set-page-option [:saved-grids type] params)))))))) (pcb/set-page-option [:saved-grids type] params))))))))

View file

@ -64,8 +64,7 @@
:zoom-selected {:tooltip (ds/shift "2") :zoom-selected {:tooltip (ds/shift "2")
:command "shift+2" :command "shift+2"
:fn #(st/emit! dw/zoom-to-selected-shape)} :fn #(st/emit! dw/zoom-to-selected-shape)}})
})
(defn get-tooltip [shortcut] (defn get-tooltip [shortcut]
(assert (contains? shortcuts shortcut) (str shortcut)) (assert (contains? shortcuts shortcut) (str shortcut))

View file

@ -55,7 +55,7 @@
(empty? (remove removed-id? (:shapes group)))) (empty? (remove removed-id? (:shapes group))))
;; Adds group to the remove and check its parent ;; Adds group to the remove and check its parent
(let [to-check (concat to-check [(cfh/get-parent-id objects current-id)]) ] (let [to-check (concat to-check [(cfh/get-parent-id objects current-id)])]
(recur (first to-check) (recur (first to-check)
(rest to-check) (rest to-check)
(conj removed-id? current-id) (conj removed-id? current-id)
@ -243,10 +243,10 @@
(when-not (empty? selected) (when-not (empty? selected)
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes) (dch/commit-changes changes)
(ptk/data-event :layout/update parents) (ptk/data-event :layout/update parents)
(dwu/commit-undo-transaction undo-id) (dwu/commit-undo-transaction undo-id)
(dws/select-shapes child-ids))))))) (dws/select-shapes child-ids)))))))
(def mask-group (def mask-group
(ptk/reify ::mask-group (ptk/reify ::mask-group

View file

@ -41,9 +41,9 @@
:starting-frame starting-frame}] :starting-frame starting-frame}]
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows ctp/add-flow new-flow)))))))) (pcb/update-page-option :flows ctp/add-flow new-flow))))))))
(defn add-flow-selected-frame (defn add-flow-selected-frame
[] []
@ -61,9 +61,9 @@
(watch [it state _] (watch [it state _]
(let [page (wsh/lookup-page state)] (let [page (wsh/lookup-page state)]
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows ctp/remove-flow flow-id)))))))) (pcb/update-page-option :flows ctp/remove-flow flow-id))))))))
(defn rename-flow (defn rename-flow
[flow-id name] [flow-id name]
@ -72,12 +72,12 @@
(ptk/reify ::rename-flow (ptk/reify ::rename-flow
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(let [page (wsh/lookup-page state) ] (let [page (wsh/lookup-page state)]
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows ctp/update-flow flow-id (pcb/update-page-option :flows ctp/update-flow flow-id
#(ctp/rename-flow % name))))))))) #(ctp/rename-flow % name)))))))))
(defn start-rename-flow (defn start-rename-flow
[id] [id]
@ -120,16 +120,16 @@
:flows] []) :flows] [])
flow (ctp/get-frame-flow flows (:id frame))] flow (ctp/get-frame-flow flows (:id frame))]
(rx/concat (rx/concat
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(let [new-interaction (-> ctsi/default-interaction (let [new-interaction (-> ctsi/default-interaction
(ctsi/set-destination destination) (ctsi/set-destination destination)
(assoc :position-relative-to (:id shape)))] (assoc :position-relative-to (:id shape)))]
(update shape :interactions (update shape :interactions
ctsi/add-interaction new-interaction))))) ctsi/add-interaction new-interaction)))))
(when (and (not (connected-frame? objects (:id frame))) (when (and (not (connected-frame? objects (:id frame)))
(nil? flow)) (nil? flow))
(rx/of (add-flow (:id frame)))))))))) (rx/of (add-flow (:id frame))))))))))
(defn remove-interaction (defn remove-interaction
[shape index] [shape index]
@ -137,9 +137,9 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(update shape :interactions (update shape :interactions
ctsi/remove-interaction index))))))) ctsi/remove-interaction index)))))))
(defn update-interaction (defn update-interaction
[shape index update-fn] [shape index update-fn]
@ -147,9 +147,9 @@
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(update shape :interactions (update shape :interactions
ctsi/update-interaction index update-fn))))))) ctsi/update-interaction index update-fn)))))))
(defn remove-all-interactions-nav-to (defn remove-all-interactions-nav-to
"Remove all interactions that navigate to the given frame." "Remove all interactions that navigate to the given frame."
@ -189,14 +189,14 @@
(let [initial-pos @ms/mouse-position (let [initial-pos @ms/mouse-position
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
stopper (->> stream stopper (->> stream
(rx/filter mse/mouse-event?) (rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))] (rx/filter mse/mouse-up-event?))]
(when (= 1 (count selected)) (when (= 1 (count selected))
(rx/concat (rx/concat
(->> ms/mouse-position (->> ms/mouse-position
(rx/take-until stopper) (rx/take-until stopper)
(rx/map #(move-edit-interaction initial-pos %))) (rx/map #(move-edit-interaction initial-pos %)))
(rx/of (finish-edit-interaction index initial-pos)))))))) (rx/of (finish-edit-interaction index initial-pos))))))))
(defn- get-target-frame (defn- get-target-frame
[state position] [state position]
@ -252,33 +252,33 @@
undo-id (js/Symbol)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(when (:hide-in-viewer target-frame) (when (:hide-in-viewer target-frame)
; If the target frame is hidden, we need to unhide it so ; If the target frame is hidden, we need to unhide it so
; users can navigate to it. ; users can navigate to it.
(dch/update-shapes [(:id target-frame)] (dch/update-shapes [(:id target-frame)]
#(dissoc % :hide-in-viewer))) #(dissoc % :hide-in-viewer)))
(cond (cond
(or (nil? shape) (or (nil? shape)
;; Didn't changed the position for the interaction ;; Didn't changed the position for the interaction
(= position initial-pos) (= position initial-pos)
;; New interaction but invalid target ;; New interaction but invalid target
(and (nil? index) (nil? target-frame))) (and (nil? index) (nil? target-frame)))
nil nil
;; Dropped interaction in an invalid target. We remove it ;; Dropped interaction in an invalid target. We remove it
(and (some? index) (nil? target-frame)) (and (some? index) (nil? target-frame))
(remove-interaction shape index) (remove-interaction shape index)
(nil? index) (nil? index)
(add-new-interaction shape (:id target-frame)) (add-new-interaction shape (:id target-frame))
:else :else
(update-interaction shape index change-interaction)) (update-interaction shape index change-interaction))
(dwu/commit-undo-transaction undo-id)))))) (dwu/commit-undo-transaction undo-id))))))
;; --- Overlays ;; --- Overlays
@ -299,8 +299,8 @@
(let [initial-pos @ms/mouse-position (let [initial-pos @ms/mouse-position
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
stopper (->> stream stopper (->> stream
(rx/filter mse/mouse-event?) (rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?))] (rx/filter mse/mouse-up-event?))]
(when (= 1 (count selected)) (when (= 1 (count selected))
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
@ -317,10 +317,10 @@
(gpt/subtract overlay-pos) (gpt/subtract overlay-pos)
(gpt/subtract frame-pos))] (gpt/subtract frame-pos))]
(rx/concat (rx/concat
(->> ms/mouse-position (->> ms/mouse-position
(rx/take-until stopper) (rx/take-until stopper)
(rx/map #(move-overlay-pos % frame-pos offset))) (rx/map #(move-overlay-pos % frame-pos offset)))
(rx/of (finish-move-overlay-pos index frame-pos offset))))))))) (rx/of (finish-move-overlay-pos index frame-pos offset)))))))))
(defn move-overlay-pos (defn move-overlay-pos
[pos frame-pos offset] [pos frame-pos offset]
@ -333,33 +333,33 @@
(assoc-in state [:workspace-local :move-overlay-to] pos))))) (assoc-in state [:workspace-local :move-overlay-to] pos)))))
(defn finish-move-overlay-pos (defn finish-move-overlay-pos
[index frame-pos offset] [index frame-pos offset]
(ptk/reify ::finish-move-overlay-pos (ptk/reify ::finish-move-overlay-pos
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(-> state (-> state
(d/dissoc-in [:workspace-local :move-overlay-to]) (d/dissoc-in [:workspace-local :move-overlay-to])
(d/dissoc-in [:workspace-local :move-overlay-index]))) (d/dissoc-in [:workspace-local :move-overlay-index])))
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [pos @ms/mouse-position (let [pos @ms/mouse-position
overlay-pos (-> pos overlay-pos (-> pos
(gpt/subtract frame-pos) (gpt/subtract frame-pos)
(gpt/subtract offset)) (gpt/subtract offset))
page-id (:current-page-id state) page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
shape (->> state shape (->> state
wsh/lookup-selected wsh/lookup-selected
first first
(get objects)) (get objects))
interactions (:interactions shape) interactions (:interactions shape)
new-interactions new-interactions
(update interactions index (update interactions index
#(ctsi/set-overlay-position % overlay-pos))] #(ctsi/set-overlay-position % overlay-pos))]
(rx/of (dch/update-shapes [(:id shape)] #(merge % {:interactions new-interactions}))))))) (rx/of (dch/update-shapes [(:id shape)] #(merge % {:interactions new-interactions})))))))

View file

@ -580,11 +580,11 @@
(ptk/reify ::detach-components (ptk/reify ::detach-components
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(let [undo-id (js/Symbol)] (let [undo-id (js/Symbol)]
(rx/concat (rx/concat
(rx/of (dwu/start-undo-transaction undo-id)) (rx/of (dwu/start-undo-transaction undo-id))
(rx/map #(detach-component %) (rx/from ids)) (rx/map #(detach-component %) (rx/from ids))
(rx/of (dwu/commit-undo-transaction undo-id))))))) (rx/of (dwu/commit-undo-transaction undo-id)))))))
(def detach-selected-components (def detach-selected-components
(ptk/reify ::detach-selected-components (ptk/reify ::detach-selected-components
@ -797,12 +797,12 @@
(watch [_ state _] (watch [_ state _]
(let [current-file-id (:current-file-id state) (let [current-file-id (:current-file-id state)
undo-id (js/Symbol)] undo-id (js/Symbol)]
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(sync-file current-file-id file-id :components component-id undo-group) (sync-file current-file-id file-id :components component-id undo-group)
(when (not= current-file-id file-id) (when (not= current-file-id file-id)
(sync-file file-id file-id :components component-id undo-group)) (sync-file file-id file-id :components component-id undo-group))
(dwu/commit-undo-transaction undo-id))))))) (dwu/commit-undo-transaction undo-id)))))))
(defn update-component-thumbnail (defn update-component-thumbnail
"Update the thumbnail of the component with the given id, in the "Update the thumbnail of the component with the given id, in the
@ -813,10 +813,10 @@
(watch [_ state _] (watch [_ state _]
(rx/of (update-component-thumbnail-sync state component-id file-id "component")) (rx/of (update-component-thumbnail-sync state component-id file-id "component"))
#_(let [data (get state :workspace-data) #_(let [data (get state :workspace-data)
component (ctkl/get-component data component-id) component (ctkl/get-component data component-id)
page-id (:main-instance-page component) page-id (:main-instance-page component)
root-id (:main-instance-id component)] root-id (:main-instance-id component)]
(rx/of (dwt/request-thumbnail file-id page-id root-id "component")))))) (rx/of (dwt/request-thumbnail file-id page-id root-id "component"))))))
(defn- find-shape-index (defn- find-shape-index
[objects id shape-id] [objects id shape-id]
@ -965,15 +965,15 @@
find-frames (fn [change] find-frames (fn [change]
(->> (ch/frames-changed file change) (->> (ch/frames-changed file change)
(map #(assoc %1 :page-id (:page-id change))))) (map #(assoc %1 :page-id (:page-id change)))))
updated-frames (->> changes updated-frames (->> changes
:redo-changes :redo-changes
(mapcat find-frames) (mapcat find-frames)
distinct)] distinct)]
(log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes (log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes
(:redo-changes changes) (:redo-changes changes)

View file

@ -976,11 +976,11 @@
[_ new-shapes _] [_ new-shapes _]
(ctst/clone-shape component-shape (ctst/clone-shape component-shape
(:id parent-shape) (:id parent-shape)
(get component-page :objects) (get component-page :objects)
:update-new-shape update-new-shape :update-new-shape update-new-shape
:update-original-shape update-original-shape :update-original-shape update-original-shape
:dest-objects (get container :objects)) :dest-objects (get container :objects))
add-obj-change (fn [changes shape'] add-obj-change (fn [changes shape']
(update changes :redo-changes conj (update changes :redo-changes conj

View file

@ -97,7 +97,7 @@
(rx/map #(svg/add-svg-shapes (assoc svg-data :image-data %) position)))))) (rx/map #(svg/add-svg-shapes (assoc svg-data :image-data %) position))))))
(defn- process-uris (defn- process-uris
[{:keys [file-id local? name uris mtype on-image on-svg] }] [{:keys [file-id local? name uris mtype on-image on-svg]}]
(letfn [(svg-url? [url] (letfn [(svg-url? [url]
(or (and mtype (= mtype "image/svg+xml")) (or (and mtype (= mtype "image/svg+xml"))
(str/ends-with? url ".svg"))) (str/ends-with? url ".svg")))
@ -211,28 +211,28 @@
(defn- process-media-objects (defn- process-media-objects
[{:keys [uris on-error] :as params}] [{:keys [uris on-error] :as params}]
(dm/assert! (dm/assert!
(and (sm/check! schema:process-media-objects params) (and (sm/check! schema:process-media-objects params)
(or (contains? params :blobs) (or (contains? params :blobs)
(contains? params :uris)))) (contains? params :uris))))
(ptk/reify ::process-media-objects (ptk/reify ::process-media-objects
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
(rx/concat (rx/concat
(rx/of (msg/show {:content (tr "media.loading") (rx/of (msg/show {:content (tr "media.loading")
:type :info :type :info
:timeout nil :timeout nil
:tag :media-loading})) :tag :media-loading}))
(->> (if (seq uris) (->> (if (seq uris)
;; Media objects is a list of URL's pointing to the path ;; Media objects is a list of URL's pointing to the path
(process-uris params) (process-uris params)
;; Media objects are blob of data to be upload ;; Media objects are blob of data to be upload
(process-blobs params)) (process-blobs params))
;; Every stream has its own sideeffect. We need to ignore the result ;; Every stream has its own sideeffect. We need to ignore the result
(rx/ignore) (rx/ignore)
(rx/catch #(handle-media-error % on-error)) (rx/catch #(handle-media-error % on-error))
(rx/finalize #(st/emit! (msg/hide-tag :media-loading)))))))) (rx/finalize #(st/emit! (msg/hide-tag :media-loading))))))))
;; Deprecated in components-v2 ;; Deprecated in components-v2
(defn upload-media-asset (defn upload-media-asset
@ -256,8 +256,8 @@
(defn upload-fill-image (defn upload-fill-image
[file on-success] [file on-success]
(dm/assert! (dm/assert!
"expected a valid blob for `file` param" "expected a valid blob for `file` param"
(dmm/blob? file)) (dmm/blob? file))
(ptk/reify ::upload-fill-image (ptk/reify ::upload-fill-image
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
@ -293,9 +293,9 @@
(rx/map #(vector (:name media-obj) %)) (rx/map #(vector (:name media-obj) %))
(rx/merge-map svg->clj) (rx/merge-map svg->clj)
(rx/catch ; When error downloading media-obj, skip it and continue with next one (rx/catch ; When error downloading media-obj, skip it and continue with next one
#(log/error :msg (str "Error downloading " (:name media-obj) " from " path) #(log/error :msg (str "Error downloading " (:name media-obj) " from " path)
:hint (ex-message %) :hint (ex-message %)
:error %))))) :error %)))))
(defn create-shapes-svg (defn create-shapes-svg
"Convert svg elements into penpot shapes." "Convert svg elements into penpot shapes."

View file

@ -275,11 +275,11 @@
(update-in [target-frame-id :modifiers] ctm/change-property :layout-item-v-sizing :fix))))) (update-in [target-frame-id :modifiers] ctm/change-property :layout-item-v-sizing :fix)))))
(defn modif->js (defn modif->js
[modif-tree objects] [modif-tree objects]
(clj->js (into {} (clj->js (into {}
(map (fn [[k v]] (map (fn [[k v]]
[(get-in objects [k :name]) v])) [(get-in objects [k :name]) v]))
modif-tree))) modif-tree)))
(defn apply-text-modifier (defn apply-text-modifier
[shape {:keys [width height]}] [shape {:keys [width height]}]
@ -301,19 +301,19 @@
(d/update-when result id apply-text-modifier text-modifier)))))) (d/update-when result id apply-text-modifier text-modifier))))))
#_(defn apply-path-modifiers #_(defn apply-path-modifiers
[objects path-modifiers] [objects path-modifiers]
(letfn [(apply-path-modifier (letfn [(apply-path-modifier
[shape {:keys [content-modifiers]}] [shape {:keys [content-modifiers]}]
(let [shape (update shape :content upc/apply-content-modifiers content-modifiers) (let [shape (update shape :content upc/apply-content-modifiers content-modifiers)
[points selrect] (helpers/content->points+selrect shape (:content shape))] [points selrect] (helpers/content->points+selrect shape (:content shape))]
(assoc shape :selrect selrect :points points)))] (assoc shape :selrect selrect :points points)))]
(loop [modifiers (seq path-modifiers) (loop [modifiers (seq path-modifiers)
result objects] result objects]
(if (empty? modifiers) (if (empty? modifiers)
result result
(let [[id path-modifier] (first modifiers)] (let [[id path-modifier] (first modifiers)]
(recur (rest modifiers) (recur (rest modifiers)
(update objects id apply-path-modifier path-modifier))))))) (update objects id apply-path-modifier path-modifier)))))))
(defn- calculate-modifiers (defn- calculate-modifiers
([state modif-tree] ([state modif-tree]
@ -544,8 +544,7 @@
:layout-item-margin-type :layout-item-margin-type
:layout-grid-cells :layout-grid-cells
:layout-grid-columns :layout-grid-columns
:layout-grid-rows :layout-grid-rows]})
]})
;; We've applied the text-modifier so we can dissoc the temporary data ;; We've applied the text-modifier so we can dissoc the temporary data
(fn [state] (fn [state]
(update state :workspace-text-modifier #(apply dissoc % ids))) (update state :workspace-text-modifier #(apply dissoc % ids)))

View file

@ -131,7 +131,7 @@
(let [;; To match the angle, the angle should be matching (angle between points 180deg) (let [;; To match the angle, the angle should be matching (angle between points 180deg)
angle-handlers (angle-points node handler opposite) angle-handlers (angle-points node handler opposite)
match-angle? (and match-angle? (<= (mth/abs (- 180 angle-handlers) ) 0.1)) match-angle? (and match-angle? (<= (mth/abs (- 180 angle-handlers)) 0.1))
;; To match distance the distance should be matching ;; To match distance the distance should be matching
match-distance? (and match-distance? (mth/almost-zero? (- (gpt/distance node handler) match-distance? (and match-distance? (mth/almost-zero? (- (gpt/distance node handler)

View file

@ -53,11 +53,11 @@
start (-> @ms/mouse-position to-pixel-snap) start (-> @ms/mouse-position to-pixel-snap)
stoper (rx/merge stoper (rx/merge
(->> st/stream (->> st/stream
(rx/filter mse/mouse-event?) (rx/filter mse/mouse-event?)
(rx/filter mse/mouse-up-event?)) (rx/filter mse/mouse-up-event?))
(->> st/stream (->> st/stream
(rx/filter finish-edition?))) (rx/filter finish-edition?)))
position-stream position-stream
(->> ms/mouse-position (->> ms/mouse-position

View file

@ -145,8 +145,7 @@
:revn file-revn :revn file-revn
:session-id sid :session-id sid
:changes-with-metadata (into [] changes) :changes-with-metadata (into [] changes)
:features features :features features}]
}]
(->> (rp/cmd! :update-file params) (->> (rp/cmd! :update-file params)
(rx/mapcat (fn [lagged] (rx/mapcat (fn [lagged]

View file

@ -368,7 +368,7 @@
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/with-objects all-objects))] (pcb/with-objects all-objects))]
(prepare-duplicate-changes all-objects page ids delta it libraries library-data file-id init-changes))) (prepare-duplicate-changes all-objects page ids delta it libraries library-data file-id init-changes)))
([all-objects page ids delta it libraries library-data file-id init-changes] ([all-objects page ids delta it libraries library-data file-id init-changes]
(let [shapes (map (d/getf all-objects) ids) (let [shapes (map (d/getf all-objects) ids)
@ -495,7 +495,7 @@
(not duplicating-component?) (not duplicating-component?)
(ctk/detach-shape)) (ctk/detach-shape))
; We want the first added object to touch it's parent, but not subsequent children ;; We want the first added object to touch it's parent, but not subsequent children
changes (-> (pcb/add-object changes new-obj {:ignore-touched (and duplicating-component? child?)}) changes (-> (pcb/add-object changes new-obj {:ignore-touched (and duplicating-component? child?)})
(pcb/amend-last-change #(assoc % :old-id (:id obj))) (pcb/amend-last-change #(assoc % :old-id (:id obj)))
(cond-> (ctl/grid-layout? objects (:parent-id obj)) (cond-> (ctl/grid-layout? objects (:parent-id obj))
@ -506,7 +506,7 @@
(and is-component-root? is-component-main?) (and is-component-root? is-component-main?)
(regenerate-component new-obj)) (regenerate-component new-obj))
; This is needed for the recursive call to find the new object as parent ;; This is needed for the recursive call to find the new object as parent
page' (ctst/add-shape (:id new-obj) page' (ctst/add-shape (:id new-obj)
new-obj new-obj
{:objects objects} {:objects objects}
@ -545,15 +545,15 @@
(if-not (empty? frames-with-flow) (if-not (empty? frames-with-flow)
(let [update-flows (fn [flows] (let [update-flows (fn [flows]
(reduce (reduce
(fn [flows frame] (fn [flows frame]
(let [name (cfh/generate-unique-name @unames "Flow 1") (let [name (cfh/generate-unique-name @unames "Flow 1")
_ (vswap! unames conj name) _ (vswap! unames conj name)
new-flow {:id (uuid/next) new-flow {:id (uuid/next)
:name name :name name
:starting-frame (get ids-map (:id frame))}] :starting-frame (get ids-map (:id frame))}]
(ctp/add-flow flows new-flow))) (ctp/add-flow flows new-flow)))
flows flows
frames-with-flow))] frames-with-flow))]
(pcb/update-page-option changes :flows update-flows)) (pcb/update-page-option changes :flows update-flows))
changes))) changes)))
@ -611,9 +611,9 @@
objects-indices (->> index-map (d/mapm fix-indices) (vals) (reduce merge))] objects-indices (->> index-map (d/mapm fix-indices) (vals) (reduce merge))]
(pcb/amend-changes (pcb/amend-changes
changes changes
(fn [change] (fn [change]
(assoc change :index (get objects-indices (:old-id change))))))) (assoc change :index (get objects-indices (:old-id change)))))))
(defn clear-memorize-duplicated (defn clear-memorize-duplicated
[] []
@ -671,52 +671,52 @@
([move-delta?] ([move-delta?]
(duplicate-selected move-delta? false)) (duplicate-selected move-delta? false))
([move-delta? alt-duplication?] ([move-delta? alt-duplication?]
(ptk/reify ::duplicate-selected (ptk/reify ::duplicate-selected
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(when (or (not move-delta?) (nil? (get-in state [:workspace-local :transform]))) (when (or (not move-delta?) (nil? (get-in state [:workspace-local :transform])))
(let [page (wsh/lookup-page state) (let [page (wsh/lookup-page state)
objects (:objects page) objects (:objects page)
selected (->> (wsh/lookup-selected state) selected (->> (wsh/lookup-selected state)
(map #(get objects %)) (map #(get objects %))
(remove #(ctk/in-component-copy-not-root? %)) ;; We don't want to change the structure of component copies (remove #(ctk/in-component-copy-not-root? %)) ;; We don't want to change the structure of component copies
(map :id) (map :id)
set)] set)]
(when (seq selected) (when (seq selected)
(let [obj (get objects (first selected)) (let [obj (get objects (first selected))
delta (if move-delta? delta (if move-delta?
(calc-duplicate-delta obj state objects) (calc-duplicate-delta obj state objects)
(gpt/point 0 0)) (gpt/point 0 0))
file-id (:current-file-id state) file-id (:current-file-id state)
libraries (wsh/get-libraries state) libraries (wsh/get-libraries state)
library-data (wsh/get-file state file-id) library-data (wsh/get-file state file-id)
changes (->> (prepare-duplicate-changes objects page selected delta it libraries library-data file-id) changes (->> (prepare-duplicate-changes objects page selected delta it libraries library-data file-id)
(duplicate-changes-update-indices objects selected)) (duplicate-changes-update-indices objects selected))
tags (or (:tags changes) #{}) tags (or (:tags changes) #{})
changes (cond-> changes alt-duplication? (assoc :tags (conj tags :alt-duplication))) changes (cond-> changes alt-duplication? (assoc :tags (conj tags :alt-duplication)))
id-original (first selected) id-original (first selected)
new-selected (->> changes new-selected (->> changes
:redo-changes :redo-changes
(filter #(= (:type %) :add-obj)) (filter #(= (:type %) :add-obj))
(filter #(selected (:old-id %))) (filter #(selected (:old-id %)))
(map #(get-in % [:obj :id])) (map #(get-in % [:obj :id]))
(into (d/ordered-set))) (into (d/ordered-set)))
id-duplicated (first new-selected) id-duplicated (first new-selected)
frames (into #{} frames (into #{}
(map #(get-in objects [% :frame-id])) (map #(get-in objects [% :frame-id]))
selected) selected)
undo-id (js/Symbol)] undo-id (js/Symbol)]
;; Warning: This order is important for the focus mode. ;; Warning: This order is important for the focus mode.
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(dch/commit-changes changes) (dch/commit-changes changes)
(select-shapes new-selected) (select-shapes new-selected)

View file

@ -255,7 +255,7 @@
:command "t" :command "t"
:subsections [:tools] :subsections [:tools]
:fn #(emit-when-no-readonly dwtxt/start-edit-if-selected :fn #(emit-when-no-readonly dwtxt/start-edit-if-selected
(dwd/select-for-drawing :text))} (dwd/select-for-drawing :text))}
:draw-path {:tooltip "P" :draw-path {:tooltip "P"
:command "p" :command "p"
@ -399,7 +399,7 @@
:command (ds/c-mod "shift+e") :command (ds/c-mod "shift+e")
:subsections [:basics :main-menu] :subsections [:basics :main-menu]
:fn #(st/emit! :fn #(st/emit!
(de/show-workspace-export-dialog))} (de/show-workspace-export-dialog))}
:toggle-snap-guide {:tooltip (ds/meta-shift "G") :toggle-snap-guide {:tooltip (ds/meta-shift "G")
:command (ds/c-mod "shift+g") :command (ds/c-mod "shift+g")
@ -432,15 +432,15 @@
:command (ds/a-mod "p") :command (ds/a-mod "p")
:subsections [:panels] :subsections [:panels]
:fn #(do (r/set-resize-type! :bottom) :fn #(do (r/set-resize-type! :bottom)
(emit-when-no-readonly (dw/remove-layout-flag :textpalette) (emit-when-no-readonly (dw/remove-layout-flag :textpalette)
(toggle-layout-flag :colorpalette)))} (toggle-layout-flag :colorpalette)))}
:toggle-textpalette {:tooltip (ds/alt "T") :toggle-textpalette {:tooltip (ds/alt "T")
:command (ds/a-mod "t") :command (ds/a-mod "t")
:subsections [:panels] :subsections [:panels]
:fn #(do (r/set-resize-type! :bottom) :fn #(do (r/set-resize-type! :bottom)
(emit-when-no-readonly (dw/remove-layout-flag :colorpalette) (emit-when-no-readonly (dw/remove-layout-flag :colorpalette)
(toggle-layout-flag :textpalette)))} (toggle-layout-flag :textpalette)))}
:hide-ui {:tooltip "\\" :hide-ui {:tooltip "\\"
:command "\\" :command "\\"

View file

@ -24,18 +24,18 @@
(defn open-specialized-panel (defn open-specialized-panel
[type] [type]
(ptk/reify ::open-specialized-panel (ptk/reify ::open-specialized-panel
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id) objects (wsh/lookup-page-objects state page-id)
selected-ids (wsh/lookup-selected state) selected-ids (wsh/lookup-selected state)
selected-shapes (map (d/getf objects) selected-ids)] selected-shapes (map (d/getf objects) selected-ids)]
(assoc state :specialized-panel {:type type :shapes selected-shapes}))) (assoc state :specialized-panel {:type type :shapes selected-shapes})))
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ stream] (watch [_ _ stream]
(->> (rx/merge (->> (rx/merge
(rx/filter interrupt? stream) (rx/filter interrupt? stream)
(rx/filter (ptk/type? ::dwc/undo) stream)) (rx/filter (ptk/type? ::dwc/undo) stream))
(rx/take 1) (rx/take 1)
(rx/map clear-specialized-panel))))) (rx/map clear-specialized-panel)))))

View file

@ -76,11 +76,11 @@
(or (= variant-id "remove-bold") (or (= variant-id "remove-bold")
(= variant-id "toggle-bold"))) (= variant-id "toggle-bold")))
add-italic? (and (not italic?) add-italic? (and (not italic?)
(or (= variant-id "add-italic") (or (= variant-id "add-italic")
(= variant-id "toggle-italic"))) (= variant-id "toggle-italic")))
remove-italic? (and italic? remove-italic? (and italic?
(or (= variant-id "remove-italic") (or (= variant-id "remove-italic")
(= variant-id "toggle-italic")))] (= variant-id "toggle-italic")))]
(cond (cond
(and add-bold? italic?) ;; it is italic, set it to bold+italic (and add-bold? italic?) ;; it is italic, set it to bold+italic
(choose-bold-italic) (choose-bold-italic)
@ -127,8 +127,7 @@
:attrs dwt/text-attrs})))) :attrs dwt/text-attrs}))))
(defn- update-attrs [shape props] (defn- update-attrs [shape props]
(let [ (let [text-values (calculate-text-values shape)
text-values (calculate-text-values shape)
font-size (d/parse-double (:font-size text-values)) font-size (d/parse-double (:font-size text-values))
line-height (d/parse-double (:line-height text-values)) line-height (d/parse-double (:line-height text-values))
letter-spacing (d/parse-double (:letter-spacing text-values)) letter-spacing (d/parse-double (:letter-spacing text-values))
@ -166,8 +165,7 @@
all-underline? (every? #(= (:text-decoration %) "underline") text-values) all-underline? (every? #(= (:text-decoration %) "underline") text-values)
all-line-through? (every? #(= (:text-decoration %) "line-through") text-values) all-line-through? (every? #(= (:text-decoration %) "line-through") text-values)
all-bold? (every? #(is-bold? (:font-variant-id %)) text-values) all-bold? (every? #(is-bold? (:font-variant-id %)) text-values)
all-italic? (every? #(is-italic? (:font-variant-id %)) text-values) all-italic? (every? #(is-italic? (:font-variant-id %)) text-values)]
]
(cond (cond
(= (:text-decoration props) "toggle-underline") (= (:text-decoration props) "toggle-underline")
(if all-underline? (if all-underline?
@ -197,9 +195,9 @@
(blend-props text-shapes props) (blend-props text-shapes props)
props)] props)]
(when (and (not read-only?) text-shapes) (when (and (not read-only?) text-shapes)
(st/emit! (dwu/start-undo-transaction undo-id)) (st/emit! (dwu/start-undo-transaction undo-id))
(run! #(update-attrs % props) text-shapes) (run! #(update-attrs % props) text-shapes)
(st/emit! (dwu/commit-undo-transaction undo-id))))) (st/emit! (dwu/commit-undo-transaction undo-id)))))
(def shortcuts (def shortcuts
{:text-align-left {:tooltip (ds/meta (ds/alt "L")) {:text-align-left {:tooltip (ds/meta (ds/alt "L"))

View file

@ -339,8 +339,7 @@
(and (d/not-empty? color-attrs) (nil? (:fills node))) (and (d/not-empty? color-attrs) (nil? (:fills node)))
(-> (dissoc :fill-color :fill-opacity :fill-color-ref-id :fill-color-ref-file :fill-color-gradient) (-> (dissoc :fill-color :fill-opacity :fill-color-ref-id :fill-color-ref-file :fill-color-gradient)
(assoc :fills [color-attrs]))) (assoc :fills [color-attrs])))))
))
(defn migrate-content (defn migrate-content
[content] [content]

View file

@ -45,13 +45,13 @@
;; for example, right will only grow in the x coordinate and left ;; for example, right will only grow in the x coordinate and left
;; will grow in the inverse of the x coordinate ;; will grow in the inverse of the x coordinate
(def ^:private handler-multipliers (def ^:private handler-multipliers
{:right [ 1 0] {:right [1 0]
:bottom [ 0 1] :bottom [0 1]
:left [-1 0] :left [-1 0]
:top [ 0 -1] :top [0 -1]
:top-right [ 1 -1] :top-right [1 -1]
:top-left [-1 -1] :top-left [-1 -1]
:bottom-right [ 1 1] :bottom-right [1 1]
:bottom-left [-1 1]}) :bottom-left [-1 1]})
(defn- handler-resize-origin (defn- handler-resize-origin

View file

@ -64,13 +64,13 @@
items (conj-undo-entry items entry)] items (conj-undo-entry items entry)]
(-> state (-> state
(update :workspace-undo assoc :items items (update :workspace-undo assoc :items items
:index (min (inc index) :index (min (inc index)
(dec MAX-UNDO-SIZE))))) (dec MAX-UNDO-SIZE)))))
state)) state))
(defn- stack-undo-entry (defn- stack-undo-entry
[state {:keys [undo-changes redo-changes] :as entry}] [state {:keys [undo-changes redo-changes] :as entry}]
(let [index (get-in state [:workspace-undo :index] -1)] (let [index (get-in state [:workspace-undo :index] -1)]
(if (>= index 0) (if (>= index 0)
(update-in state [:workspace-undo :items index] (update-in state [:workspace-undo :items index]
(fn [item] (fn [item]
@ -86,7 +86,7 @@
(update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes)) (update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes))
(cond-> (cond->
(nil? (get-in state [:workspace-undo :transaction :undo-group])) (nil? (get-in state [:workspace-undo :transaction :undo-group]))
(assoc-in [:workspace-undo :transaction :undo-group] undo-group)) (assoc-in [:workspace-undo :transaction :undo-group] undo-group))
(assoc-in [:workspace-undo :transaction :tags] tags))) (assoc-in [:workspace-undo :transaction :tags] tags)))
(defn append-undo (defn append-undo
@ -101,18 +101,18 @@
(ptk/reify ::append-undo (ptk/reify ::append-undo
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(cond (cond
(and (get-in state [:workspace-undo :transaction]) (and (get-in state [:workspace-undo :transaction])
(or (not stack?) (or (not stack?)
(d/not-empty? (get-in state [:workspace-undo :transaction :undo-changes])) (d/not-empty? (get-in state [:workspace-undo :transaction :undo-changes]))
(d/not-empty? (get-in state [:workspace-undo :transaction :redo-changes])))) (d/not-empty? (get-in state [:workspace-undo :transaction :redo-changes]))))
(accumulate-undo-entry state entry) (accumulate-undo-entry state entry)
stack? stack?
(stack-undo-entry state entry) (stack-undo-entry state entry)
:else :else
(add-undo-entry state entry))))) (add-undo-entry state entry)))))
(def empty-tx (def empty-tx
{:undo-changes [] :redo-changes []}) {:undo-changes [] :redo-changes []})

View file

@ -196,40 +196,40 @@
(if-not (exists? js/window) (if-not (exists? js/window)
;; If we are in the worker environment, we just mark it as loaded ;; If we are in the worker environment, we just mark it as loaded
;; without really loading it. ;; without really loading it.
(do (do
(swap! loaded-hints conj {:font-id font-id :font-variant-id variant-id}) (swap! loaded-hints conj {:font-id font-id :font-variant-id variant-id})
(p/resolved font-id)) (p/resolved font-id))
(let [font (get @fontsdb font-id)] (let [font (get @fontsdb font-id)]
(cond (cond
(nil? font) (nil? font)
(p/resolved font-id) (p/resolved font-id)
;; Font already loaded, we just continue ;; Font already loaded, we just continue
(contains? @loaded font-id) (contains? @loaded font-id)
(p/resolved font-id) (p/resolved font-id)
;; Font is currently downloading. We attach the caller to the promise ;; Font is currently downloading. We attach the caller to the promise
(contains? @loading font-id) (contains? @loading font-id)
(p/resolved (get @loading font-id)) (p/resolved (get @loading font-id))
;; First caller, we create the promise and then wait ;; First caller, we create the promise and then wait
:else :else
(let [on-load (fn [resolve] (let [on-load (fn [resolve]
(swap! loaded conj font-id) (swap! loaded conj font-id)
(swap! loading dissoc font-id) (swap! loading dissoc font-id)
(resolve font-id)) (resolve font-id))
load-p (->> (p/create load-p (->> (p/create
(fn [resolve _] (fn [resolve _]
(-> font (-> font
(assoc ::on-loaded (partial on-load resolve)) (assoc ::on-loaded (partial on-load resolve))
(load-font)))) (load-font))))
;; We need to wait for the font to be loaded ;; We need to wait for the font to be loaded
(p/delay 120))] (p/delay 120))]
(swap! loading assoc font-id load-p) (swap! loading assoc font-id load-p)
load-p)))))) load-p))))))
(defn ready (defn ready
[cb] [cb]
@ -253,22 +253,22 @@
[node] [node]
(let [nodes (.from js/Array (dom/query-all node "[style*=font]")) (let [nodes (.from js/Array (dom/query-all node "[style*=font]"))
result (.reduce nodes (fn [obj node] result (.reduce nodes (fn [obj node]
(let [style (.-style node) (let [style (.-style node)
font-family (.-fontFamily style) font-family (.-fontFamily style)
[_ font] (first [_ font] (first
(filter (fn [[_ {:keys [id family]}]] (filter (fn [[_ {:keys [id family]}]]
(or (= family font-family) (or (= family font-family)
(= id font-family))) (= id font-family)))
@fontsdb)) @fontsdb))
font-id (:id font) font-id (:id font)
font-variant (get-variant font (.-fontVariant style)) font-variant (get-variant font (.-fontVariant style))
font-variant-id (:id font-variant)] font-variant-id (:id font-variant)]
(obj/set! (obj/set!
obj obj
(dm/str font-id ":" font-variant-id) (dm/str font-id ":" font-variant-id)
{:font-id font-id {:font-id font-id
:font-variant-id font-variant-id}))) :font-variant-id font-variant-id})))
#js {})] #js {})]
(.values js/Object result))) (.values js/Object result)))
(defn get-content-fonts (defn get-content-fonts

View file

@ -339,53 +339,53 @@
{::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]} {::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]}
[{:keys [objects root-shape show-grids? zoom] :or {zoom 1} :as props}] [{:keys [objects root-shape show-grids? zoom] :or {zoom 1} :as props}]
(when root-shape (when root-shape
(let [root-shape-id (:id root-shape) (let [root-shape-id (:id root-shape)
include-metadata (mf/use-ctx export/include-metadata-ctx) include-metadata (mf/use-ctx export/include-metadata-ctx)
vector vector
(mf/use-memo (mf/use-memo
(mf/deps (:x root-shape) (:y root-shape)) (mf/deps (:x root-shape) (:y root-shape))
(fn [] (fn []
(-> (gpt/point (:x root-shape) (:y root-shape)) (-> (gpt/point (:x root-shape) (:y root-shape))
(gpt/negate)))) (gpt/negate))))
objects objects
(mf/use-memo (mf/use-memo
(mf/deps vector objects root-shape-id) (mf/deps vector objects root-shape-id)
(fn [] (fn []
(let [children-ids (cons root-shape-id (cfh/get-children-ids objects root-shape-id)) (let [children-ids (cons root-shape-id (cfh/get-children-ids objects root-shape-id))
update-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))] update-fn #(update %1 %2 gsh/transform-shape (ctm/move-modifiers vector))]
(reduce update-fn objects children-ids)))) (reduce update-fn objects children-ids))))
root-shape' (get objects root-shape-id) root-shape' (get objects root-shape-id)
width (* (:width root-shape') zoom) width (* (:width root-shape') zoom)
height (* (:height root-shape') zoom) height (* (:height root-shape') zoom)
vbox (format-viewbox {:width (:width root-shape' 0) vbox (format-viewbox {:width (:width root-shape' 0)
:height (:height root-shape' 0)}) :height (:height root-shape' 0)})
root-shape-wrapper root-shape-wrapper
(mf/use-memo (mf/use-memo
(mf/deps objects root-shape') (mf/deps objects root-shape')
(fn [] (fn []
(case (:type root-shape') (case (:type root-shape')
:group (group-wrapper-factory objects) :group (group-wrapper-factory objects)
:frame (frame-wrapper-factory objects))))] :frame (frame-wrapper-factory objects))))]
[:svg {:view-box vbox [:svg {:view-box vbox
:width (ust/format-precision width viewbox-decimal-precision) :width (ust/format-precision width viewbox-decimal-precision)
:height (ust/format-precision height viewbox-decimal-precision) :height (ust/format-precision height viewbox-decimal-precision)
:version "1.1" :version "1.1"
:xmlns "http://www.w3.org/2000/svg" :xmlns "http://www.w3.org/2000/svg"
:xmlnsXlink "http://www.w3.org/1999/xlink" :xmlnsXlink "http://www.w3.org/1999/xlink"
:xmlns:penpot (when include-metadata "https://penpot.app/xmlns") :xmlns:penpot (when include-metadata "https://penpot.app/xmlns")
:fill "none"} :fill "none"}
[:* [:*
[:> shape-container {:shape root-shape'} [:> shape-container {:shape root-shape'}
[:& (mf/provider muc/is-component?) {:value true} [:& (mf/provider muc/is-component?) {:value true}
[:& root-shape-wrapper {:shape root-shape' :view-box vbox}]]] [:& root-shape-wrapper {:shape root-shape' :view-box vbox}]]]
(when show-grids? (when show-grids?
[:& empty-grids {:root-shape-id root-shape-id :objects objects}])]]))) [:& empty-grids {:root-shape-id root-shape-id :objects objects}])]])))
(mf/defc component-svg-thumbnail (mf/defc component-svg-thumbnail
{::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]} {::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]}

View file

@ -66,8 +66,7 @@
:form-data? true} :form-data? true}
:export-binfile {:response-type :blob} :export-binfile {:response-type :blob}
:retrieve-list-of-builtin-templates {:query-params :all} :retrieve-list-of-builtin-templates {:query-params :all}})
})
(defn- send! (defn- send!
"A simple helper for a common case of sending and receiving transit "A simple helper for a common case of sending and receiving transit

View file

@ -181,7 +181,7 @@
range-tree range-tree
(- cd snap-distance-accuracy) (- cd snap-distance-accuracy)
(+ cd snap-distance-accuracy)) (+ cd snap-distance-accuracy))
(map #(- (first %) cd )))))))) (map #(- (first %) cd))))))))
get-middle-snaps get-middle-snaps
(fn [lt-dist gt-dist] (fn [lt-dist gt-dist]

View file

@ -43,7 +43,7 @@
(when (and *debug-events* (when (and *debug-events*
(ptk/event? e) (ptk/event? e)
(not (debug-exclude-events (ptk/type e)))) (not (debug-exclude-events (ptk/type e))))
(.log js/console (str "[stream]: " (ptk/repr-event e)) ))))) (.log js/console (str "[stream]: " (ptk/repr-event e)))))))
(defonce state (defonce state
(ptk/store {:resolve ptk/resolve (ptk/store {:resolve ptk/resolve

View file

@ -33,16 +33,16 @@
(def ^:private xform-css (def ^:private xform-css
(keep (fn [k] (keep (fn [k]
(cond (cond
(keyword? k) (keyword? k)
(let [knm (name k) (let [knm (name k)
kns (namespace k)] kns (namespace k)]
(case kns (case kns
"global" knm "global" knm
(str *css-prefix* knm))) (str *css-prefix* knm)))
(string? k) (string? k)
k)))) k))))
(defmacro css* (defmacro css*
"Just coerces all params to strings and concats them with "Just coerces all params to strings and concats them with

View file

@ -40,18 +40,18 @@
(dom/prevent-default event) (dom/prevent-default event)
(->> (rp/cmd! :login-with-oidc (assoc params :provider provider)) (->> (rp/cmd! :login-with-oidc (assoc params :provider provider))
(rx/subs! (fn [{:keys [redirect-uri] :as rsp}] (rx/subs! (fn [{:keys [redirect-uri] :as rsp}]
(if redirect-uri (if redirect-uri
(.replace js/location redirect-uri) (.replace js/location redirect-uri)
(log/error :hint "unexpected response from OIDC method" (log/error :hint "unexpected response from OIDC method"
:resp (pr-str rsp)))) :resp (pr-str rsp))))
(fn [{:keys [type code] :as error}] (fn [{:keys [type code] :as error}]
(cond (cond
(and (= type :restriction) (and (= type :restriction)
(= code :provider-not-configured)) (= code :provider-not-configured))
(st/emit! (dm/error (tr "errors.auth-provider-not-configured"))) (st/emit! (dm/error (tr "errors.auth-provider-not-configured")))
:else :else
(st/emit! (dm/error (tr "errors.generic")))))))) (st/emit! (dm/error (tr "errors.generic"))))))))
(defn- login-with-ldap (defn- login-with-ldap
[event params] [event params]
@ -60,20 +60,20 @@
(let [{:keys [on-error]} (meta params)] (let [{:keys [on-error]} (meta params)]
(->> (rp/cmd! :login-with-ldap params) (->> (rp/cmd! :login-with-ldap params)
(rx/subs! (fn [profile] (rx/subs! (fn [profile]
(if-let [token (:invitation-token profile)] (if-let [token (:invitation-token profile)]
(st/emit! (rt/nav :auth-verify-token {} {:token token})) (st/emit! (rt/nav :auth-verify-token {} {:token token}))
(st/emit! (du/login-from-token {:profile profile})))) (st/emit! (du/login-from-token {:profile profile}))))
(fn [{:keys [type code] :as error}] (fn [{:keys [type code] :as error}]
(cond (cond
(and (= type :restriction) (and (= type :restriction)
(= code :ldap-not-initialized)) (= code :ldap-not-initialized))
(st/emit! (dm/error (tr "errors.ldap-disabled"))) (st/emit! (dm/error (tr "errors.ldap-disabled")))
(fn? on-error) (fn? on-error)
(on-error error) (on-error error)
:else :else
(st/emit! (dm/error (tr "errors.generic"))))))))) (st/emit! (dm/error (tr "errors.generic")))))))))
(s/def ::email ::us/email) (s/def ::email ::us/email)
(s/def ::password ::us/not-empty-string) (s/def ::password ::us/not-empty-string)

View file

@ -232,7 +232,7 @@
(->> (rp/cmd! :register-profile params) (->> (rp/cmd! :register-profile params)
(rx/finalize #(reset! submitted? false)) (rx/finalize #(reset! submitted? false))
(rx/subs! on-success (rx/subs! on-success
(partial handle-register-error form))))))] (partial handle-register-error form))))))]
[:& fm/form {:on-submit on-submit :form form} [:& fm/form {:on-submit on-submit :form form}
[:div {:class (stl/css :fields-row)} [:div {:class (stl/css :fields-row)}

View file

@ -28,7 +28,7 @@
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc resizing-textarea (mf/defc resizing-textarea
{::mf/wrap-props false } {::mf/wrap-props false}
[props] [props]
(let [value (d/nilv (unchecked-get props "value") "") (let [value (d/nilv (unchecked-get props "value") "")
on-focus (unchecked-get props "on-focus") on-focus (unchecked-get props "on-focus")
@ -51,14 +51,14 @@
on-key-down on-key-down
(mf/use-fn (mf/use-fn
(mf/deps on-esc on-ctrl-enter on-change*) (mf/deps on-esc on-ctrl-enter on-change*)
(fn [event] (fn [event]
(cond (cond
(and (kbd/esc? event) (fn? on-esc)) (on-esc event) (and (kbd/esc? event) (fn? on-esc)) (on-esc event)
(and (kbd/mod? event) (kbd/enter? event) (fn? on-ctrl-enter)) (and (kbd/mod? event) (kbd/enter? event) (fn? on-ctrl-enter))
(do (do
(on-change* event) (on-change* event)
(on-ctrl-enter event))))) (on-ctrl-enter event)))))
on-focus* on-focus*
(mf/use-fn (mf/use-fn
@ -168,13 +168,13 @@
on-change on-change
(mf/use-fn (mf/use-fn
(mf/deps draft) (mf/deps draft)
(fn [content] (fn [content]
(st/emit! (dcm/update-draft-thread {:content content})))) (st/emit! (dcm/update-draft-thread {:content content}))))
on-submit on-submit
(mf/use-fn (mf/use-fn
(mf/deps draft) (mf/deps draft)
(partial on-submit draft))] (partial on-submit draft))]
[:* [:*
[:div [:div

View file

@ -1,10 +1,10 @@
(ns app.main.ui.components.buttons.simple-button (ns app.main.ui.components.buttons.simple-button
(:require-macros [app.main.style :as stl]) (:require-macros [app.main.style :as stl])
(:require (:require
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(mf/defc simple-button (mf/defc simple-button
{::mf/wrap-props false} {::mf/wrap-props false}
[{:keys [on-click children]}] [{:keys [on-click children]}]
[:button {:on-click on-click :class (stl/css :button)} children]) [:button {:on-click on-click :class (stl/css :button)} children])

View file

@ -37,11 +37,11 @@
(cond (cond
(:gradient color) (:gradient color)
[:div.color-bullet-wrapper {:style {:background (uc/color->background color)}}] [:div.color-bullet-wrapper {:style {:background (uc/color->background color)}}]
(:image color) (:image color)
(let [uri (cfg/resolve-file-media (:image color))] (let [uri (cfg/resolve-file-media (:image color))]
[:div.color-bullet-wrapper {:style {:background-size "contain" :background-image (str/ffmt "url(%)" uri)}}]) [:div.color-bullet-wrapper {:style {:background-size "contain" :background-image (str/ffmt "url(%)" uri)}}])
:else :else
[:div.color-bullet-wrapper [:div.color-bullet-wrapper
[:div.color-bullet-left {:style {:background (uc/color->background (assoc color :opacity 1))}}] [:div.color-bullet-left {:style {:background (uc/color->background (assoc color :opacity 1))}}]

View file

@ -114,20 +114,20 @@
on-mouse-up on-mouse-up
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(dom/prevent-default event))) (dom/prevent-default event)))
handle-focus handle-focus
(mf/use-fn (mf/use-fn
(fn [event] (fn [event]
(let [target (dom/get-target event)] (let [target (dom/get-target event)]
(when on-focus (when on-focus
(on-focus event)) (on-focus event))
(when select-on-focus? (when select-on-focus?
(-> event (dom/get-target) (.select)) (-> event (dom/get-target) (.select))
;; In webkit browsers the mouseup event will be called after the on-focus causing and unselect ;; In webkit browsers the mouseup event will be called after the on-focus causing and unselect
(.addEventListener target "mouseup" on-mouse-up #js {"once" true}))))) (.addEventListener target "mouseup" on-mouse-up #js {"once" true})))))
props (-> (obj/clone props) props (-> (obj/clone props)
(obj/unset! "selectOnFocus") (obj/unset! "selectOnFocus")

View file

@ -361,17 +361,17 @@
(zero? (count @items))) (zero? (count @items)))
klass (str (get props :class) " " klass (str (get props :class) " "
(stl/css-case (stl/css-case
:focus @focus? :focus @focus?
:valid (and touched? (not error)) :valid (and touched? (not error))
:invalid (and touched? error) :invalid (and touched? error)
:empty empty? :empty empty?
:custom-multi-input true)) :custom-multi-input true))
in-klass (str class " " in-klass (str class " "
(stl/css-case (stl/css-case
:inside-input true :inside-input true
:no-padding (pos? (count @items)))) :no-padding (pos? (count @items))))
on-focus on-focus
(mf/use-fn #(reset! focus? true)) (mf/use-fn #(reset! focus? true))
@ -481,7 +481,7 @@
(> (count value) length)) (> (count value) length))
(defn validate-length (defn validate-length
[field length errors-msg ] [field length errors-msg]
(fn [errors data] (fn [errors data]
(cond-> errors (cond-> errors
(max-length? (get data field) length) (max-length? (get data field) length)
@ -500,6 +500,6 @@
(let [value (get data field)] (let [value (get data field)]
(cond-> errors (cond-> errors
(and (and
(all-spaces? value) (all-spaces? value)
(> (count value) 0)) (> (count value) 0))
(assoc field {:message error-msg}))))) (assoc field {:message error-msg})))))

View file

@ -18,4 +18,4 @@
(keyboard-action event))) (keyboard-action event)))
:tab-index "0" :tab-index "0"
:data-test data-test} :data-test data-test}
[:* children]])) [:* children]]))

View file

@ -46,7 +46,7 @@
(when ^boolean enter? (dom/blur! node)) (when ^boolean enter? (dom/blur! node))
(when ^boolean esc? (dom/blur! node)))))] (when ^boolean esc? (dom/blur! node)))))]
[:span {:class (stl/css-case :search-box true [:span {:class (stl/css-case :search-box true
:has-children (some? children))} :has-children (some? children))}
children children
[:div {:class (stl/css :search-input-wrapper)} [:div {:class (stl/css :search-input-wrapper)}
icon icon

View file

@ -50,7 +50,7 @@
(when (fn? on-change) (on-change id)))))] (when (fn? on-change) (on-change id)))))]
[:div {:class (stl/css :tab-container)} [:div {:class (stl/css :tab-container)}
[:div {:class (dm/str class " "(stl/css :tab-container-tabs))} [:div {:class (dm/str class " " (stl/css :tab-container-tabs))}
(when collapsable? (when collapsable?
[:button [:button
{:on-click handle-collapse {:on-click handle-collapse
@ -67,7 +67,7 @@
:data-id (d/name id) :data-id (d/name id)
:on-click select-fn :on-click select-fn
:class (stl/css-case :tab-container-tab-title true :class (stl/css-case :tab-container-tab-title true
:current (= selected id))} :current (= selected id))}
title]))]] title]))]]
[:div {:class (dm/str content-class " " (stl/css :tab-container-content ))} [:div {:class (dm/str content-class " " (stl/css :tab-container-content))}
(d/seek #(= selected (-> % .-props .-id)) children)]])) (d/seek #(= selected (-> % .-props .-id)) children)]]))

View file

@ -43,7 +43,7 @@
team-id (get-in route [:params :path :team-id]) team-id (get-in route [:params :path :team-id])
project-id (get-in route [:params :path :project-id])] project-id (get-in route [:params :path :project-id])]
(cond-> (cond->
{:search-term search-term} {:search-term search-term}
(uuid-str? team-id) (uuid-str? team-id)
(assoc :team-id (uuid team-id)) (assoc :team-id (uuid team-id))

View file

@ -75,9 +75,9 @@
(with-meta {::ev/origin "dashboard"})))))] (with-meta {::ev/origin "dashboard"})))))]
(mf/use-effect (mf/use-effect
(mf/deps team-id) (mf/deps team-id)
(fn [] (fn []
(st/emit! (dcm/retrieve-unread-comment-threads team-id)))) (st/emit! (dcm/retrieve-unread-comment-threads team-id))))
(mf/use-effect (mf/use-effect
(mf/deps show?) (mf/deps show?)

View file

@ -196,7 +196,7 @@
(->> (rp/cmd! :get-all-projects) (->> (rp/cmd! :get-all-projects)
(rx/map group-by-team) (rx/map group-by-team)
(rx/subs! #(when (mf/ref-val mounted-ref) (rx/subs! #(when (mf/ref-val mounted-ref)
(reset! teams %))))))) (reset! teams %)))))))
(when current-team (when current-team
(let [sub-options (concat (vec (for [project current-projects] (let [sub-options (concat (vec (for [project current-projects]

View file

@ -67,9 +67,9 @@
(fn [blobs] (fn [blobs]
(->> (df/process-upload blobs (:id team)) (->> (df/process-upload blobs (:id team))
(rx/subs! (fn [result] (rx/subs! (fn [result]
(swap! fonts df/merge-and-group-fonts installed-fonts result)) (swap! fonts df/merge-and-group-fonts installed-fonts result))
(fn [error] (fn [error]
(js/console.error "error" error)))))) (js/console.error "error" error))))))
on-upload on-upload
(mf/use-callback (mf/use-callback
@ -79,11 +79,11 @@
(->> (rp/cmd! :create-font-variant item) (->> (rp/cmd! :create-font-variant item)
(rx/delay-at-least 2000) (rx/delay-at-least 2000)
(rx/subs! (fn [font] (rx/subs! (fn [font]
(swap! fonts dissoc (:id item)) (swap! fonts dissoc (:id item))
(swap! uploading disj (:id item)) (swap! uploading disj (:id item))
(st/emit! (df/add-font font))) (st/emit! (df/add-font font)))
(fn [error] (fn [error]
(js/console.log "error" error)))))) (js/console.log "error" error))))))
on-upload-all on-upload-all
(fn [items] (fn [items]

View file

@ -74,12 +74,12 @@
(when (and visible? (not thumbnail-uri)) (when (and visible? (not thumbnail-uri))
(->> (ask-for-thumbnail file-id revn) (->> (ask-for-thumbnail file-id revn)
(rx/subs! (fn [url] (rx/subs! (fn [url]
(st/emit! (dd/set-file-thumbnail file-id url))) (st/emit! (dd/set-file-thumbnail file-id url)))
(fn [cause] (fn [cause]
(log/error :hint "unable to render thumbnail" (log/error :hint "unable to render thumbnail"
:file-if file-id :file-if file-id
:revn revn :revn revn
:message (ex-message cause))))))) :message (ex-message cause)))))))
[:div {:class (stl/css :grid-item-th) [:div {:class (stl/css :grid-item-th)
:style {:background-color background-color} :style {:background-color background-color}
@ -514,12 +514,12 @@
(do (do
(dom/prevent-default e) (dom/prevent-default e)
(when-not (or (dnd/from-child? e) (when-not (or (dnd/from-child? e)
(dnd/broken-event? e)) (dnd/broken-event? e))
(when (not= selected-project project-id) (when (not= selected-project project-id)
(reset! dragging? true)))) (reset! dragging? true))))
(or (dnd/has-type? e "Files") (or (dnd/has-type? e "Files")
(dnd/has-type? e "application/x-moz-file")) (dnd/has-type? e "application/x-moz-file"))
(do (do
(dom/prevent-default e) (dom/prevent-default e)
(reset! dragging? true))))) (reset! dragging? true)))))
@ -559,7 +559,7 @@
(st/emit! (dd/move-files (with-meta data mdata)))))) (st/emit! (dd/move-files (with-meta data mdata))))))
(or (dnd/has-type? e "Files") (or (dnd/has-type? e "Files")
(dnd/has-type? e "application/x-moz-file")) (dnd/has-type? e "application/x-moz-file"))
(do (do
(dom/prevent-default e) (dom/prevent-default e)
(reset! dragging? false) (reset! dragging? false)

View file

@ -82,40 +82,40 @@
(when (fn? on-import) (on-import)))) (when (fn? on-import) (on-import))))
options [(when-not (:is-default project) options [(when-not (:is-default project)
{:option-name (tr "labels.rename") {:option-name (tr "labels.rename")
:id "project-menu-rename" :id "project-menu-rename"
:option-handler on-edit :option-handler on-edit
:data-test "project-rename"}) :data-test "project-rename"})
(when-not (:is-default project) (when-not (:is-default project)
{:option-name (tr "dashboard.duplicate") {:option-name (tr "dashboard.duplicate")
:id "project-menu-duplicated" :id "project-menu-duplicated"
:option-handler on-duplicate :option-handler on-duplicate
:data-test "project-duplicate"}) :data-test "project-duplicate"})
(when-not (:is-default project) (when-not (:is-default project)
{:option-name (tr "dashboard.pin-unpin") {:option-name (tr "dashboard.pin-unpin")
:id "project-menu-pin" :id "project-menu-pin"
:option-handler toggle-pin}) :option-handler toggle-pin})
(when (and (seq teams) (not (:is-default project))) (when (and (seq teams) (not (:is-default project)))
{:option-name (tr "dashboard.move-to") {:option-name (tr "dashboard.move-to")
:id "project-menu-move-to" :id "project-menu-move-to"
:sub-options (for [team teams] :sub-options (for [team teams]
{:option-name (:name team) {:option-name (:name team)
:id (:name team) :id (:name team)
:option-handler (on-move (:id team))}) :option-handler (on-move (:id team))})
:data-test "project-move-to"}) :data-test "project-move-to"})
(when (some? on-import) (when (some? on-import)
{:option-name (tr "dashboard.import") {:option-name (tr "dashboard.import")
:id "project-menu-import" :id "project-menu-import"
:option-handler on-import-files :option-handler on-import-files
:data-test "file-import"}) :data-test "file-import"})
(when-not (:is-default project) (when-not (:is-default project)
{:option-name :separator}) {:option-name :separator})
(when-not (:is-default project) (when-not (:is-default project)
{:option-name (tr "labels.delete") {:option-name (tr "labels.delete")
:id "project-menu-delete" :id "project-menu-delete"
:option-handler on-delete :option-handler on-delete
:data-test "project-delete"})]] :data-test "project-delete"})]]
[:* [:*
[:& udi/import-form {:ref file-input [:& udi/import-form {:ref file-input

View file

@ -370,8 +370,8 @@
you-admin? (get-in team [:permissions :is-admin]) you-admin? (get-in team [:permissions :is-admin])
can-invite? (or you-owner? you-admin?) can-invite? (or you-owner? you-admin?)
team-hero? (and can-invite? team-hero? (and can-invite?
(:team-hero? props true) (:team-hero? props true)
(not (:is-default team))) (not (:is-default team)))
tutorial-viewed? (:viewed-tutorial? props true) tutorial-viewed? (:viewed-tutorial? props true)
walkthrough-viewed? (:viewed-walkthrough? props true) walkthrough-viewed? (:viewed-walkthrough? props true)

View file

@ -949,7 +949,7 @@
(mf/with-effect [team] (mf/with-effect [team]
(st/emit! (dd/fetch-team-webhooks))) (st/emit! (dd/fetch-team-webhooks)))
[:* [:*
[:& header {:team team :section :dashboard-team-webhooks}] [:& header {:team team :section :dashboard-team-webhooks}]
[:section {:class (stl/css :dashboard-container :dashboard-team-webhooks)} [:section {:class (stl/css :dashboard-container :dashboard-team-webhooks)}
[:* [:*

View file

@ -5,7 +5,7 @@
;; Copyright (c) KALEIDOS INC ;; Copyright (c) KALEIDOS INC
(ns app.main.ui.delete-shared (ns app.main.ui.delete-shared
(:require-macros [app.main.style :as stl]) (:require-macros [app.main.style :as stl])
(:require (:require
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]

View file

@ -147,9 +147,9 @@
[:div {:class (stl/css :modal-footer)} [:div {:class (stl/css :modal-footer)}
[:div {:class (stl/css :action-buttons)} [:div {:class (stl/css :action-buttons)}
[:input {:class (stl/css :cancel-button) [:input {:class (stl/css :cancel-button)
:type "button" :type "button"
:value (tr "labels.cancel") :value (tr "labels.cancel")
:on-click cancel-fn}] :on-click cancel-fn}]
[:input {:class (stl/css-case :accept-btn true [:input {:class (stl/css-case :accept-btn true
:btn-disabled (or in-progress? all-unchecked?)) :btn-disabled (or in-progress? all-unchecked?))

View file

@ -13,14 +13,14 @@
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[] []
(let [iframe-ref (mf/use-ref nil) (let [iframe-ref (mf/use-ref nil)
last-data* (mf/use-state nil) last-data* (mf/use-state nil)
zoom-ref (mf/use-ref nil) zoom-ref (mf/use-ref nil)
zoom* (mf/use-state 1) zoom* (mf/use-state 1)
zoom @zoom* zoom @zoom*
handle-load handle-load
(mf/use-callback (mf/use-callback
@ -33,7 +33,7 @@
(-> iframe-dom .-contentWindow .-document .open) (-> iframe-dom .-contentWindow .-document .open)
(-> iframe-dom .-contentWindow .-document (.write data)) (-> iframe-dom .-contentWindow .-document (.write data))
(-> iframe-dom .-contentWindow .-document .close))))) (-> iframe-dom .-contentWindow .-document .close)))))
load-ref load-ref
(mf/use-callback (mf/use-callback
(fn [iframe-dom] (fn [iframe-dom]
@ -54,7 +54,7 @@
(fn [] (fn []
(aset js/window "load" handle-load) (aset js/window "load" handle-load)
#(js-delete js/window "load"))) #(js-delete js/window "load")))
[:div {:style {:display "flex" :width "100%" :height "100%" :flex-direction "column" :overflow "auto" :align-items "center"}} [:div {:style {:display "flex" :width "100%" :height "100%" :flex-direction "column" :overflow "auto" :align-items "center"}}
[:input {:id "zoom-input" [:input {:id "zoom-input"
:ref zoom-ref :ref zoom-ref
@ -65,6 +65,6 @@
[:div {:style {:width "100%" :height "100%" :overflow "auto"}} [:div {:style {:width "100%" :height "100%" :overflow "auto"}}
[:iframe {:ref load-ref [:iframe {:ref load-ref
:frame-border "0" :frame-border "0"
:scrolling "no" :scrolling "no"
:style {:transform-origin "top left" :style {:transform-origin "top left"
:transform (str "scale(" zoom ")")}}]]])) :transform (str "scale(" zoom ")")}}]]]))

View file

@ -385,11 +385,11 @@
mnt? (volatile! true) mnt? (volatile! true)
sub (->> (wapi/observe-resize node) sub (->> (wapi/observe-resize node)
(rx/subs! (fn [entries] (rx/subs! (fn [entries]
(let [row (first entries) (let [row (first entries)
row-rect (.-contentRect ^js row) row-rect (.-contentRect ^js row)
row-width (.-width ^js row-rect)] row-width (.-width ^js row-rect)]
(when @mnt? (when @mnt?
(reset! width* row-width))))))] (reset! width* row-width))))))]
(fn [] (fn []
(vreset! mnt? false) (vreset! mnt? false)
(rx/dispose! sub)))) (rx/dispose! sub))))

View file

@ -96,18 +96,18 @@
(or (and (neg? ss) (pos? se)) (or (and (neg? ss) (pos? se))
(and (pos? ss) (neg? ee)) (and (pos? ss) (neg? ee))
(and (neg? ss) (> ss se))) (and (neg? ss) (> ss se)))
(conj [ from-s (+ from-s ss) ]) (conj [from-s (+ from-s ss)])
(and (neg? se) (<= ss se)) (and (neg? se) (<= ss se))
(conj [ from-s (+ from-s se) ]) (conj [from-s (+ from-s se)])
(and (pos? es) (<= es ee)) (and (pos? es) (<= es ee))
(conj [ from-e (+ from-e es) ]) (conj [from-e (+ from-e es)])
(or (and (pos? ee) (neg? es)) (or (and (pos? ee) (neg? es))
(and (neg? ee) (pos? ss)) (and (neg? ee) (pos? ss))
(and (pos? ee) (< ee es))) (and (pos? ee) (< ee es)))
(conj [ from-e (+ from-e ee) ])))) (conj [from-e (+ from-e ee)]))))
;; ------------------------------------------------ ;; ------------------------------------------------
;; COMPONENTS ;; COMPONENTS
@ -383,9 +383,9 @@
pill-width (/ flex-display-pill-width zoom) pill-width (/ flex-display-pill-width zoom)
pill-height (/ flex-display-pill-height zoom) pill-height (/ flex-display-pill-height zoom)
hover? #(or hover-all? hover? #(or hover-all?
(and (or (= % :p1) (= % :p3)) hover-v?) (and (or (= % :p1) (= % :p3)) hover-v?)
(and (or (= % :p2) (= % :p4)) hover-h?) (and (or (= % :p2) (= % :p4)) hover-h?)
(= @hover %)) (= @hover %))
negate {:p1 (if (:flip-y frame) true false) negate {:p1 (if (:flip-y frame) true false)
:p2 (if (:flip-x frame) true false) :p2 (if (:flip-x frame) true false)
:p3 (if (:flip-y frame) true false) :p3 (if (:flip-y frame) true false)
@ -459,7 +459,7 @@
:value @hover-value}])])) :value @hover-value}])]))
(mf/defc margin-display [{:keys [shape-id zoom hover-all? hover-v? hover-h? margin-num margin on-pointer-enter on-pointer-leave (mf/defc margin-display [{:keys [shape-id zoom hover-all? hover-v? hover-h? margin-num margin on-pointer-enter on-pointer-leave
rect-data hover? selected? mouse-pos hover-value]}] rect-data hover? selected? mouse-pos hover-value]}]
(let [resizing? (mf/use-var false) (let [resizing? (mf/use-var false)
start (mf/use-var nil) start (mf/use-var nil)
original-value (mf/use-var 0) original-value (mf/use-var 0)
@ -582,7 +582,7 @@
:resize-negate? (:flip-x frame)}}] :resize-negate? (:flip-x frame)}}]
[:g.margins {:pointer-events "visible"} [:g.margins {:pointer-events "visible"}
(for [[margin-num rect-data] margin-display-data] (for [[margin-num rect-data] margin-display-data]
[:& margin-display [:& margin-display
{:key (:key rect-data) {:key (:key rect-data)
:shape-id shape-id :shape-id shape-id
@ -611,7 +611,7 @@
:value @hover-value}])])) :value @hover-value}])]))
(mf/defc gap-display [{:keys [frame-id zoom gap-type gap on-pointer-enter on-pointer-leave (mf/defc gap-display [{:keys [frame-id zoom gap-type gap on-pointer-enter on-pointer-leave
rect-data hover? selected? mouse-pos hover-value]}] rect-data hover? selected? mouse-pos hover-value]}]
(let [resizing (mf/use-var nil) (let [resizing (mf/use-var nil)
start (mf/use-var nil) start (mf/use-var nil)
original-value (mf/use-var 0) original-value (mf/use-var 0)
@ -654,19 +654,19 @@
(reset! hover-value val) (reset! hover-value val)
(st/emit! (dwm/set-modifiers modifiers)))))))] (st/emit! (dwm/set-modifiers modifiers)))))))]
[:rect.gap-rect {:x (:x rect-data) [:rect.gap-rect {:x (:x rect-data)
:y (:y rect-data) :y (:y rect-data)
:width (:width rect-data) :width (:width rect-data)
:height (:height rect-data) :height (:height rect-data)
:on-pointer-enter on-pointer-enter :on-pointer-enter on-pointer-enter
:on-pointer-leave on-pointer-leave :on-pointer-leave on-pointer-leave
:on-pointer-down on-pointer-down :on-pointer-down on-pointer-down
:on-lost-pointer-capture on-lost-pointer-capture :on-lost-pointer-capture on-lost-pointer-capture
:on-pointer-move on-pointer-move :on-pointer-move on-pointer-move
:class (when (or hover? selected?) :class (when (or hover? selected?)
(if (= (:resize-axis rect-data) :x) (cur/get-dynamic "resize-ew" 0) (cur/get-dynamic "resize-ew" 90))) (if (= (:resize-axis rect-data) :x) (cur/get-dynamic "resize-ew" 0) (cur/get-dynamic "resize-ew" 90)))
:style {:fill (if (or hover? selected?) distance-color "none") :style {:fill (if (or hover? selected?) distance-color "none")
:opacity (if selected? 0.5 0.25)}}])) :opacity (if selected? 0.5 0.25)}}]))
(mf/defc gap-rects [{:keys [frame zoom]}] (mf/defc gap-rects [{:keys [frame zoom]}]
(let [frame-id (:id frame) (let [frame-id (:id frame)

View file

@ -93,7 +93,7 @@
(s/def ::questions-form-step-3 (s/def ::questions-form-step-3
(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-3-form-validator (defn- step-3-form-validator
[errors data] [errors data]
@ -134,7 +134,7 @@
(s/def ::questions-form-step-4 (s/def ::questions-form-step-4
(s/keys :req-un [::team-size ::role] (s/keys :req-un [::team-size ::role]
:opt-un [::role-other])) :opt-un [::role-other]))
(defn- step-4-form-validator (defn- step-4-form-validator
[errors data] [errors data]

View file

@ -40,11 +40,11 @@
(reset! downloading? true) (reset! downloading? true)
(->> (http/send! {:method :get :uri link :response-type :blob :mode :no-cors}) (->> (http/send! {:method :get :uri link :response-type :blob :mode :no-cors})
(rx/subs! (fn [{:keys [body] :as response}] (rx/subs! (fn [{:keys [body] :as response}]
(open-import-modal {:name name :uri (wapi/create-uri body)})) (open-import-modal {:name name :uri (wapi/create-uri body)}))
(fn [error] (fn [error]
(js/console.log "error" error)) (js/console.log "error" error))
(fn [] (fn []
(reset! downloading? false)))))] (reset! downloading? false)))))]
[:div.template-item [:div.template-item
[:div.template-item-content [:div.template-item-content

View file

@ -113,15 +113,15 @@
;; invitations workflows (and probably other cases). ;; invitations workflows (and probably other cases).
(->> (rp/cmd! :get-profile) (->> (rp/cmd! :get-profile)
(rx/subs! (fn [{:keys [id] :as profile}] (rx/subs! (fn [{:keys [id] :as profile}]
(cond (cond
(= id uuid/zero) (= id uuid/zero)
(st/emit! (rt/nav :auth-login)) (st/emit! (rt/nav :auth-login))
empty-path? empty-path?
(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)})) (st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))
:else :else
(st/emit! (rt/assign-exception {:type :not-found}))))))))) (st/emit! (rt/assign-exception {:type :not-found})))))))))
(defn init-routes (defn init-routes
[] []

View file

@ -89,13 +89,13 @@
on-email-change on-email-change
(mf/use-callback (mf/use-callback
(fn [_ _] (fn [_ _]
(let [different-emails-error? (= (dma/get-in @form [:errors :email-2 :code]) :different-emails) (let [different-emails-error? (= (dma/get-in @form [:errors :email-2 :code]) :different-emails)
email-1 (dma/get-in @form [:clean-data :email-1]) email-1 (dma/get-in @form [:clean-data :email-1])
email-2 (dma/get-in @form [:clean-data :email-2])] email-2 (dma/get-in @form [:clean-data :email-2])]
(println "different-emails-error?" (and different-emails-error? (= email-1 email-2))) (println "different-emails-error?" (and different-emails-error? (= email-1 email-2)))
(when (and different-emails-error? (= email-1 email-2)) (when (and different-emails-error? (= email-1 email-2))
(swap! form d/dissoc-in [:errors :email-2])))))] (swap! form d/dissoc-in [:errors :email-2])))))]
[:div {:class (stl/css :modal-overlay)} [:div {:class (stl/css :modal-overlay)}
[:div {:class (stl/css :modal-container)} [:div {:class (stl/css :modal-container)}
@ -134,8 +134,7 @@
[:div {:class (stl/css :action-buttons) [:div {:class (stl/css :action-buttons)
:data-test "change-email-submit"} :data-test "change-email-submit"}
[:> fm/submit-button* [:> fm/submit-button*
{:label (tr "modals.change-email.submit")}]]]]]] {:label (tr "modals.change-email.submit")}]]]]]]))
))

View file

@ -75,11 +75,11 @@
(mf/defc options-page (mf/defc options-page
[] []
(mf/use-effect (mf/use-effect
#(dom/set-html-title (tr "title.settings.options"))) #(dom/set-html-title (tr "title.settings.options")))
[:div {:class (stl/css :dashboard-settings)} [:div {:class (stl/css :dashboard-settings)}
[:div {:class (stl/css :form-container) :data-test "settings-form"} [:div {:class (stl/css :form-container) :data-test "settings-form"}
[:h2 (tr "labels.settings")] [:h2 (tr "labels.settings")]
[:& options-form {}]]]) [:& options-form {}]]])

View file

@ -30,42 +30,42 @@
go-dashboard go-dashboard
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))) #(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)})))
go-settings-profile go-settings-profile
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-profile))) #(st/emit! (rt/nav :settings-profile)))
go-settings-feedback go-settings-feedback
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-feedback))) #(st/emit! (rt/nav :settings-feedback)))
go-settings-password go-settings-password
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-password))) #(st/emit! (rt/nav :settings-password)))
go-settings-options go-settings-options
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-options))) #(st/emit! (rt/nav :settings-options)))
go-settings-access-tokens go-settings-access-tokens
(mf/use-callback (mf/use-callback
(mf/deps profile) (mf/deps profile)
#(st/emit! (rt/nav :settings-access-tokens))) #(st/emit! (rt/nav :settings-access-tokens)))
show-release-notes show-release-notes
(mf/use-callback (mf/use-callback
(fn [event] (fn [event]
(let [version (:main cf/version)] (let [version (:main cf/version)]
(st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version}))
(if (and (kbd/alt? event) (kbd/mod? event)) (if (and (kbd/alt? event) (kbd/mod? event))
(st/emit! (modal/show {:type :onboarding})) (st/emit! (modal/show {:type :onboarding}))
(st/emit! (modal/show {:type :release-notes :version version}))))))] (st/emit! (modal/show {:type :release-notes :version version}))))))]
[:div {:class (stl/css :sidebar-content)} [:div {:class (stl/css :sidebar-content)}
[:div {:class (stl/css :sidebar-content-section)} [:div {:class (stl/css :sidebar-content-section)}

View file

@ -144,7 +144,7 @@
(not= caps-start caps-end))) (not= caps-start caps-end)))
(obj/set! attrs "markerEnd" (str/ffmt "url(#marker-%-%)" render-id (name caps-end)))))))) (obj/set! attrs "markerEnd" (str/ffmt "url(#marker-%-%)" render-id (name caps-end))))))))
attrs)) attrs))
(defn add-layer-styles! (defn add-layer-styles!
[props shape] [props shape]
@ -197,15 +197,15 @@
(add-layer-styles! shape)) (add-layer-styles! shape))
url-fill? (or ^boolean (some? (:fill-image shape)) url-fill? (or ^boolean (some? (:fill-image shape))
^boolean (cfh/image-shape? shape) ^boolean (cfh/image-shape? shape)
^boolean (> (count shape-fills) 1) ^boolean (> (count shape-fills) 1)
^boolean (some? (some :fill-color-gradient shape-fills)) ^boolean (some? (some :fill-color-gradient shape-fills))
^boolean (some? (some :fill-image shape-fills))) ^boolean (some? (some :fill-image shape-fills)))
props (if (cfh/frame-shape? shape) props (if (cfh/frame-shape? shape)
props props
(if (or (some? (->> shape-shadow (remove :hidden) seq)) (if (or (some? (->> shape-shadow (remove :hidden) seq))
(and (some? shape-blur) (not ^boolean (:hidden shape-blur)))) (and (some? shape-blur) (not ^boolean (:hidden shape-blur))))
(obj/set! props "filter" (dm/fmt "url(#filter-%)" render-id)) (obj/set! props "filter" (dm/fmt "url(#filter-%)" render-id))
props))] props))]
@ -219,9 +219,9 @@
;; reset to normal if a Penpot frame shape appears below ;; reset to normal if a Penpot frame shape appears below
;; (see main.ui.shapes.frame/frame-container). ;; (see main.ui.shapes.frame/frame-container).
(and ^boolean (contains? shape :svg-attrs) (and ^boolean (contains? shape :svg-attrs)
^boolean (or ^boolean (= :svg-raw shape-type) ^boolean (or ^boolean (= :svg-raw shape-type)
^boolean (= :group shape-type)) ^boolean (= :group shape-type))
^boolean (empty? shape-fills)) ^boolean (empty? shape-fills))
(let [wstyle (get shape :wrapper-styles) (let [wstyle (get shape :wrapper-styles)
fill (obj/get wstyle "fill") fill (obj/get wstyle "fill")
fill (d/nilv fill clr/black)] fill (d/nilv fill clr/black)]
@ -234,7 +234,7 @@
(obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id))) (obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id)))
(and ^boolean (some? svg-styles) (and ^boolean (some? svg-styles)
^boolean (obj/contains? svg-styles "fill")) ^boolean (obj/contains? svg-styles "fill"))
(let [fill (obj/get svg-styles "fill") (let [fill (obj/get svg-styles "fill")
opacity (obj/get svg-styles "fillOpacity")] opacity (obj/get svg-styles "fillOpacity")]
(when (some? fill) (when (some? fill)
@ -243,7 +243,7 @@
(obj/set! style "fillOpacity" opacity))) (obj/set! style "fillOpacity" opacity)))
(and ^boolean (some? svg-attrs) (and ^boolean (some? svg-attrs)
^boolean (empty? shape-fills)) ^boolean (empty? shape-fills))
(let [fill (obj/get svg-attrs "fill") (let [fill (obj/get svg-attrs "fill")
opacity (obj/get svg-attrs "fillOpacity")] opacity (obj/get svg-attrs "fillOpacity")]
(when (some? fill) (when (some? fill)
@ -256,7 +256,7 @@
(obj/merge! style (get-fill-style fill render-id 0 shape-type))) (obj/merge! style (get-fill-style fill render-id 0 shape-type)))
(and ^boolean (cfh/path-shape? shape) (and ^boolean (cfh/path-shape? shape)
^boolean (empty? shape-fills)) ^boolean (empty? shape-fills))
(obj/set! style "fill" "none")) (obj/set! style "fill" "none"))
(-> props (-> props

View file

@ -105,106 +105,106 @@
(:stroke-opacity stroke))] (:stroke-opacity stroke))]
[:* [:*
(when (or (= cap-start :line-arrow) (when (or (= cap-start :line-arrow)
(= cap-end :line-arrow)) (= cap-end :line-arrow))
[:marker {:id (dm/str id-prefix "-line-arrow") [:marker {:id (dm/str id-prefix "-line-arrow")
:viewBox "0 0 3 6" :viewBox "0 0 3 6"
:refX "2" :refX "2"
:refY "3" :refY "3"
:markerWidth "8.5" :markerWidth "8.5"
:markerHeight "8.5" :markerHeight "8.5"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:path {:d "M 0.5 0.5 L 3 3 L 0.5 5.5 L 0 5 L 2 3 L 0 1 z"}]]) [:path {:d "M 0.5 0.5 L 3 3 L 0.5 5.5 L 0 5 L 2 3 L 0 1 z"}]])
(when (or (= cap-start :triangle-arrow) (when (or (= cap-start :triangle-arrow)
(= cap-end :triangle-arrow)) (= cap-end :triangle-arrow))
[:marker {:id (dm/str id-prefix "-triangle-arrow") [:marker {:id (dm/str id-prefix "-triangle-arrow")
:viewBox "0 0 3 6" :viewBox "0 0 3 6"
:refX "2" :refX "2"
:refY "3" :refY "3"
:markerWidth "8.5" :markerWidth "8.5"
:markerHeight "8.5" :markerHeight "8.5"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:path {:d "M 0 0 L 3 3 L 0 6 z"}]]) [:path {:d "M 0 0 L 3 3 L 0 6 z"}]])
(when (or (= cap-start :square-marker) (when (or (= cap-start :square-marker)
(= cap-end :square-marker)) (= cap-end :square-marker))
[:marker {:id (dm/str id-prefix "-square-marker") [:marker {:id (dm/str id-prefix "-square-marker")
:viewBox "0 0 6 6" :viewBox "0 0 6 6"
:refX "3" :refX "3"
:refY "3" :refY "3"
:markerWidth "4.2426" ;; diagonal length of a 3x3 square :markerWidth "4.2426" ;; diagonal length of a 3x3 square
:markerHeight "4.2426" :markerHeight "4.2426"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:rect {:x 0 :y 0 :width 6 :height 6}]]) [:rect {:x 0 :y 0 :width 6 :height 6}]])
(when (or (= cap-start :circle-marker) (when (or (= cap-start :circle-marker)
(= cap-end :circle-marker)) (= cap-end :circle-marker))
[:marker {:id (dm/str id-prefix "-circle-marker") [:marker {:id (dm/str id-prefix "-circle-marker")
:viewBox "0 0 6 6" :viewBox "0 0 6 6"
:refX "3" :refX "3"
:refY "3" :refY "3"
:markerWidth "4" :markerWidth "4"
:markerHeight "4" :markerHeight "4"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:circle {:cx "3" :cy "3" :r "3"}]]) [:circle {:cx "3" :cy "3" :r "3"}]])
(when (or (= cap-start :diamond-marker) (when (or (= cap-start :diamond-marker)
(= cap-end :diamond-marker)) (= cap-end :diamond-marker))
[:marker {:id (dm/str id-prefix "-diamond-marker") [:marker {:id (dm/str id-prefix "-diamond-marker")
:viewBox "0 0 6 6" :viewBox "0 0 6 6"
:refX "3" :refX "3"
:refY "3" :refY "3"
:markerWidth "6" :markerWidth "6"
:markerHeight "6" :markerHeight "6"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:path {:d "M 3 0 L 6 3 L 3 6 L 0 3 z"}]]) [:path {:d "M 3 0 L 6 3 L 3 6 L 0 3 z"}]])
;; If the user wants line caps but different in each end, ;; If the user wants line caps but different in each end,
;; simulate it with markers. ;; simulate it with markers.
(when (and (or (= cap-start :round) (when (and (or (= cap-start :round)
(= cap-end :round)) (= cap-end :round))
(not= cap-start cap-end)) (not= cap-start cap-end))
[:marker {:id (dm/str id-prefix "-round") [:marker {:id (dm/str id-prefix "-round")
:viewBox "0 0 6 6" :viewBox "0 0 6 6"
:refX "3" :refX "3"
:refY "3" :refY "3"
:markerWidth "6" :markerWidth "6"
:markerHeight "6" :markerHeight "6"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:path {:d "M 3 2.5 A 0.5 0.5 0 0 1 3 3.5 "}]]) [:path {:d "M 3 2.5 A 0.5 0.5 0 0 1 3 3.5 "}]])
(when (and (or (= cap-start :square) (when (and (or (= cap-start :square)
(= cap-end :square)) (= cap-end :square))
(not= cap-start cap-end)) (not= cap-start cap-end))
[:marker {:id (dm/str id-prefix "-square") [:marker {:id (dm/str id-prefix "-square")
:viewBox "0 0 6 6" :viewBox "0 0 6 6"
:refX "3" :refX "3"
:refY "3" :refY "3"
:markerWidth "6" :markerWidth "6"
:markerHeight "6" :markerHeight "6"
:orient "auto-start-reverse" :orient "auto-start-reverse"
:fill color :fill color
:fillOpacity opacity} :fillOpacity opacity}
[:rect {:x 3 :y 2.5 :width 0.5 :height 1}]])])) [:rect {:x 3 :y 2.5 :width 0.5 :height 1}]])]))
(mf/defc stroke-defs (mf/defc stroke-defs
{::mf/wrap-props false} {::mf/wrap-props false}
[{:keys [shape stroke render-id index]}] [{:keys [shape stroke render-id index]}]
(let [open-path? (and ^boolean (cfh/path-shape? shape) (let [open-path? (and ^boolean (cfh/path-shape? shape)
^boolean (gsh/open-path? shape)) ^boolean (gsh/open-path? shape))
gradient (:stroke-color-gradient stroke) gradient (:stroke-color-gradient stroke)
alignment (:stroke-alignment stroke :center) alignment (:stroke-alignment stroke :center)
width (:stroke-width stroke 0) width (:stroke-width stroke 0)
@ -487,11 +487,11 @@
props props
(cond-> props (cond-> props
(and (some? shape-blur) (and (some? shape-blur)
(not ^boolean (:hidden shape-blur))) (not ^boolean (:hidden shape-blur)))
(obj/set! "filter" (dm/fmt "url(#filter-blur-%)" render-id)) (obj/set! "filter" (dm/fmt "url(#filter-blur-%)" render-id))
(and (empty? shape-fills) (and (empty? shape-fills)
(some? (->> shape-shadow (remove :hidden) seq))) (some? (->> shape-shadow (remove :hidden) seq)))
(obj/set! "filter" (dm/fmt "url(#filter-%)" render-id))))] (obj/set! "filter" (dm/fmt "url(#filter-%)" render-id))))]
(when (d/not-empty? shape-strokes) (when (d/not-empty? shape-strokes)

View file

@ -38,9 +38,9 @@
(url-mapping) (url-mapping)
(rx/reduce conj {}) (rx/reduce conj {})
(rx/subs! (fn [data] (rx/subs! (fn [data]
(when-not (= data (mf/ref-val uri-data)) (when-not (= data (mf/ref-val uri-data))
(mf/set-ref-val! uri-data data) (mf/set-ref-val! uri-data data)
(reset! state inc)))))] (reset! state inc)))))]
#(when sub #(when sub
(rx/dispose! sub))))) (rx/dispose! sub)))))

View file

@ -169,10 +169,10 @@
(mf/defc export-flows (mf/defc export-flows
[{:keys [flows]}] [{:keys [flows]}]
[:> "penpot:flows" #js {} [:> "penpot:flows" #js {}
(for [{:keys [id name starting-frame]} flows] (for [{:keys [id name starting-frame]} flows]
[:> "penpot:flow" #js {:id id [:> "penpot:flow" #js {:id id
:name name :name name
:starting-frame starting-frame}])]) :starting-frame starting-frame}])])
(mf/defc export-guides (mf/defc export-guides
[{:keys [guides]}] [{:keys [guides]}]
@ -253,7 +253,7 @@
[:* [:*
(when (contains? shape :svg-attrs) (when (contains? shape :svg-attrs)
(let [svg-transform (get shape :svg-transform) (let [svg-transform (get shape :svg-transform)
svg-attrs (->> shape :svg-attrs keys (mapv d/name) (str/join ",") ) svg-attrs (->> shape :svg-attrs keys (mapv d/name) (str/join ","))
svg-defs (->> shape :svg-defs keys (mapv d/name) (str/join ","))] svg-defs (->> shape :svg-defs keys (mapv d/name) (str/join ","))]
[:> "penpot:svg-import" [:> "penpot:svg-import"
#js {:penpot:svg-attrs (when-not (empty? svg-attrs) svg-attrs) #js {:penpot:svg-attrs (when-not (empty? svg-attrs) svg-attrs)
@ -292,47 +292,47 @@
(when-let [fills (seq fills)] (when-let [fills (seq fills)]
(let [render-id (mf/use-ctx muc/render-id)] (let [render-id (mf/use-ctx muc/render-id)]
(mf/html (mf/html
[:> "penpot:fills" #js {} [:> "penpot:fills" #js {}
(for [[index fill] (d/enumerate fills)] (for [[index fill] (d/enumerate fills)]
(let [fill-image-id (dm/str "fill-image-" render-id "-" index)] (let [fill-image-id (dm/str "fill-image-" render-id "-" index)]
[:> "penpot:fill" [:> "penpot:fill"
#js {:penpot:fill-color (cond #js {:penpot:fill-color (cond
(some? (:fill-color-gradient fill)) (some? (:fill-color-gradient fill))
(str/format "url(#%s)" (str "fill-color-gradient-" render-id "-" index)) (str/format "url(#%s)" (str "fill-color-gradient-" render-id "-" index))
:else :else
(d/name (:fill-color fill))) (d/name (:fill-color fill)))
:key (swap! internal-counter inc) :key (swap! internal-counter inc)
:penpot:fill-image-id (when (:fill-image fill) fill-image-id) :penpot:fill-image-id (when (:fill-image fill) fill-image-id)
:penpot:fill-color-ref-file (d/name (:fill-color-ref-file fill)) :penpot:fill-color-ref-file (d/name (:fill-color-ref-file fill))
:penpot:fill-color-ref-id (d/name (:fill-color-ref-id fill)) :penpot:fill-color-ref-id (d/name (:fill-color-ref-id fill))
:penpot:fill-opacity (d/name (:fill-opacity fill))}]))])))) :penpot:fill-opacity (d/name (:fill-opacity fill))}]))]))))
(defn- export-strokes-data [{:keys [strokes]}] (defn- export-strokes-data [{:keys [strokes]}]
(when-let [strokes (seq strokes)] (when-let [strokes (seq strokes)]
(let [render-id (mf/use-ctx muc/render-id)] (let [render-id (mf/use-ctx muc/render-id)]
(mf/html (mf/html
[:> "penpot:strokes" #js {} [:> "penpot:strokes" #js {}
(for [[index stroke] (d/enumerate strokes)] (for [[index stroke] (d/enumerate strokes)]
(let [stroke-image-id (dm/str "stroke-image-" render-id "-" index)] (let [stroke-image-id (dm/str "stroke-image-" render-id "-" index)]
[:> "penpot:stroke" [:> "penpot:stroke"
#js {:penpot:stroke-color (cond #js {:penpot:stroke-color (cond
(some? (:stroke-color-gradient stroke)) (some? (:stroke-color-gradient stroke))
(str/format "url(#%s)" (str "stroke-color-gradient-" render-id "-" index)) (str/format "url(#%s)" (str "stroke-color-gradient-" render-id "-" index))
:else :else
(d/name (:stroke-color stroke))) (d/name (:stroke-color stroke)))
:key (swap! internal-counter inc) :key (swap! internal-counter inc)
:penpot:stroke-image-id (when (:stroke-image stroke) stroke-image-id) :penpot:stroke-image-id (when (:stroke-image stroke) stroke-image-id)
:penpot:stroke-color-ref-file (d/name (:stroke-color-ref-file stroke)) :penpot:stroke-color-ref-file (d/name (:stroke-color-ref-file stroke))
:penpot:stroke-color-ref-id (d/name (:stroke-color-ref-id stroke)) :penpot:stroke-color-ref-id (d/name (:stroke-color-ref-id stroke))
:penpot:stroke-opacity (d/name (:stroke-opacity stroke)) :penpot:stroke-opacity (d/name (:stroke-opacity stroke))
:penpot:stroke-style (d/name (:stroke-style stroke)) :penpot:stroke-style (d/name (:stroke-style stroke))
:penpot:stroke-width (d/name (:stroke-width stroke)) :penpot:stroke-width (d/name (:stroke-width stroke))
:penpot:stroke-alignment (d/name (:stroke-alignment stroke)) :penpot:stroke-alignment (d/name (:stroke-alignment stroke))
:penpot:stroke-cap-start (d/name (:stroke-cap-start stroke)) :penpot:stroke-cap-start (d/name (:stroke-cap-start stroke))
:penpot:stroke-cap-end (d/name (:stroke-cap-end stroke))}]))])))) :penpot:stroke-cap-end (d/name (:stroke-cap-end stroke))}]))]))))
(defn- export-interactions-data [{:keys [interactions]}] (defn- export-interactions-data [{:keys [interactions]}]
(when-let [interactions (seq interactions)] (when-let [interactions (seq interactions)]

View file

@ -35,7 +35,7 @@
height (dm/get-prop selrect :height) height (dm/get-prop selrect :height)
has-image? (or (some? metadata) has-image? (or (some? metadata)
(some? image)) (some? image))
uri (cond uri (cond
(some? metadata) (some? metadata)
@ -45,10 +45,10 @@
(cf/resolve-file-media image)) (cf/resolve-file-media image))
uris (into [uri] uris (into [uri]
(comp (comp
(keep :fill-image) (keep :fill-image)
(map cf/resolve-file-media)) (map cf/resolve-file-media))
fills) fills)
transform (gsh/transform-str shape) transform (gsh/transform-str shape)
@ -59,8 +59,8 @@
:height height} :height height}
pat-props (if (= :path type) pat-props (if (= :path type)
(obj/set! pat-props "patternTransform" transform) (obj/set! pat-props "patternTransform" transform)
pat-props)] pat-props)]
(for [[shape-index shape] (d/enumerate (or (:position-data shape) [shape]))] (for [[shape-index shape] (d/enumerate (or (:position-data shape) [shape]))]
[:* {:key (dm/str shape-index)} [:* {:key (dm/str shape-index)}

View file

@ -60,8 +60,8 @@
points (dm/get-prop mask :points) points (dm/get-prop mask :points)
points-str (mf/with-memo [points] points-str (mf/with-memo [points]
(->> (map point->str points) (->> (map point->str points)
(str/join " "))) (str/join " ")))
bounds (mf/with-memo [points] bounds (mf/with-memo [points]
(grc/points->rect points)) (grc/points->rect points))

View file

@ -22,9 +22,9 @@
(upf/format-path content) (upf/format-path content)
(catch :default e (catch :default e
(log/error :hint "unexpected error on formatting path" (log/error :hint "unexpected error on formatting path"
:shape-name (:name shape) :shape-name (:name shape)
:shape-id (:id shape) :shape-id (:id shape)
:cause e) :cause e)
""))) "")))
props (-> #js {} props (-> #js {}

View file

@ -59,11 +59,11 @@
(= :group type)) (= :group type))
(update :className #(if % (dm/str % " svg-def") "svg-def"))) (update :className #(if % (dm/str % " svg-def") "svg-def")))
(cond-> (cond->
transform-gradient? (add-matrix :gradientTransform transform) transform-gradient? (add-matrix :gradientTransform transform)
transform-pattern? (add-matrix :patternTransform transform) transform-pattern? (add-matrix :patternTransform transform)
transform-clippath? (add-matrix :transform transform) transform-clippath? (add-matrix :transform transform)
(or transform-filter? (or transform-filter?
transform-mask?) (merge bounds))) transform-mask?) (merge bounds)))
;; Fixes race condition with dynamic modifiers forcing redraw this properties before ;; Fixes race condition with dynamic modifiers forcing redraw this properties before
;; the effect triggers ;; the effect triggers

View file

@ -83,7 +83,7 @@
(usa/add-fill-props! shape render-id))] (usa/add-fill-props! shape render-id))]
(when (and (some? element-id) (when (and (some? element-id)
(contains? ids-mapping element-id)) (contains? ids-mapping element-id))
(obj/set! props "id" (get ids-mapping element-id))) (obj/set! props "id" (get ids-mapping element-id)))
props))] props))]

View file

@ -196,7 +196,7 @@
;; We use a class here because react has a bug that won't use the appropriate selector for ;; We use a class here because react has a bug that won't use the appropriate selector for
;; `background-clip` ;; `background-clip`
[:style ".text-node { background-clip: text; [:style ".text-node { background-clip: text;
-webkit-background-clip: text; }" ] -webkit-background-clip: text; }"]
[:& render-node {:index 0 [:& render-node {:index 0
:shape shape :shape shape
:node content}]])) :node content}]]))

View file

@ -121,7 +121,7 @@
;; `background-clip` ;; `background-clip`
(when (not code?) (when (not code?)
[:style ".text-node { background-clip: text; [:style ".text-node { background-clip: text;
-webkit-background-clip: text; }" ]) -webkit-background-clip: text; }"])
[:& render-node {:index 0 [:& render-node {:index 0
:shape shape :shape shape
:node content :node content

View file

@ -121,7 +121,7 @@
[{:keys [section index users frame page]}] [{:keys [section index users frame page]}]
(let [comments-local (mf/deref refs/comments-local) (let [comments-local (mf/deref refs/comments-local)
show-sidebar? (and (= section :comments) (:show-sidebar? comments-local))] show-sidebar? (and (= section :comments) (:show-sidebar? comments-local))]
[:* [:*
[:& viewer-pagination [:& viewer-pagination
{:index index {:index index
:num-frames (count (:frames page)) :num-frames (count (:frames page))

View file

@ -40,7 +40,7 @@
(let [mode (-> (dom/get-current-target event) (let [mode (-> (dom/get-current-target event)
(dom/get-data "value") (dom/get-data "value")
(keyword))] (keyword))]
(st/emit! (dcm/update-filters {:mode mode}))))) (st/emit! (dcm/update-filters {:mode mode})))))
update-show update-show
(mf/use-callback (mf/use-callback
@ -48,7 +48,7 @@
(let [mode (-> (dom/get-current-target event) (let [mode (-> (dom/get-current-target event)
(dom/get-data "value") (dom/get-data "value")
(d/read-string))] (d/read-string))]
(st/emit! (dcm/update-filters {:show mode}))))) (st/emit! (dcm/update-filters {:show mode})))))
update-options update-options
(mf/use-callback (mf/use-callback

View file

@ -275,13 +275,13 @@
(mf/use-fn (mf/use-fn
(mf/deps permissions) (mf/deps permissions)
(fn [event] (fn [event]
(let [section (-> (dom/get-current-target event) (let [section (-> (dom/get-current-target event)
(dom/get-data "value") (dom/get-data "value")
(keyword))] (keyword))]
(if (or (= section :interactions) (:is-logged permissions)) (if (or (= section :interactions) (:is-logged permissions))
(st/emit! (dv/go-to-section section)) (st/emit! (dv/go-to-section section))
(open-login-dialog)))))] (open-login-dialog)))))]
[:header {:class (stl/css :viewer-header)} [:header {:class (stl/css :viewer-header)}
[:div {:class (stl/css :nav-zone)} [:div {:class (stl/css :nav-zone)}

View file

@ -80,7 +80,7 @@
handle-expand handle-expand
(mf/use-callback (mf/use-callback
(mf/deps right-size) (mf/deps right-size)
(fn[] (fn []
(set-right-size (if (> right-size 276) 276 768))))] (set-right-size (if (> right-size 276) 276 768))))]
(mf/use-effect on-mount) (mf/use-effect on-mount)

View file

@ -148,7 +148,7 @@
(if (= (:type shape) :frame) ;; manual interactions are always from "self" (if (= (:type shape) :frame) ;; manual interactions are always from "self"
(:frame-id shape) (:frame-id shape)
(:id shape)) (:id shape))
(:position-relative-to interaction)) (:position-relative-to interaction))
relative-to-shape (or (get objects relative-to-id) base-frame) relative-to-shape (or (get objects relative-to-id) base-frame)
overlays-ids (set (map :id overlays)) overlays-ids (set (map :id overlays))
relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame) relative-to-base-frame (find-relative-to-base-frame relative-to-shape objects overlays-ids base-frame)
@ -278,68 +278,68 @@
"Wrap some svg shape and add interaction controls" "Wrap some svg shape and add interaction controls"
[component] [component]
(mf/fnc generic-wrapper (mf/fnc generic-wrapper
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [shape (unchecked-get props "shape") (let [shape (unchecked-get props "shape")
childs (unchecked-get props "childs") childs (unchecked-get props "childs")
frame (unchecked-get props "frame") frame (unchecked-get props "frame")
objects (unchecked-get props "objects") objects (unchecked-get props "objects")
all-objects (or (unchecked-get props "all-objects") objects) all-objects (or (unchecked-get props "all-objects") objects)
base-frame (mf/use-ctx base-frame-ctx) base-frame (mf/use-ctx base-frame-ctx)
frame-offset (mf/use-ctx frame-offset-ctx) frame-offset (mf/use-ctx frame-offset-ctx)
interactions-show? (mf/deref viewer-interactions-show?) interactions-show? (mf/deref viewer-interactions-show?)
overlays (mf/deref refs/viewer-overlays) overlays (mf/deref refs/viewer-overlays)
interactions (:interactions shape) interactions (:interactions shape)
svg-element? (and (= :svg-raw (:type shape)) svg-element? (and (= :svg-raw (:type shape))
(not= :svg (get-in shape [:content :tag]))) (not= :svg (get-in shape [:content :tag])))
;; The objects parameter has the shapes that we must draw. It may be a subset of ;; The objects parameter has the shapes that we must draw. It may be a subset of
;; all-objects in some cases (e.g. if there are fixed elements). But for interactions ;; all-objects in some cases (e.g. if there are fixed elements). But for interactions
;; handling we need access to all objects inside the page. ;; handling we need access to all objects inside the page.
on-pointer-down on-pointer-down
(mf/use-fn (mf/deps shape base-frame frame-offset all-objects) (mf/use-fn (mf/deps shape base-frame frame-offset all-objects)
#(on-pointer-down % shape base-frame frame-offset all-objects overlays)) #(on-pointer-down % shape base-frame frame-offset all-objects overlays))
on-pointer-up on-pointer-up
(mf/use-fn (mf/deps shape base-frame frame-offset all-objects) (mf/use-fn (mf/deps shape base-frame frame-offset all-objects)
#(on-pointer-up % shape base-frame frame-offset all-objects overlays)) #(on-pointer-up % shape base-frame frame-offset all-objects overlays))
on-pointer-enter on-pointer-enter
(mf/use-fn (mf/deps shape base-frame frame-offset all-objects) (mf/use-fn (mf/deps shape base-frame frame-offset all-objects)
#(on-pointer-enter % shape base-frame frame-offset all-objects overlays)) #(on-pointer-enter % shape base-frame frame-offset all-objects overlays))
on-pointer-leave on-pointer-leave
(mf/use-fn (mf/deps shape base-frame frame-offset all-objects) (mf/use-fn (mf/deps shape base-frame frame-offset all-objects)
#(on-pointer-leave % shape base-frame frame-offset all-objects overlays))] #(on-pointer-leave % shape base-frame frame-offset all-objects overlays))]
(mf/with-effect [] (mf/with-effect []
(let [sems (on-load shape base-frame frame-offset objects overlays)] (let [sems (on-load shape base-frame frame-offset objects overlays)]
(partial run! tm/dispose! sems))) (partial run! tm/dispose! sems)))
(if-not svg-element? (if-not svg-element?
[:> shape-container {:shape shape [:> shape-container {:shape shape
:cursor (when (ctsi/actionable? interactions) "pointer") :cursor (when (ctsi/actionable? interactions) "pointer")
:on-pointer-down on-pointer-down :on-pointer-down on-pointer-down
:on-pointer-up on-pointer-up :on-pointer-up on-pointer-up
:on-pointer-enter on-pointer-enter :on-pointer-enter on-pointer-enter
:on-pointer-leave on-pointer-leave} :on-pointer-leave on-pointer-leave}
[:& component {:shape shape [:& component {:shape shape
:frame frame :frame frame
:childs childs :childs childs
:is-child-selected? true :is-child-selected? true
:objects objects}] :objects objects}]
[:& interaction {:shape shape [:& interaction {:shape shape
:interactions interactions :interactions interactions
:interactions-show? interactions-show?}]] :interactions-show? interactions-show?}]]
;; Don't wrap svg elements inside a <g> otherwise some can break ;; Don't wrap svg elements inside a <g> otherwise some can break
[:& component {:shape shape [:& component {:shape shape
:frame frame :frame frame
:childs childs :childs childs
:objects objects}])))) :objects objects}]))))
(defn frame-wrapper (defn frame-wrapper
[shape-container] [shape-container]
@ -400,41 +400,41 @@
(let [shape-container (shape-container-factory objects all-objects) (let [shape-container (shape-container-factory objects all-objects)
group-wrapper (group-wrapper shape-container)] group-wrapper (group-wrapper shape-container)]
(mf/fnc group-container (mf/fnc group-container
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape")))
props (obj/merge! #js {} props props (obj/merge! #js {} props
#js {:childs childs #js {:childs childs
:objects objects})] :objects objects})]
(when (not-empty childs) (when (not-empty childs)
[:> group-wrapper props]))))) [:> group-wrapper props])))))
(defn bool-container-factory (defn bool-container-factory
[objects all-objects] [objects all-objects]
(let [shape-container (shape-container-factory objects all-objects) (let [shape-container (shape-container-factory objects all-objects)
bool-wrapper (bool-wrapper shape-container)] bool-wrapper (bool-wrapper shape-container)]
(mf/fnc bool-container (mf/fnc bool-container
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [childs (->> (cfh/get-children-ids objects (:id (unchecked-get props "shape"))) (let [childs (->> (cfh/get-children-ids objects (:id (unchecked-get props "shape")))
(select-keys objects)) (select-keys objects))
props (obj/merge! #js {} props props (obj/merge! #js {} props
#js {:childs childs #js {:childs childs
:objects objects})] :objects objects})]
[:> bool-wrapper props])))) [:> bool-wrapper props]))))
(defn svg-raw-container-factory (defn svg-raw-container-factory
[objects all-objects] [objects all-objects]
(let [shape-container (shape-container-factory objects all-objects) (let [shape-container (shape-container-factory objects all-objects)
svg-raw-wrapper (svg-raw-wrapper shape-container)] svg-raw-wrapper (svg-raw-wrapper shape-container)]
(mf/fnc svg-raw-container (mf/fnc svg-raw-container
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape")))
props (obj/merge! #js {} props props (obj/merge! #js {} props
#js {:childs childs #js {:childs childs
:objects objects})] :objects objects})]
[:> svg-raw-wrapper props])))) [:> svg-raw-wrapper props]))))
(defn shape-container-factory (defn shape-container-factory
[objects all-objects] [objects all-objects]
@ -444,28 +444,28 @@
image-wrapper (image-wrapper) image-wrapper (image-wrapper)
circle-wrapper (circle-wrapper)] circle-wrapper (circle-wrapper)]
(mf/fnc shape-container (mf/fnc shape-container
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[props] [props]
(let [shape (unchecked-get props "shape") (let [shape (unchecked-get props "shape")
frame (unchecked-get props "frame") frame (unchecked-get props "frame")
group-container group-container
(mf/with-memo [objects] (mf/with-memo [objects]
(group-container-factory objects all-objects)) (group-container-factory objects all-objects))
frame-container frame-container
(mf/with-memo [objects] (mf/with-memo [objects]
(frame-container-factory objects all-objects)) (frame-container-factory objects all-objects))
bool-container bool-container
(mf/with-memo [objects] (mf/with-memo [objects]
(bool-container-factory objects all-objects)) (bool-container-factory objects all-objects))
svg-raw-container svg-raw-container
(mf/with-memo [objects] (mf/with-memo [objects]
(svg-raw-container-factory objects all-objects))] (svg-raw-container-factory objects all-objects))]
(when (and shape (not (:hidden shape))) (when (and shape (not (:hidden shape)))
(let [shape (if frame (let [shape (if frame
(gsh/translate-to-frame shape frame) (gsh/translate-to-frame shape frame)
shape) shape)
@ -473,13 +473,13 @@
opts #js {:shape shape opts #js {:shape shape
:objects objects :objects objects
:all-objects all-objects}] :all-objects all-objects}]
(case (:type shape) (case (:type shape)
:frame [:> frame-container opts] :frame [:> frame-container opts]
:text [:> text-wrapper opts] :text [:> text-wrapper opts]
:rect [:> rect-wrapper opts] :rect [:> rect-wrapper opts]
:path [:> path-wrapper opts] :path [:> path-wrapper opts]
:image [:> image-wrapper opts] :image [:> image-wrapper opts]
:circle [:> circle-wrapper opts] :circle [:> circle-wrapper opts]
:group [:> group-container {:shape shape :frame frame :objects objects}] :group [:> group-container {:shape shape :frame frame :objects objects}]
:bool [:> bool-container {:shape shape :frame frame :objects objects}] :bool [:> bool-container {:shape shape :frame frame :objects objects}]
:svg-raw [:> svg-raw-container {:shape shape :frame frame :objects objects}]))))))) :svg-raw [:> svg-raw-container {:shape shape :frame frame :objects objects}])))))))

View file

@ -26,8 +26,8 @@
(letfn [(select-color [event] (letfn [(select-color [event]
(st/emit! (mdc/apply-color-from-palette color (kbd/alt? event))))] (st/emit! (mdc/apply-color-from-palette color (kbd/alt? event))))]
[:div {:class (stl/css-case :color-cell true [:div {:class (stl/css-case :color-cell true
:is-not-library-color (nil? (:id color)) :is-not-library-color (nil? (:id color))
:no-text (<= size 64)) :no-text (<= size 64))
:title (uc/get-color-name color) :title (uc/get-color-name color)
:on-click select-color} :on-click select-color}
[:& cb/color-bullet {:color color}] [:& cb/color-bullet {:color color}]

View file

@ -57,7 +57,7 @@
[:div {:class (stl/css :lib-name-wrapper)} [:div {:class (stl/css :lib-name-wrapper)}
[:span {:class (stl/css :lib-name)} [:span {:class (stl/css :lib-name)}
(dm/str (tr "workspace.libraries.colors.file-library"))] (dm/str (tr "workspace.libraries.colors.file-library"))]
[:span {:class (stl/css :lib-num)} [:span {:class (stl/css :lib-num)}
(dm/str "(" (count file-colors) ")")]] (dm/str "(" (count file-colors) ")")]]
@ -81,7 +81,7 @@
[:span {:class (stl/css :lib-name)} [:span {:class (stl/css :lib-name)}
(dm/str (tr "workspace.libraries.colors.recent-colors"))] (dm/str (tr "workspace.libraries.colors.recent-colors"))]
[:span {:class (stl/css :lib-num)} [:span {:class (stl/css :lib-num)}
(dm/str "("(count recent-colors) ")")]] (dm/str "(" (count recent-colors) ")")]]
(when (= selected :recent) (when (= selected :recent)
[:span {:class (stl/css :icon-wrapper)} [:span {:class (stl/css :icon-wrapper)}

View file

@ -78,21 +78,21 @@
selected-mode (get state :type :color) selected-mode (get state :type :color)
disabled-color-accept? (and disabled-color-accept? (and
(= selected-mode :image) (= selected-mode :image)
(not (:image current-color))) (not (:image current-color)))
on-fill-image-success on-fill-image-success
(mf/use-fn (mf/use-fn
(fn [image] (fn [image]
(st/emit! (dc/update-colorpicker-color {:image (select-keys image [:id :width :height :mtype :name])} (not @drag?))))) (st/emit! (dc/update-colorpicker-color {:image (select-keys image [:id :width :height :mtype :name])} (not @drag?)))))
on-fill-image-click on-fill-image-click
(mf/use-callback #(dom/click (mf/ref-val fill-image-ref))) (mf/use-callback #(dom/click (mf/ref-val fill-image-ref)))
on-fill-image-selected on-fill-image-selected
(mf/use-fn (mf/use-fn
(fn [file] (fn [file]
(st/emit! (dwm/upload-fill-image file on-fill-image-success)))) (st/emit! (dwm/upload-fill-image file on-fill-image-success))))
set-tab! set-tab!
(mf/use-fn (mf/use-fn
@ -218,7 +218,7 @@
options options
(mf/with-memo [selected-mode disable-gradient disable-image] (mf/with-memo [selected-mode disable-gradient disable-image]
(d/concat-vec (d/concat-vec
[{:value :color :label (tr "media.solid")}] [{:value :color :label (tr "media.solid")}]
(when (not disable-gradient) (when (not disable-gradient)
[{:value :linear-gradient :label (tr "media.linear")} [{:value :linear-gradient :label (tr "media.linear")}

View file

@ -58,7 +58,7 @@
(-> (dw/toggle-layout-flag :colorpalette) (-> (dw/toggle-layout-flag :colorpalette)
(vary-meta assoc ::ev/origin "workspace-colorpicker")))))) (vary-meta assoc ::ev/origin "workspace-colorpicker"))))))
shared-libs-options (mapv (fn[lib] {:value (d/name (:id lib)) :label (:name lib)} ) (vals shared-libs)) shared-libs-options (mapv (fn [lib] {:value (d/name (:id lib)) :label (:name lib)}) (vals shared-libs))
library-options [{:value "recent" :label (tr "workspace.libraries.colors.recent-colors")} library-options [{:value "recent" :label (tr "workspace.libraries.colors.recent-colors")}
@ -69,7 +69,7 @@
on-color-click on-color-click
(mf/use-fn (mf/use-fn
(mf/deps state) (mf/deps state)
(fn[event] (fn [event]
(on-select-color state event)))] (on-select-color state event)))]
;; Load library colors when the select is changed ;; Load library colors when the select is changed

View file

@ -555,7 +555,7 @@
(mf/deps grid-id type index) (mf/deps grid-id type index)
(fn [] (fn []
(st/emit! (dwsl/remove-layout-track [grid-id] type index {:with-shapes? true}))))] (st/emit! (dwsl/remove-layout-track [grid-id] type index {:with-shapes? true}))))]
(if (= type :column) (if (= type :column)
[:* [:*
[:& menu-entry {:title (tr "workspace.context-menu.grid-track.column.duplicate") :on-click do-duplicate-track}] [:& menu-entry {:title (tr "workspace.context-menu.grid-track.column.duplicate") :on-click do-duplicate-track}]

View file

@ -42,8 +42,8 @@
(refs/children-objects shape-id)) (refs/children-objects shape-id))
childs (mf/deref childs-ref)] childs (mf/deref childs-ref)]
[:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)} [:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)}
[:& frame-shape {:shape shape :childs childs}]])))) [:& frame-shape {:shape shape :childs childs}]]))))
(defn check-props (defn check-props
[new-props old-props] [new-props old-props]

View file

@ -311,6 +311,4 @@
(reset! prev-modifiers modifiers) (reset! prev-modifiers modifiers)
(reset! prev-transforms transforms) (reset! prev-transforms transforms)
(reset! prev-shapes shapes)) (reset! prev-shapes shapes))))
))

View file

@ -308,7 +308,7 @@
;; edited ;; edited
(mf/use-effect (mf/use-effect
(fn [] (fn []
(let [text-nodes (->> text-shapes (vals)(mapcat #(txt/node-seq txt/is-text-node? (:content %)))) (let [text-nodes (->> text-shapes (vals) (mapcat #(txt/node-seq txt/is-text-node? (:content %))))
fonts (into #{} (keep :font-id) text-nodes)] fonts (into #{} (keep :font-id) text-nodes)]
(run! fonts/ensure-loaded! fonts)))) (run! fonts/ensure-loaded! fonts))))

View file

@ -111,7 +111,7 @@
(mf/defc right-sidebar (mf/defc right-sidebar
{::mf/wrap-props false {::mf/wrap-props false
::mf/wrap [mf/memo]} ::mf/wrap [mf/memo]}
[{:keys [layout section file page-id ] :as props}] [{:keys [layout section file page-id] :as props}]
(let [drawing-tool (:tool (mf/deref refs/workspace-drawing)) (let [drawing-tool (:tool (mf/deref refs/workspace-drawing))
is-comments? (= drawing-tool :comments) is-comments? (= drawing-tool :comments)

View file

@ -127,31 +127,31 @@
(mf/use-fn #(swap! filters* assoc :open-menu false)) (mf/use-fn #(swap! filters* assoc :open-menu false))
options (into [] (remove nil? options (into [] (remove nil?
[{:option-name (tr "workspace.assets.box-filter-all") [{:option-name (tr "workspace.assets.box-filter-all")
:id "section-all" :id "section-all"
:option-handler on-section-filter-change :option-handler on-section-filter-change
:data-test "all"} :data-test "all"}
{:option-name (tr "workspace.assets.components") {:option-name (tr "workspace.assets.components")
:id "section-components" :id "section-components"
:option-handler on-section-filter-change :option-handler on-section-filter-change
:data-test "components"} :data-test "components"}
(when (not components-v2) (when (not components-v2)
{:option-name (tr "workspace.assets.graphics") {:option-name (tr "workspace.assets.graphics")
:id "section-graphics" :id "section-graphics"
:option-handler on-section-filter-change :option-handler on-section-filter-change
:data-test "graphics"}) :data-test "graphics"})
{:option-name (tr "workspace.assets.colors") {:option-name (tr "workspace.assets.colors")
:id "section-color" :id "section-color"
:option-handler on-section-filter-change :option-handler on-section-filter-change
:data-test "colors"} :data-test "colors"}
{:option-name (tr "workspace.assets.typography") {:option-name (tr "workspace.assets.typography")
:id "section-typography" :id "section-typography"
:option-handler on-section-filter-change :option-handler on-section-filter-change
:data-test "typographies"}]))] :data-test "typographies"}]))]
[:div {:class (stl/css :assets-bar)} [:div {:class (stl/css :assets-bar)}
[:div {:class (stl/css :assets-header)} [:div {:class (stl/css :assets-header)}

View file

@ -59,10 +59,10 @@
;; NOTE: We don't schedule the thumbnail generation on idle right now ;; NOTE: We don't schedule the thumbnail generation on idle right now
;; until we can queue and handle thumbnail batching properly. ;; until we can queue and handle thumbnail batching properly.
#_(mf/with-effect [] #_(mf/with-effect []
(when-not (some? thumbnail-uri) (when-not (some? thumbnail-uri)
(tm/schedule-on-idle (tm/schedule-on-idle
#(st/emit! (dwl/update-component-thumbnail (:id component) file-id))))) #(st/emit! (dwl/update-component-thumbnail (:id component) file-id)))))
(mf/defc components-item (mf/defc components-item

View file

@ -387,71 +387,71 @@
(partial on-asset-click groups))] (partial on-asset-click groups))]
(mf/use-effect (mf/use-effect
(mf/deps local-data ) (mf/deps local-data)
(fn [] (fn []
(when (:edit-typography local-data) (when (:edit-typography local-data)
(st/emit! #(update % :workspace-global dissoc :edit-typography))))) (st/emit! #(update % :workspace-global dissoc :edit-typography)))))
[:* [:*
[:& cmm/asset-section {:file-id file-id [:& cmm/asset-section {:file-id file-id
:title (tr "workspace.assets.typography") :title (tr "workspace.assets.typography")
:section :typographies :section :typographies
:assets-count (count typographies) :assets-count (count typographies)
:open? open?} :open? open?}
(when local? (when local?
[:& cmm/asset-section-block {:role :title-button} [:& cmm/asset-section-block {:role :title-button}
(when-not read-only? (when-not read-only?
[:button {:class (stl/css :assets-btn) [:button {:class (stl/css :assets-btn)
:on-click add-typography} :on-click add-typography}
i/add-refactor])]) i/add-refactor])])
[:& cmm/asset-section-block {:role :content} [:& cmm/asset-section-block {:role :content}
[:& typographies-group {:file-id file-id [:& typographies-group {:file-id file-id
:prefix "" :prefix ""
:groups groups :groups groups
:open-groups open-groups :open-groups open-groups
:force-open? force-open? :force-open? force-open?
:state state :state state
:file file :file file
:local? local? :local? local?
:selected selected :selected selected
:editing-id editing-id :editing-id editing-id
:renaming-id renaming-id :renaming-id renaming-id
:local-data local-data :local-data local-data
:on-asset-click on-asset-click :on-asset-click on-asset-click
:handle-change handle-change :handle-change handle-change
:apply-typography apply-typography :apply-typography apply-typography
:on-rename-group on-rename-group :on-rename-group on-rename-group
:on-ungroup on-ungroup :on-ungroup on-ungroup
:on-context-menu on-context-menu :on-context-menu on-context-menu
:selected-full selected-full}] :selected-full selected-full}]
(if local? (if local?
[:& cmm/assets-context-menu [:& cmm/assets-context-menu
{:on-close on-close-menu {:on-close on-close-menu
:state @menu-state :state @menu-state
:options [(when-not (or multi-typographies? multi-assets?) :options [(when-not (or multi-typographies? multi-assets?)
{:option-name (tr "workspace.assets.rename") {:option-name (tr "workspace.assets.rename")
:id "assets-rename-typography" :id "assets-rename-typography"
:option-handler handle-rename-typography-clicked}) :option-handler handle-rename-typography-clicked})
(when-not (or multi-typographies? multi-assets?) (when-not (or multi-typographies? multi-assets?)
{:option-name (tr "workspace.assets.edit") {:option-name (tr "workspace.assets.edit")
:id "assets-edit-typography" :id "assets-edit-typography"
:option-handler handle-edit-typography-clicked}) :option-handler handle-edit-typography-clicked})
{:option-name (tr "workspace.assets.delete") {:option-name (tr "workspace.assets.delete")
:id "assets-delete-typography" :id "assets-delete-typography"
:option-handler handle-delete-typography} :option-handler handle-delete-typography}
(when-not multi-assets? (when-not multi-assets?
{:option-name (tr "workspace.assets.group") {:option-name (tr "workspace.assets.group")
:id "assets-group-typography" :id "assets-group-typography"
:option-handler on-group})]}] :option-handler on-group})]}]
[:& cmm/assets-context-menu [:& cmm/assets-context-menu
{:on-close on-close-menu {:on-close on-close-menu
:state @menu-state :state @menu-state
:options [{:option-name "show info" :options [{:option-name "show info"
:id "assets-rename-typography" :id "assets-rename-typography"
:option-handler handle-edit-typography-clicked}]}])]]])) :option-handler handle-edit-typography-clicked}]}])]]]))

View file

@ -260,27 +260,27 @@
(let [{entries :items} (mf/deref workspace-undo) (let [{entries :items} (mf/deref workspace-undo)
objects (mf/deref refs/workspace-page-objects)] objects (mf/deref refs/workspace-page-objects)]
[:div {:class (stl/css :history-entry-detail)} [:div {:class (stl/css :history-entry-detail)}
(case (:operation entry) (case (:operation entry)
:new :new
(:name (get-object (:detail entry) entries objects)) (:name (get-object (:detail entry) entries objects))
:delete :delete
[:ul {:class (stl/css :history-entry-details-list)} [:ul {:class (stl/css :history-entry-details-list)}
(for [id (:detail entry)] (for [id (:detail entry)]
(let [shape-name (:name (get-object id entries objects))] (let [shape-name (:name (get-object id entries objects))]
[:li {:key id} shape-name]))] [:li {:key id} shape-name]))]
:modify :modify
[:ul {:class (stl/css :history-entry-details-list)} [:ul {:class (stl/css :history-entry-details-list)}
(for [[id attributes] (:detail entry)] (for [[id attributes] (:detail entry)]
(let [shape-name (:name (get-object id entries objects))] (let [shape-name (:name (get-object id entries objects))]
[:li {:key id} [:li {:key id}
[:div shape-name] [:div shape-name]
[:div (str/join ", " attributes)]]))] [:div (str/join ", " attributes)]]))]
nil)])) nil)]))
(mf/defc history-entry [{:keys [locale entry idx-entry disabled? current?]}] (mf/defc history-entry [{:keys [locale entry idx-entry disabled? current?]}]
(let [hover? (mf/use-state false) (let [hover? (mf/use-state false)

View file

@ -317,78 +317,78 @@
(fn [style] (fn [style]
(swap! filters* assoc :listing-thumbs? (= style "grid"))))] (swap! filters* assoc :listing-thumbs? (= style "grid"))))]
[:div {:class (stl/css :component-swap)} [:div {:class (stl/css :component-swap)}
[:div {:class (stl/css :element-set-title)} [:div {:class (stl/css :element-set-title)}
[:span (tr "workspace.options.component.swap")]] [:span (tr "workspace.options.component.swap")]]
[:div {:class (stl/css :component-swap-content)} [:div {:class (stl/css :component-swap-content)}
[:div {:class (stl/css :search-field)} [:div {:class (stl/css :search-field)}
[:& search-bar {:on-change on-search-term-change [:& search-bar {:on-change on-search-term-change
:clear-action on-search-clear-click :clear-action on-search-clear-click
:value (:term filters) :value (:term filters)
:placeholder (str (tr "labels.search") " " (get-in libraries [current-library-id :name])) :placeholder (str (tr "labels.search") " " (get-in libraries [current-library-id :name]))
:icon (mf/html [:span {:class (stl/css :search-icon)} i/search-refactor])}]] :icon (mf/html [:span {:class (stl/css :search-icon)} i/search-refactor])}]]
[:div {:class (stl/css :select-field)} [:div {:class (stl/css :select-field)}
[:& select [:& select
{:class (stl/css :select-library) {:class (stl/css :select-library)
:default-value current-library-id :default-value current-library-id
:options libraries-options :options libraries-options
:on-change on-library-change}]] :on-change on-library-change}]]
[:div {:class (stl/css :library-name)} current-library-name] [:div {:class (stl/css :library-name)} current-library-name]
[:div {:class (stl/css :listing-options-wrapper)} [:div {:class (stl/css :listing-options-wrapper)}
[:& radio-buttons {:class (stl/css :listing-options) [:& radio-buttons {:class (stl/css :listing-options)
:selected (if (:listing-thumbs? filters) "grid" "list") :selected (if (:listing-thumbs? filters) "grid" "list")
:on-change toggle-list-style :on-change toggle-list-style
:name "swap-listing-style"} :name "swap-listing-style"}
[:& radio-button {:icon i/view-as-list-refactor [:& radio-button {:icon i/view-as-list-refactor
:icon-class (stl/css :radio-button) :icon-class (stl/css :radio-button)
:value "list" :value "list"
:id "swap-opt-list"}] :id "swap-opt-list"}]
[:& radio-button {:icon i/flex-grid-refactor [:& radio-button {:icon i/flex-grid-refactor
:icon-class (stl/css :radio-button) :icon-class (stl/css :radio-button)
:value "grid" :value "grid"
:id "swap-opt-grid"}]]] :id "swap-opt-grid"}]]]
(if (or is-search? (str/empty? (:path filters))) (if (or is-search? (str/empty? (:path filters)))
[:div {:class (stl/css :component-path-empty)}] [:div {:class (stl/css :component-path-empty)}]
[:button {:class (stl/css :component-path) [:button {:class (stl/css :component-path)
:on-click on-go-back :on-click on-go-back
:title (:path filters)} :title (:path filters)}
[:span i/arrow-slide] [:span i/arrow-slide]
[:span (:path filters)]]) [:span (:path filters)]])
(when (empty? items) (when (empty? items)
[:div {:class (stl/css :component-list-empty)} [:div {:class (stl/css :component-list-empty)}
(tr "workspace.options.component.swap.empty")]) (tr "workspace.options.component.swap.empty")])
(when (:listing-thumbs? filters) (when (:listing-thumbs? filters)
[:div {:class (stl/css :component-list)} [:div {:class (stl/css :component-list)}
(for [item groups] (for [item groups]
[:& component-group-item {:item item :on-enter-group on-enter-group}])]) [:& component-group-item {:item item :on-enter-group on-enter-group}])])
[:div {:class (stl/css-case :component-grid (:listing-thumbs? filters) [:div {:class (stl/css-case :component-grid (:listing-thumbs? filters)
:component-list (not (:listing-thumbs? filters)))} :component-list (not (:listing-thumbs? filters)))}
(for [item items] (for [item items]
(if (:id item) (if (:id item)
(let [data (get-in libraries [current-library-id :data]) (let [data (get-in libraries [current-library-id :data])
container (ctf/get-component-page data item) container (ctf/get-component-page data item)
root-shape (ctf/get-component-root data item) root-shape (ctf/get-component-root data item)
loop? (or (contains? parent-components (:main-instance-id item)) loop? (or (contains? parent-components (:main-instance-id item))
(contains? parent-components (:id item)))] (contains? parent-components (:id item)))]
[:& component-swap-item {:key (:id item) [:& component-swap-item {:key (:id item)
:item item :item item
:loop loop? :loop loop?
:shapes shapes :shapes shapes
:file-id current-library-id :file-id current-library-id
:root-shape root-shape :root-shape root-shape
:container container :container container
:component-id current-comp-id :component-id current-comp-id
:is-search is-search? :is-search is-search?
:listing-thumbs (:listing-thumbs? filters)}]) :listing-thumbs (:listing-thumbs? filters)}])
[:& component-group-item {:item item :on-enter-group on-enter-group}]))]]])) [:& component-group-item {:item item :on-enter-group on-enter-group}]))]]]))
(mf/defc component-ctx-menu (mf/defc component-ctx-menu
[{:keys [menu-entries on-close show] :as props}] [{:keys [menu-entries on-close show] :as props}]
@ -397,14 +397,14 @@
(dom/stop-propagation event) (dom/stop-propagation event)
(action) (action)
(on-close))] (on-close))]
[:& dropdown {:show show :on-close on-close} [:& dropdown {:show show :on-close on-close}
[:ul {:class (stl/css :custom-select-dropdown)} [:ul {:class (stl/css :custom-select-dropdown)}
(for [entry menu-entries :when (not (nil? entry))] (for [entry menu-entries :when (not (nil? entry))]
[:li {:key (uuid/next) [:li {:key (uuid/next)
:class (stl/css :dropdown-element) :class (stl/css :dropdown-element)
:on-click (partial do-action (:action entry))} :on-click (partial do-action (:action entry))}
[:span {:class (stl/css :dropdown-label)} [:span {:class (stl/css :dropdown-label)}
(tr (:msg entry))]])]])) (tr (:msg entry))]])]]))
(mf/defc component-menu (mf/defc component-menu
[{:keys [shapes swap-opened?] :as props}] [{:keys [shapes swap-opened?] :as props}]

View file

@ -74,7 +74,7 @@
(st/emit! (dc/add-fill ids {:color default-color (st/emit! (dc/add-fill ids {:color default-color
:opacity 1})) :opacity 1}))
(when (not (some? (seq fills))) (open-content)))) (when (not (some? (seq fills))) (open-content))))
on-change on-change
(mf/use-fn (mf/use-fn

View file

@ -46,28 +46,28 @@
(set-alignment (-> value keyword))))] (set-alignment (-> value keyword))))]
[:div {:class (stl/css :self-align-menu)} [:div {:class (stl/css :self-align-menu)}
[:& radio-buttons {:selected (d/name alignment) [:& radio-buttons {:selected (d/name alignment)
:on-change handle-set-alignment :on-change handle-set-alignment
:name (dm/str "flex-align-items-" type)} :name (dm/str "flex-align-items-" type)}
[:& radio-button {:value "start" [:& radio-button {:value "start"
:icon (if is-col? i/align-self-row-left-refactor i/align-self-column-top-refactor) :icon (if is-col? i/align-self-row-left-refactor i/align-self-column-top-refactor)
:title "Align self start" :title "Align self start"
:id (dm/str "align-self-start-" type)}] :id (dm/str "align-self-start-" type)}]
[:& radio-button {:value "center" [:& radio-button {:value "center"
:icon (if is-col? i/align-self-row-center-refactor i/align-self-column-center-refactor) :icon (if is-col? i/align-self-row-center-refactor i/align-self-column-center-refactor)
:title "Align self center" :title "Align self center"
:id (dm/str "align-self-center-" type)}] :id (dm/str "align-self-center-" type)}]
[:& radio-button {:value "end" [:& radio-button {:value "end"
:icon (if is-col? i/align-self-row-right-refactor i/align-self-column-bottom-refactor) :icon (if is-col? i/align-self-row-right-refactor i/align-self-column-bottom-refactor)
:title "Align self end" :title "Align self end"
:id (dm/str "align-self-end-" type)}] :id (dm/str "align-self-end-" type)}]
[:& radio-button {:value "stretch" [:& radio-button {:value "stretch"
:icon (if is-col? i/align-self-row-strech i/align-self-column-strech) :icon (if is-col? i/align-self-row-strech i/align-self-column-strech)
:title "Align self stretch" :title "Align self stretch"
:id (dm/str "align-self-stretch-" type)}]]])) :id (dm/str "align-self-stretch-" type)}]]]))
(mf/defc options (mf/defc options

Some files were not shown because too many files have changed in this diff Show more