diff --git a/.cljfmt.edn b/.cljfmt.edn index ffa047b2c..38cfeb89b 100644 --- a/.cljfmt.edn +++ b/.cljfmt.edn @@ -3,6 +3,7 @@ :remove-surrounding-whitespace? true :remove-consecutive-blank-lines? false :extra-indents {rumext.v2/fnc [[:inner 0]] + cljs.test/async [[:inner 0]] promesa.exec/thread [[:inner 0]] specify! [[:inner 0] [:inner 1]]} } diff --git a/frontend/src/app/libs/file_builder.cljs b/frontend/src/app/libs/file_builder.cljs index a1605bfdd..4d3b21adc 100644 --- a/frontend/src/app/libs/file_builder.cljs +++ b/frontend/src/app/libs/file_builder.cljs @@ -133,8 +133,8 @@ (rx/reduce conj []) (rx/with-latest-from files-stream) (rx/merge-map (fn [[data _]] - (->> (uz/compress-files data) - (rx/map #(vector file %))))))))) + (->> (uz/compress-files data) + (rx/map #(vector file %))))))))) (deftype File [^:mutable file] Object @@ -263,4 +263,4 @@ (File. (fb/create-file name))) (defn exports [] - #js { :createFile create-file-export }) + #js {:createFile create-file-export}) diff --git a/frontend/src/app/libs/render.cljs b/frontend/src/app/libs/render.cljs index 9021bb810..26e6cfe5d 100644 --- a/frontend/src/app/libs/render.cljs +++ b/frontend/src/app/libs/render.cljs @@ -22,7 +22,7 @@ (fn [resolve reject] (->> (r/render-page data) (rx/take 1) - (rx/subs! resolve reject))) ))) + (rx/subs! resolve reject)))))) (defn exports [] #js {:renderPage render-page-export}) diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index 273aeaf2f..ce8e1bd6d 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -171,14 +171,14 @@ ptk/WatchEvent (watch [_ state _] - (let [share-id (-> state :viewer-local :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}] - (if (and (= type :restriction) - (= code :max-quote-reached)) - (rx/throw cause) - (rx/throw {:type :comment-error})))) - (rx/ignore)))))) + (let [share-id (-> state :viewer-local :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}] + (if (and (= type :restriction) + (= code :max-quote-reached)) + (rx/throw cause) + (rx/throw {:type :comment-error})))) + (rx/ignore)))))) (defn add-comment [thread content] @@ -196,16 +196,16 @@ (ptk/reify ::create-comment ptk/WatchEvent (watch [_ state _] - (let [share-id (-> state :viewer-local :share-id)] - (rx/concat - (->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id}) - (rx/map #(partial created %)) - (rx/catch (fn [{:keys [type code] :as cause}] - (if (and (= type :restriction) - (= code :max-quote-reached)) - (rx/throw cause) - (rx/throw {:type :comment-error}))))) - (rx/of (refresh-comment-thread thread)))))))) + (let [share-id (-> state :viewer-local :share-id)] + (rx/concat + (->> (rp/cmd! :create-comment {:thread-id (:id thread) :content content :share-id share-id}) + (rx/map #(partial created %)) + (rx/catch (fn [{:keys [type code] :as cause}] + (if (and (= type :restriction) + (= code :max-quote-reached)) + (rx/throw cause) + (rx/throw {:type :comment-error}))))) + (rx/of (refresh-comment-thread thread)))))))) (defn update-comment [{:keys [id content thread-id] :as comment}] @@ -309,14 +309,14 @@ (-> (assoc-in (conj path :position) (:position comment-thread)) (assoc-in (conj path :frame-id) (:frame-id comment-thread)))))) - (fetched [[users comments] state] - (let [pages (-> (get-in state [:workspace-data :pages]) - set) - comments (filter #(contains? pages (:page-id %)) comments) - state (-> state - (assoc :comment-threads (d/index-by :id comments)) - (update :current-file-comments-users merge (d/index-by :id users)))] - (reduce set-comment-threds state comments)))] + (fetched [[users comments] state] + (let [pages (-> (get-in state [:workspace-data :pages]) + set) + comments (filter #(contains? pages (:page-id %)) comments) + state (-> state + (assoc :comment-threads (d/index-by :id comments)) + (update :current-file-comments-users merge (d/index-by :id users)))] + (reduce set-comment-threds state comments)))] (ptk/reify ::retrieve-comment-threads ptk/WatchEvent @@ -491,23 +491,23 @@ ([thread] (update-comment-thread-frame thread uuid/zero)) - ([thread frame-id] - (dm/assert! - "expected valid comment thread" - (check-comment-thread! thread)) + ([thread frame-id] + (dm/assert! + "expected valid comment thread" + (check-comment-thread! thread)) - (ptk/reify ::update-comment-thread-frame - ptk/UpdateEvent - (update [_ state] - (let [thread-id (:id thread)] - (assoc-in state [:comment-threads thread-id :frame-id] frame-id))) + (ptk/reify ::update-comment-thread-frame + ptk/UpdateEvent + (update [_ state] + (let [thread-id (:id thread)] + (assoc-in state [:comment-threads thread-id :frame-id] frame-id))) - ptk/WatchEvent - (watch [_ _ _] - (let [thread-id (:id thread)] - (->> (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/ignore))))))) + ptk/WatchEvent + (watch [_ _ _] + (let [thread-id (:id thread)] + (->> (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/ignore))))))) (defn detach-comment-thread "Detach comment threads that are inside a frame when that frame is deleted" diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index 30787180b..10effaf16 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -306,8 +306,8 @@ (ptk/reify ::fetch-builtin-templates ptk/WatchEvent (watch [_ _ _] - (->> (rp/cmd! :get-builtin-templates) - (rx/map builtin-templates-fetched))))) + (->> (rp/cmd! :get-builtin-templates) + (rx/map builtin-templates-fetched))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data Selection @@ -320,7 +320,7 @@ (update [_ state] (update state :dashboard-local assoc :selected-files #{} - :selected-project nil)))) + :selected-project nil)))) (defn toggle-file-select [{:keys [id project-id] :as file}] @@ -377,10 +377,10 @@ :or {on-success identity on-error rx/throw}} (meta params) features (features/get-enabled-features state)] - params {:name name - :emails #{emails} - :role role - :features features} + params {:name name + :emails #{emails} + :role role + :features features} (->> (rp/cmd! :create-team-with-invitations params) (rx/tap on-success) (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-recent-files id :is-shared] (constantly is-shared)) (cond-> - (not is-shared) + (not is-shared) (d/update-when :dashboard-shared-files dissoc id)))) ptk/WatchEvent @@ -1010,9 +1010,9 @@ (let [team-id (:current-team-id state)] (if (empty? term) (do - (dom/focus! (dom/get-element "search-input")) - (rx/of (rt/nav :dashboard-search - {:team-id team-id}))) + (dom/focus! (dom/get-element "search-input")) + (rx/of (rt/nav :dashboard-search + {:team-id team-id}))) (rx/of (rt/nav :dashboard-search {:team-id team-id} {:search-term term}))))) diff --git a/frontend/src/app/main/data/messages.cljs b/frontend/src/app/main/data/messages.cljs index cce234699..ef4c131ab 100644 --- a/frontend/src/app/main/data/messages.cljs +++ b/frontend/src/app/main/data/messages.cljs @@ -59,16 +59,16 @@ ptk/WatchEvent (watch [_ _ stream] (rx/merge - (let [stoper (rx/filter (ptk/type? ::hide) stream)] - (->> stream - (rx/filter (ptk/type? :app.util.router/navigate)) - (rx/map (constantly hide)) - (rx/take-until stoper))) - (when (:timeout data) - (let [stoper (rx/filter (ptk/type? ::show) stream)] - (->> (rx/of hide) - (rx/delay (:timeout data)) - (rx/take-until stoper)))))))) + (let [stoper (rx/filter (ptk/type? ::hide) stream)] + (->> stream + (rx/filter (ptk/type? :app.util.router/navigate)) + (rx/map (constantly hide)) + (rx/take-until stoper))) + (when (:timeout data) + (let [stoper (rx/filter (ptk/type? ::show) stream)] + (->> (rx/of hide) + (rx/delay (:timeout data)) + (rx/take-until stoper)))))))) (def hide (ptk/reify ::hide diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 4672ebbfd..50cd0e584 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -131,8 +131,8 @@ (when profile (swap! storage assoc :profile profile) (i18n/set-locale! (:lang profile)) - (when (not= previous-email email) - (swap! storage dissoc ::current-team-id))))))) + (when (not= previous-email email) + (swap! storage dissoc ::current-team-id))))))) (defn fetch-profile [] diff --git a/frontend/src/app/main/data/viewer.cljs b/frontend/src/app/main/data/viewer.cljs index e8c00c8ac..ae361f3e1 100644 --- a/frontend/src/app/main/data/viewer.cljs +++ b/frontend/src/app/main/data/viewer.cljs @@ -66,10 +66,10 @@ (-> state (assoc :current-file-id file-id) (update :viewer-local - (fn [lstate] - (if (nil? lstate) - default-local-state - lstate))) + (fn [lstate] + (if (nil? lstate) + default-local-state + lstate))) (assoc-in [:viewer-local :share-id] share-id) (assoc-in [:viewer-local :interactions-show?] interactions-show?))) @@ -202,10 +202,10 @@ "fill" zoom-to-fill nil)) (rx/of - (cond - (some? frame-id) (go-to-frame (uuid frame-id)) - (some? index) (go-to-frame-by-index index) - :else (go-to-frame-auto))))))))) + (cond + (some? frame-id) (go-to-frame (uuid frame-id)) + (some? index) (go-to-frame-by-index index) + :else (go-to-frame-auto))))))))) (defn fetch-comment-threads [{:keys [file-id page-id share-id] :as params}] @@ -297,9 +297,9 @@ ptk/UpdateEvent (update [_ state] (let [srect (as-> (get-in state [:route :query-params :page-id]) % - (get-in state [:viewer :pages % :frames]) - (nth % (get-in state [:route :query-params :index])) - (get % :selrect)) + (get-in state [:viewer :pages % :frames]) + (nth % (get-in state [:route :query-params :index])) + (get % :selrect)) orig-size (get-in state [:viewer-local :viewport-size]) wdiff (/ (:width orig-size) (:width srect)) hdiff (/ (:height orig-size) (:height srect)) @@ -514,9 +514,9 @@ (some? animation) (assoc-in [:viewer-animations (:id frame)] - {:kind :go-to-frame - :orig-frame-id (:id frame) - :animation animation})))) + {:kind :go-to-frame + :orig-frame-id (:id frame) + :animation animation})))) ptk/WatchEvent (watch [_ state _] diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 6c7213600..59e78502f 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -316,8 +316,8 @@ (rx/take 1) (rx/map #(go-to-component (uuid/uuid component-id)))))) - (rx/take-until - (rx/filter (ptk/type? ::fetch-bundle) stream)))))) + (rx/take-until + (rx/filter (ptk/type? ::fetch-bundle) stream)))))) (defn initialize-file [project-id file-id] @@ -1038,12 +1038,12 @@ shapes-to-select (->> selected (reduce - (fn [result shape-id] - (let [parent-id (dm/get-in objects [shape-id :parent-id])] - (if (and (some? parent-id) (not= parent-id uuid/zero)) - (conj result parent-id) - (conj result shape-id)))) - (d/ordered-set)))] + (fn [result shape-id] + (let [parent-id (dm/get-in objects [shape-id :parent-id])] + (if (and (some? parent-id) (not= parent-id uuid/zero)) + (conj result parent-id) + (conj result shape-id)))) + (d/ordered-set)))] (rx/of (dws/select-shapes shapes-to-select)))))) ;; --- Change Page Order (D&D Ordering) @@ -1470,17 +1470,17 @@ no-bool-shapes? (->> all-selected (some (comp #{:frame :text} :type)))] - (if (and (some? shape) (not (contains? selected (:id shape)))) - (rx/concat - (rx/of (dws/select-shape (:id shape))) - (rx/of (show-shape-context-menu params))) - (rx/of (show-context-menu - (-> params - (assoc - :kind :shape - :disable-booleans? (or no-bool-shapes? not-group-like?) - :disable-flatten? no-bool-shapes? - :selected (conj selected (:id shape))))))))))) + (if (and (some? shape) (not (contains? selected (:id shape)))) + (rx/concat + (rx/of (dws/select-shape (:id shape))) + (rx/of (show-shape-context-menu params))) + (rx/of (show-context-menu + (-> params + (assoc + :kind :shape + :disable-booleans? (or no-bool-shapes? not-group-like?) + :disable-flatten? no-bool-shapes? + :selected (conj selected (:id shape))))))))))) (defn show-page-item-context-menu [{:keys [position page] :as params}] @@ -1488,8 +1488,8 @@ (ptk/reify ::show-page-item-context-menu ptk/WatchEvent (watch [_ _ _] - (rx/of (show-context-menu - (-> params (assoc :kind :page :selected (:id page)))))))) + (rx/of (show-context-menu + (-> params (assoc :kind :page :selected (:id page)))))))) (defn show-track-context-menu [{:keys [grid-id type index] :as params}] @@ -1902,7 +1902,7 @@ ;; - 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 (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) (let [frame-id (ctst/top-nested-frame page-objects position) @@ -1953,8 +1953,7 @@ (ptk/reify ::paste-shapes ptk/WatchEvent (watch [it state _] - (let [ - file-id (:current-file-id state) + (let [file-id (:current-file-id state) page (wsh/lookup-page state) media-idx (->> (:media pdata) @@ -2216,23 +2215,23 @@ ptk/WatchEvent (watch [it state _] - (let [data (get state :workspace-data) + (let [data (get state :workspace-data) - update-fn - (fn [component] + update-fn + (fn [component] ;; NOTE: we need to ensure the component exists, ;; because there are small possibilities of race ;; conditions with component deletion. - (when component - (if (nil? annotation) - (dissoc component :annotation) - (assoc component :annotation annotation)))) + (when component + (if (nil? annotation) + (dissoc component :annotation) + (assoc component :annotation annotation)))) - changes (-> (pcb/empty-changes it) - (pcb/with-library-data data) - (pcb/update-component id update-fn))] + changes (-> (pcb/empty-changes it) + (pcb/with-library-data data) + (pcb/update-component id update-fn))] - (rx/of (dch/commit-changes changes)))))) + (rx/of (dch/commit-changes changes)))))) (defn set-annotations-expanded [expanded?] diff --git a/frontend/src/app/main/data/workspace/collapse.cljs b/frontend/src/app/main/data/workspace/collapse.cljs index 07bd85838..f805c238c 100644 --- a/frontend/src/app/main/data/workspace/collapse.cljs +++ b/frontend/src/app/main/data/workspace/collapse.cljs @@ -19,12 +19,12 @@ (update [_ state] (let [expand-fn (fn [expanded] (merge expanded - (->> ids - (map #(cfh/get-parent-ids objects %)) - flatten - (remove #(= % uuid/zero)) - (map (fn [id] {id true})) - (into {}))))] + (->> ids + (map #(cfh/get-parent-ids objects %)) + flatten + (remove #(= % uuid/zero)) + (map (fn [id] {id true})) + (into {}))))] (update-in state [:workspace-local :expanded] expand-fn))))) diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index a89467786..61ec72a63 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -332,9 +332,9 @@ (ptk/reify ::reorder-strokes ptk/WatchEvent (watch [_ _ _] - (rx/of (dch/update-shapes - ids - #(swap-attrs % :strokes index new-index)))))) + (rx/of (dch/update-shapes + ids + #(swap-attrs % :strokes index new-index)))))) (defn picker-for-selected-shape [] @@ -529,9 +529,9 @@ ptk/UpdateEvent (update [_ state] (update state :colorpicker - (fn [state] - (-> state - (assoc :type tab))))))) + (fn [state] + (-> state + (assoc :type tab))))))) (defn finalize-colorpicker [] @@ -622,10 +622,10 @@ ptk/UpdateEvent (update [_ state] (update state :colorpicker - (fn [state] - (-> state - (assoc :type :color) - (dissoc :editing-stop :stops :gradient))))))) + (fn [state] + (-> state + (assoc :type :color) + (dissoc :editing-stop :stops :gradient))))))) (defn activate-colorpicker-gradient [type] @@ -642,13 +642,13 @@ (d/dissoc-in [:current-color :image]) (cond-> (not (:stops state)) (assoc :editing-stop 0 - :stops [(-> color - (assoc :offset 0) - (materialize-color-components)) - (-> color - (assoc :alpha 0) - (assoc :offset 1) - (materialize-color-components))]))))))))) + :stops [(-> color + (assoc :offset 0) + (materialize-color-components)) + (-> color + (assoc :alpha 0) + (assoc :offset 1) + (materialize-color-components))]))))))))) (defn activate-colorpicker-image [] @@ -656,10 +656,10 @@ ptk/UpdateEvent (update [_ state] (update state :colorpicker - (fn [state] - (-> state - (assoc :type :image) - (dissoc :editing-stop :stops :gradient))))))) + (fn [state] + (-> state + (assoc :type :image) + (dissoc :editing-stop :stops :gradient))))))) (defn select-color [position add-color] @@ -671,13 +671,13 @@ shape (first shapes) fills (if (cfh/text-shape? shape) (:fills (dwt/current-text-values - {:editor-state (dm/get-in state [:workspace-editor-state (:id shape)]) - :shape shape - :attrs (conj dwt/text-fill-attrs :fills)})) + {:editor-state (dm/get-in state [:workspace-editor-state (:id shape)]) + :shape shape + :attrs (conj dwt/text-fill-attrs :fills)})) (:fills shape)) fill (first fills) single? (and (= 1 (count selected)) - (= 1 (count fills))) + (= 1 (count fills))) data (if single? (d/without-nils {:color (:fill-color fill) :opacity (:fill-opacity fill) @@ -685,13 +685,13 @@ {:color "#406280" :opacity 1})] (rx/of (md/show :colorpicker - {:x (:x position) - :y (:y position) - :on-accept add-color - :data data - :position :right}) - (ptk/event ::ev/event {::ev/name "add-asset-to-library" - :asset-type "color"})))))) + {:x (:x position) + :y (:y position) + :on-accept add-color + :data data + :position :right}) + (ptk/event ::ev/event {::ev/name "add-asset-to-library" + :asset-type "color"})))))) (defn get-active-color-tab [] diff --git a/frontend/src/app/main/data/workspace/comments.cljs b/frontend/src/app/main/data/workspace/comments.cljs index 0c4850a40..800647dad 100644 --- a/frontend/src/app/main/data/workspace/comments.cljs +++ b/frontend/src/app/main/data/workspace/comments.cljs @@ -42,7 +42,7 @@ (rx/filter mse/mouse-click-event?) (rx/switch-map #(rx/take 1 ms/mouse-position)) (rx/with-latest-from ms/keyboard-space) - (rx/filter (fn [[_ space]] (not space)) ) + (rx/filter (fn [[_ space]] (not space))) (rx/map first) (rx/map handle-comment-layer-click) (rx/take-until stoper)) diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 19c610c14..063c1e50a 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -169,7 +169,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn toggle-toolbar-visibility - [] + [] (ptk/reify ::toggle-toolbar-visibility ptk/UpdateEvent (update [_ state] @@ -180,7 +180,7 @@ (ptk/reify ::hide-toolbar ptk/UpdateEvent (update [_ state] - (assoc-in state [:workspace-local :hide-toolbar] true)))) + (assoc-in state [:workspace-local :hide-toolbar] true)))) (defn show-toolbar [] diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 0254cd291..9a3793b10 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -82,7 +82,7 @@ (rx/merge (rx/of (handle-drawing type)) (->> stream - (rx/filter (ptk/type? ::common/handle-finish-drawing) ) + (rx/filter (ptk/type? ::common/handle-finish-drawing)) (rx/take 1) (rx/map #(fn [state] (update state :workspace-drawing dissoc :lock))))))))))) diff --git a/frontend/src/app/main/data/workspace/fix_deleted_fonts.cljs b/frontend/src/app/main/data/workspace/fix_deleted_fonts.cljs index 06fb37621..31ec4176e 100644 --- a/frontend/src/app/main/data/workspace/fix_deleted_fonts.cljs +++ b/frontend/src/app/main/data/workspace/fix_deleted_fonts.cljs @@ -25,8 +25,8 @@ [node] (let [fonts (deref fonts/fontsdb)] (and - (some? (:font-family node)) - (nil? (get fonts (:font-id node)))))) + (some? (:font-family node)) + (nil? (get fonts (:font-id node)))))) (defn calculate-alternative-font-id [value] @@ -66,9 +66,9 @@ (defn fix-deleted-font-component [component] (update component - :objects - (fn [objects] - (d/mapm #(fix-deleted-font-shape %2) objects)))) + :objects + (fn [objects] + (d/mapm #(fix-deleted-font-shape %2) objects)))) (defn fix-deleted-font-typography [typography] @@ -84,8 +84,8 @@ (let [objects (wsh/lookup-page-objects state) ids (into #{} - (comp (filter should-fix-deleted-font-shape?) (map :id)) - (vals objects)) + (comp (filter should-fix-deleted-font-shape?) (map :id)) + (vals objects)) components (->> (wsh/lookup-local-components state) (vals) @@ -93,11 +93,11 @@ component-changes (into [] - (map (fn [component] - {:type :mod-component - :id (:id component) - :objects (-> (fix-deleted-font-component component) :objects)})) - components) + (map (fn [component] + {:type :mod-component + :id (:id component) + :objects (-> (fix-deleted-font-component component) :objects)})) + components) typographies (->> (get-in state [:workspace-data :typographies]) (vals) @@ -105,25 +105,25 @@ typography-changes (into [] - (map (fn [typography] - {:type :mod-typography - :typography (fix-deleted-font-typography typography)})) - typographies)] + (map (fn [typography] + {:type :mod-typography + :typography (fix-deleted-font-typography typography)})) + typographies)] (rx/concat - (rx/of (dch/update-shapes ids #(fix-deleted-font-shape %) {:reg-objects? false - :save-undo? false - :ignore-tree true})) - (if (empty? component-changes) - (rx/empty) - (rx/of (dch/commit-changes {:origin it - :redo-changes component-changes - :undo-changes [] - :save-undo? false}))) + (rx/of (dch/update-shapes ids #(fix-deleted-font-shape %) {:reg-objects? false + :save-undo? false + :ignore-tree true})) + (if (empty? component-changes) + (rx/empty) + (rx/of (dch/commit-changes {:origin it + :redo-changes component-changes + :undo-changes [] + :save-undo? false}))) - (if (empty? typography-changes) - (rx/empty) - (rx/of (dch/commit-changes {:origin it - :redo-changes typography-changes - :undo-changes [] - :save-undo? false})))))))) + (if (empty? typography-changes) + (rx/empty) + (rx/of (dch/commit-changes {:origin it + :redo-changes typography-changes + :undo-changes [] + :save-undo? false})))))))) diff --git a/frontend/src/app/main/data/workspace/grid.cljs b/frontend/src/app/main/data/workspace/grid.cljs index d8e8b93db..50a235107 100644 --- a/frontend/src/app/main/data/workspace/grid.cljs +++ b/frontend/src/app/main/data/workspace/grid.cljs @@ -76,6 +76,6 @@ (watch [it state _] (let [page (wsh/lookup-page state)] (rx/of (dch/commit-changes - (-> (pcb/empty-changes it) - (pcb/with-page page) - (pcb/set-page-option [:saved-grids type] params)))))))) + (-> (pcb/empty-changes it) + (pcb/with-page page) + (pcb/set-page-option [:saved-grids type] params)))))))) diff --git a/frontend/src/app/main/data/workspace/grid_layout/shortcuts.cljs b/frontend/src/app/main/data/workspace/grid_layout/shortcuts.cljs index 078858fd7..8d76c38ca 100644 --- a/frontend/src/app/main/data/workspace/grid_layout/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/grid_layout/shortcuts.cljs @@ -64,8 +64,7 @@ :zoom-selected {:tooltip (ds/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] (assert (contains? shortcuts shortcut) (str shortcut)) diff --git a/frontend/src/app/main/data/workspace/groups.cljs b/frontend/src/app/main/data/workspace/groups.cljs index ff477d320..a89d845cb 100644 --- a/frontend/src/app/main/data/workspace/groups.cljs +++ b/frontend/src/app/main/data/workspace/groups.cljs @@ -55,7 +55,7 @@ (empty? (remove removed-id? (:shapes group)))) ;; 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) (rest to-check) (conj removed-id? current-id) @@ -243,10 +243,10 @@ (when-not (empty? selected) (rx/of (dwu/start-undo-transaction undo-id) - (dch/commit-changes changes) - (ptk/data-event :layout/update parents) - (dwu/commit-undo-transaction undo-id) - (dws/select-shapes child-ids))))))) + (dch/commit-changes changes) + (ptk/data-event :layout/update parents) + (dwu/commit-undo-transaction undo-id) + (dws/select-shapes child-ids))))))) (def mask-group (ptk/reify ::mask-group diff --git a/frontend/src/app/main/data/workspace/interactions.cljs b/frontend/src/app/main/data/workspace/interactions.cljs index ab2584940..a8e2fe284 100644 --- a/frontend/src/app/main/data/workspace/interactions.cljs +++ b/frontend/src/app/main/data/workspace/interactions.cljs @@ -41,9 +41,9 @@ :starting-frame starting-frame}] (rx/of (dch/commit-changes - (-> (pcb/empty-changes it) - (pcb/with-page page) - (pcb/update-page-option :flows ctp/add-flow new-flow)))))))) + (-> (pcb/empty-changes it) + (pcb/with-page page) + (pcb/update-page-option :flows ctp/add-flow new-flow)))))))) (defn add-flow-selected-frame [] @@ -61,9 +61,9 @@ (watch [it state _] (let [page (wsh/lookup-page state)] (rx/of (dch/commit-changes - (-> (pcb/empty-changes it) - (pcb/with-page page) - (pcb/update-page-option :flows ctp/remove-flow flow-id)))))))) + (-> (pcb/empty-changes it) + (pcb/with-page page) + (pcb/update-page-option :flows ctp/remove-flow flow-id)))))))) (defn rename-flow [flow-id name] @@ -72,12 +72,12 @@ (ptk/reify ::rename-flow ptk/WatchEvent (watch [it state _] - (let [page (wsh/lookup-page state) ] + (let [page (wsh/lookup-page state)] (rx/of (dch/commit-changes - (-> (pcb/empty-changes it) - (pcb/with-page page) - (pcb/update-page-option :flows ctp/update-flow flow-id - #(ctp/rename-flow % name))))))))) + (-> (pcb/empty-changes it) + (pcb/with-page page) + (pcb/update-page-option :flows ctp/update-flow flow-id + #(ctp/rename-flow % name))))))))) (defn start-rename-flow [id] @@ -120,16 +120,16 @@ :flows] []) flow (ctp/get-frame-flow flows (:id frame))] (rx/concat - (rx/of (dch/update-shapes [(:id shape)] - (fn [shape] - (let [new-interaction (-> ctsi/default-interaction - (ctsi/set-destination destination) - (assoc :position-relative-to (:id shape)))] - (update shape :interactions - ctsi/add-interaction new-interaction))))) - (when (and (not (connected-frame? objects (:id frame))) - (nil? flow)) - (rx/of (add-flow (:id frame)))))))))) + (rx/of (dch/update-shapes [(:id shape)] + (fn [shape] + (let [new-interaction (-> ctsi/default-interaction + (ctsi/set-destination destination) + (assoc :position-relative-to (:id shape)))] + (update shape :interactions + ctsi/add-interaction new-interaction))))) + (when (and (not (connected-frame? objects (:id frame))) + (nil? flow)) + (rx/of (add-flow (:id frame)))))))))) (defn remove-interaction [shape index] @@ -137,9 +137,9 @@ ptk/WatchEvent (watch [_ _ _] (rx/of (dch/update-shapes [(:id shape)] - (fn [shape] - (update shape :interactions - ctsi/remove-interaction index))))))) + (fn [shape] + (update shape :interactions + ctsi/remove-interaction index))))))) (defn update-interaction [shape index update-fn] @@ -147,9 +147,9 @@ ptk/WatchEvent (watch [_ _ _] (rx/of (dch/update-shapes [(:id shape)] - (fn [shape] - (update shape :interactions - ctsi/update-interaction index update-fn))))))) + (fn [shape] + (update shape :interactions + ctsi/update-interaction index update-fn))))))) (defn remove-all-interactions-nav-to "Remove all interactions that navigate to the given frame." @@ -189,14 +189,14 @@ (let [initial-pos @ms/mouse-position selected (wsh/lookup-selected state) stopper (->> stream - (rx/filter mse/mouse-event?) - (rx/filter mse/mouse-up-event?))] + (rx/filter mse/mouse-event?) + (rx/filter mse/mouse-up-event?))] (when (= 1 (count selected)) (rx/concat - (->> ms/mouse-position - (rx/take-until stopper) - (rx/map #(move-edit-interaction initial-pos %))) - (rx/of (finish-edit-interaction index initial-pos)))))))) + (->> ms/mouse-position + (rx/take-until stopper) + (rx/map #(move-edit-interaction initial-pos %))) + (rx/of (finish-edit-interaction index initial-pos)))))))) (defn- get-target-frame [state position] @@ -252,33 +252,33 @@ undo-id (js/Symbol)] (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 ; users can navigate to it. - (dch/update-shapes [(:id target-frame)] - #(dissoc % :hide-in-viewer))) + (dch/update-shapes [(:id target-frame)] + #(dissoc % :hide-in-viewer))) - (cond - (or (nil? shape) + (cond + (or (nil? shape) ;; Didn't changed the position for the interaction - (= position initial-pos) + (= position initial-pos) ;; New interaction but invalid target - (and (nil? index) (nil? target-frame))) - nil + (and (nil? index) (nil? target-frame))) + nil ;; Dropped interaction in an invalid target. We remove it - (and (some? index) (nil? target-frame)) - (remove-interaction shape index) + (and (some? index) (nil? target-frame)) + (remove-interaction shape index) - (nil? index) - (add-new-interaction shape (:id target-frame)) + (nil? index) + (add-new-interaction shape (:id target-frame)) - :else - (update-interaction shape index change-interaction)) + :else + (update-interaction shape index change-interaction)) - (dwu/commit-undo-transaction undo-id)))))) + (dwu/commit-undo-transaction undo-id)))))) ;; --- Overlays @@ -299,8 +299,8 @@ (let [initial-pos @ms/mouse-position selected (wsh/lookup-selected state) stopper (->> stream - (rx/filter mse/mouse-event?) - (rx/filter mse/mouse-up-event?))] + (rx/filter mse/mouse-event?) + (rx/filter mse/mouse-up-event?))] (when (= 1 (count selected)) (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) @@ -317,10 +317,10 @@ (gpt/subtract overlay-pos) (gpt/subtract frame-pos))] (rx/concat - (->> ms/mouse-position - (rx/take-until stopper) - (rx/map #(move-overlay-pos % frame-pos offset))) - (rx/of (finish-move-overlay-pos index frame-pos offset))))))))) + (->> ms/mouse-position + (rx/take-until stopper) + (rx/map #(move-overlay-pos % frame-pos offset))) + (rx/of (finish-move-overlay-pos index frame-pos offset))))))))) (defn move-overlay-pos [pos frame-pos offset] @@ -333,33 +333,33 @@ (assoc-in state [:workspace-local :move-overlay-to] pos))))) (defn finish-move-overlay-pos - [index frame-pos offset] - (ptk/reify ::finish-move-overlay-pos + [index frame-pos offset] + (ptk/reify ::finish-move-overlay-pos ptk/UpdateEvent (update [_ state] (-> state (d/dissoc-in [:workspace-local :move-overlay-to]) (d/dissoc-in [:workspace-local :move-overlay-index]))) - ptk/WatchEvent - (watch [_ state _] - (let [pos @ms/mouse-position - overlay-pos (-> pos - (gpt/subtract frame-pos) - (gpt/subtract offset)) + ptk/WatchEvent + (watch [_ state _] + (let [pos @ms/mouse-position + overlay-pos (-> pos + (gpt/subtract frame-pos) + (gpt/subtract offset)) - page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) - shape (->> state - wsh/lookup-selected - first - (get objects)) + page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) + shape (->> state + wsh/lookup-selected + first + (get objects)) - interactions (:interactions shape) + interactions (:interactions shape) - new-interactions - (update interactions index - #(ctsi/set-overlay-position % overlay-pos))] + new-interactions + (update interactions index + #(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}))))))) diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 9d11f48e7..99a078fbb 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -580,11 +580,11 @@ (ptk/reify ::detach-components ptk/WatchEvent (watch [_ _ _] - (let [undo-id (js/Symbol)] - (rx/concat - (rx/of (dwu/start-undo-transaction undo-id)) - (rx/map #(detach-component %) (rx/from ids)) - (rx/of (dwu/commit-undo-transaction undo-id))))))) + (let [undo-id (js/Symbol)] + (rx/concat + (rx/of (dwu/start-undo-transaction undo-id)) + (rx/map #(detach-component %) (rx/from ids)) + (rx/of (dwu/commit-undo-transaction undo-id))))))) (def detach-selected-components (ptk/reify ::detach-selected-components @@ -797,12 +797,12 @@ (watch [_ state _] (let [current-file-id (:current-file-id state) undo-id (js/Symbol)] - (rx/of - (dwu/start-undo-transaction undo-id) - (sync-file current-file-id file-id :components component-id undo-group) - (when (not= current-file-id file-id) - (sync-file file-id file-id :components component-id undo-group)) - (dwu/commit-undo-transaction undo-id))))))) + (rx/of + (dwu/start-undo-transaction undo-id) + (sync-file current-file-id file-id :components component-id undo-group) + (when (not= current-file-id file-id) + (sync-file file-id file-id :components component-id undo-group)) + (dwu/commit-undo-transaction undo-id))))))) (defn update-component-thumbnail "Update the thumbnail of the component with the given id, in the @@ -813,10 +813,10 @@ (watch [_ state _] (rx/of (update-component-thumbnail-sync state component-id file-id "component")) #_(let [data (get state :workspace-data) - component (ctkl/get-component data component-id) - page-id (:main-instance-page component) - root-id (:main-instance-id component)] - (rx/of (dwt/request-thumbnail file-id page-id root-id "component")))))) + component (ctkl/get-component data component-id) + page-id (:main-instance-page component) + root-id (:main-instance-id component)] + (rx/of (dwt/request-thumbnail file-id page-id root-id "component")))))) (defn- find-shape-index [objects id shape-id] @@ -965,15 +965,15 @@ find-frames (fn [change] - (->> (ch/frames-changed file change) - (map #(assoc %1 :page-id (:page-id change))))) + (->> (ch/frames-changed file change) + (map #(assoc %1 :page-id (:page-id change))))) updated-frames (->> changes - :redo-changes - (mapcat find-frames) - distinct)] + :redo-changes + (mapcat find-frames) + distinct)] (log/debug :msg "SYNC-FILE finished" :js/rchanges (log-changes (:redo-changes changes) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index f9854062f..937079b2b 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -976,11 +976,11 @@ [_ new-shapes _] (ctst/clone-shape component-shape - (:id parent-shape) - (get component-page :objects) - :update-new-shape update-new-shape - :update-original-shape update-original-shape - :dest-objects (get container :objects)) + (:id parent-shape) + (get component-page :objects) + :update-new-shape update-new-shape + :update-original-shape update-original-shape + :dest-objects (get container :objects)) add-obj-change (fn [changes shape'] (update changes :redo-changes conj diff --git a/frontend/src/app/main/data/workspace/media.cljs b/frontend/src/app/main/data/workspace/media.cljs index 5369e376a..12a50de5a 100644 --- a/frontend/src/app/main/data/workspace/media.cljs +++ b/frontend/src/app/main/data/workspace/media.cljs @@ -97,7 +97,7 @@ (rx/map #(svg/add-svg-shapes (assoc svg-data :image-data %) position)))))) (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] (or (and mtype (= mtype "image/svg+xml")) (str/ends-with? url ".svg"))) @@ -211,28 +211,28 @@ (defn- process-media-objects [{:keys [uris on-error] :as params}] (dm/assert! - (and (sm/check! schema:process-media-objects params) - (or (contains? params :blobs) - (contains? params :uris)))) + (and (sm/check! schema:process-media-objects params) + (or (contains? params :blobs) + (contains? params :uris)))) (ptk/reify ::process-media-objects ptk/WatchEvent (watch [_ _ _] (rx/concat - (rx/of (msg/show {:content (tr "media.loading") - :type :info - :timeout nil - :tag :media-loading})) - (->> (if (seq uris) + (rx/of (msg/show {:content (tr "media.loading") + :type :info + :timeout nil + :tag :media-loading})) + (->> (if (seq uris) ;; 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 - (process-blobs params)) + (process-blobs params)) ;; Every stream has its own sideeffect. We need to ignore the result - (rx/ignore) - (rx/catch #(handle-media-error % on-error)) - (rx/finalize #(st/emit! (msg/hide-tag :media-loading)))))))) + (rx/ignore) + (rx/catch #(handle-media-error % on-error)) + (rx/finalize #(st/emit! (msg/hide-tag :media-loading)))))))) ;; Deprecated in components-v2 (defn upload-media-asset @@ -256,8 +256,8 @@ (defn upload-fill-image [file on-success] (dm/assert! - "expected a valid blob for `file` param" - (dmm/blob? file)) + "expected a valid blob for `file` param" + (dmm/blob? file)) (ptk/reify ::upload-fill-image ptk/WatchEvent (watch [_ state _] @@ -293,9 +293,9 @@ (rx/map #(vector (:name media-obj) %)) (rx/merge-map svg->clj) (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) - :hint (ex-message %) - :error %))))) + #(log/error :msg (str "Error downloading " (:name media-obj) " from " path) + :hint (ex-message %) + :error %))))) (defn create-shapes-svg "Convert svg elements into penpot shapes." diff --git a/frontend/src/app/main/data/workspace/modifiers.cljs b/frontend/src/app/main/data/workspace/modifiers.cljs index dcdd9c4fa..d27b980f6 100644 --- a/frontend/src/app/main/data/workspace/modifiers.cljs +++ b/frontend/src/app/main/data/workspace/modifiers.cljs @@ -275,11 +275,11 @@ (update-in [target-frame-id :modifiers] ctm/change-property :layout-item-v-sizing :fix))))) (defn modif->js - [modif-tree objects] - (clj->js (into {} - (map (fn [[k v]] - [(get-in objects [k :name]) v])) - modif-tree))) + [modif-tree objects] + (clj->js (into {} + (map (fn [[k v]] + [(get-in objects [k :name]) v])) + modif-tree))) (defn apply-text-modifier [shape {:keys [width height]}] @@ -301,19 +301,19 @@ (d/update-when result id apply-text-modifier text-modifier)))))) #_(defn apply-path-modifiers - [objects path-modifiers] - (letfn [(apply-path-modifier - [shape {:keys [content-modifiers]}] - (let [shape (update shape :content upc/apply-content-modifiers content-modifiers) - [points selrect] (helpers/content->points+selrect shape (:content shape))] - (assoc shape :selrect selrect :points points)))] - (loop [modifiers (seq path-modifiers) - result objects] - (if (empty? modifiers) - result - (let [[id path-modifier] (first modifiers)] - (recur (rest modifiers) - (update objects id apply-path-modifier path-modifier))))))) + [objects path-modifiers] + (letfn [(apply-path-modifier + [shape {:keys [content-modifiers]}] + (let [shape (update shape :content upc/apply-content-modifiers content-modifiers) + [points selrect] (helpers/content->points+selrect shape (:content shape))] + (assoc shape :selrect selrect :points points)))] + (loop [modifiers (seq path-modifiers) + result objects] + (if (empty? modifiers) + result + (let [[id path-modifier] (first modifiers)] + (recur (rest modifiers) + (update objects id apply-path-modifier path-modifier))))))) (defn- calculate-modifiers ([state modif-tree] @@ -544,8 +544,7 @@ :layout-item-margin-type :layout-grid-cells :layout-grid-columns - :layout-grid-rows - ]}) + :layout-grid-rows]}) ;; We've applied the text-modifier so we can dissoc the temporary data (fn [state] (update state :workspace-text-modifier #(apply dissoc % ids))) diff --git a/frontend/src/app/main/data/workspace/path/helpers.cljs b/frontend/src/app/main/data/workspace/path/helpers.cljs index feb898abb..de955f0f1 100644 --- a/frontend/src/app/main/data/workspace/path/helpers.cljs +++ b/frontend/src/app/main/data/workspace/path/helpers.cljs @@ -131,7 +131,7 @@ (let [;; To match the angle, the angle should be matching (angle between points 180deg) 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 match-distance? (and match-distance? (mth/almost-zero? (- (gpt/distance node handler) diff --git a/frontend/src/app/main/data/workspace/path/streams.cljs b/frontend/src/app/main/data/workspace/path/streams.cljs index 3c429d666..0bc1ad208 100644 --- a/frontend/src/app/main/data/workspace/path/streams.cljs +++ b/frontend/src/app/main/data/workspace/path/streams.cljs @@ -53,11 +53,11 @@ start (-> @ms/mouse-position to-pixel-snap) stoper (rx/merge - (->> st/stream - (rx/filter mse/mouse-event?) - (rx/filter mse/mouse-up-event?)) - (->> st/stream - (rx/filter finish-edition?))) + (->> st/stream + (rx/filter mse/mouse-event?) + (rx/filter mse/mouse-up-event?)) + (->> st/stream + (rx/filter finish-edition?))) position-stream (->> ms/mouse-position diff --git a/frontend/src/app/main/data/workspace/persistence.cljs b/frontend/src/app/main/data/workspace/persistence.cljs index dd056da35..b506c13bc 100644 --- a/frontend/src/app/main/data/workspace/persistence.cljs +++ b/frontend/src/app/main/data/workspace/persistence.cljs @@ -145,8 +145,7 @@ :revn file-revn :session-id sid :changes-with-metadata (into [] changes) - :features features - }] + :features features}] (->> (rp/cmd! :update-file params) (rx/mapcat (fn [lagged] diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index b6828a194..5ee865400 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -368,7 +368,7 @@ (-> (pcb/empty-changes it) (pcb/with-page page) (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] (let [shapes (map (d/getf all-objects) ids) @@ -495,7 +495,7 @@ (not duplicating-component?) (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?)}) (pcb/amend-last-change #(assoc % :old-id (:id obj))) (cond-> (ctl/grid-layout? objects (:parent-id obj)) @@ -506,7 +506,7 @@ (and is-component-root? is-component-main?) (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) new-obj {:objects objects} @@ -545,15 +545,15 @@ (if-not (empty? frames-with-flow) (let [update-flows (fn [flows] (reduce - (fn [flows frame] - (let [name (cfh/generate-unique-name @unames "Flow 1") - _ (vswap! unames conj name) - new-flow {:id (uuid/next) - :name name - :starting-frame (get ids-map (:id frame))}] - (ctp/add-flow flows new-flow))) - flows - frames-with-flow))] + (fn [flows frame] + (let [name (cfh/generate-unique-name @unames "Flow 1") + _ (vswap! unames conj name) + new-flow {:id (uuid/next) + :name name + :starting-frame (get ids-map (:id frame))}] + (ctp/add-flow flows new-flow))) + flows + frames-with-flow))] (pcb/update-page-option changes :flows update-flows)) changes))) @@ -611,9 +611,9 @@ objects-indices (->> index-map (d/mapm fix-indices) (vals) (reduce merge))] (pcb/amend-changes - changes - (fn [change] - (assoc change :index (get objects-indices (:old-id change))))))) + changes + (fn [change] + (assoc change :index (get objects-indices (:old-id change))))))) (defn clear-memorize-duplicated [] @@ -671,52 +671,52 @@ ([move-delta?] (duplicate-selected move-delta? false)) ([move-delta? alt-duplication?] - (ptk/reify ::duplicate-selected - ptk/WatchEvent - (watch [it state _] - (when (or (not move-delta?) (nil? (get-in state [:workspace-local :transform]))) - (let [page (wsh/lookup-page state) - objects (:objects page) - selected (->> (wsh/lookup-selected state) - (map #(get objects %)) - (remove #(ctk/in-component-copy-not-root? %)) ;; We don't want to change the structure of component copies - (map :id) - set)] - (when (seq selected) - (let [obj (get objects (first selected)) - delta (if move-delta? - (calc-duplicate-delta obj state objects) - (gpt/point 0 0)) + (ptk/reify ::duplicate-selected + ptk/WatchEvent + (watch [it state _] + (when (or (not move-delta?) (nil? (get-in state [:workspace-local :transform]))) + (let [page (wsh/lookup-page state) + objects (:objects page) + selected (->> (wsh/lookup-selected state) + (map #(get objects %)) + (remove #(ctk/in-component-copy-not-root? %)) ;; We don't want to change the structure of component copies + (map :id) + set)] + (when (seq selected) + (let [obj (get objects (first selected)) + delta (if move-delta? + (calc-duplicate-delta obj state objects) + (gpt/point 0 0)) - file-id (:current-file-id state) - libraries (wsh/get-libraries state) - library-data (wsh/get-file state file-id) + file-id (:current-file-id state) + libraries (wsh/get-libraries state) + library-data (wsh/get-file state file-id) - changes (->> (prepare-duplicate-changes objects page selected delta it libraries library-data file-id) - (duplicate-changes-update-indices objects selected)) + changes (->> (prepare-duplicate-changes objects page selected delta it libraries library-data file-id) + (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 - :redo-changes - (filter #(= (:type %) :add-obj)) - (filter #(selected (:old-id %))) - (map #(get-in % [:obj :id])) - (into (d/ordered-set))) + new-selected (->> changes + :redo-changes + (filter #(= (:type %) :add-obj)) + (filter #(selected (:old-id %))) + (map #(get-in % [:obj :id])) + (into (d/ordered-set))) - id-duplicated (first new-selected) + id-duplicated (first new-selected) - frames (into #{} - (map #(get-in objects [% :frame-id])) - selected) - undo-id (js/Symbol)] + frames (into #{} + (map #(get-in objects [% :frame-id])) + selected) + undo-id (js/Symbol)] - ;; Warning: This order is important for the focus mode. - (rx/of + ;; Warning: This order is important for the focus mode. + (rx/of (dwu/start-undo-transaction undo-id) (dch/commit-changes changes) (select-shapes new-selected) diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index e2d5b6b90..81689f6b2 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -255,7 +255,7 @@ :command "t" :subsections [:tools] :fn #(emit-when-no-readonly dwtxt/start-edit-if-selected - (dwd/select-for-drawing :text))} + (dwd/select-for-drawing :text))} :draw-path {:tooltip "P" :command "p" @@ -399,7 +399,7 @@ :command (ds/c-mod "shift+e") :subsections [:basics :main-menu] :fn #(st/emit! - (de/show-workspace-export-dialog))} + (de/show-workspace-export-dialog))} :toggle-snap-guide {:tooltip (ds/meta-shift "G") :command (ds/c-mod "shift+g") @@ -432,15 +432,15 @@ :command (ds/a-mod "p") :subsections [:panels] :fn #(do (r/set-resize-type! :bottom) - (emit-when-no-readonly (dw/remove-layout-flag :textpalette) - (toggle-layout-flag :colorpalette)))} + (emit-when-no-readonly (dw/remove-layout-flag :textpalette) + (toggle-layout-flag :colorpalette)))} :toggle-textpalette {:tooltip (ds/alt "T") :command (ds/a-mod "t") :subsections [:panels] :fn #(do (r/set-resize-type! :bottom) - (emit-when-no-readonly (dw/remove-layout-flag :colorpalette) - (toggle-layout-flag :textpalette)))} + (emit-when-no-readonly (dw/remove-layout-flag :colorpalette) + (toggle-layout-flag :textpalette)))} :hide-ui {:tooltip "\\" :command "\\" diff --git a/frontend/src/app/main/data/workspace/specialized_panel.cljs b/frontend/src/app/main/data/workspace/specialized_panel.cljs index 41f25f14f..eb4ec08f5 100644 --- a/frontend/src/app/main/data/workspace/specialized_panel.cljs +++ b/frontend/src/app/main/data/workspace/specialized_panel.cljs @@ -24,18 +24,18 @@ (defn open-specialized-panel [type] - (ptk/reify ::open-specialized-panel - ptk/UpdateEvent - (update [_ state] - (let [page-id (:current-page-id state) - objects (wsh/lookup-page-objects state page-id) - selected-ids (wsh/lookup-selected state) - selected-shapes (map (d/getf objects) selected-ids)] - (assoc state :specialized-panel {:type type :shapes selected-shapes}))) - ptk/WatchEvent - (watch [_ _ stream] - (->> (rx/merge - (rx/filter interrupt? stream) - (rx/filter (ptk/type? ::dwc/undo) stream)) - (rx/take 1) - (rx/map clear-specialized-panel))))) + (ptk/reify ::open-specialized-panel + ptk/UpdateEvent + (update [_ state] + (let [page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) + selected-ids (wsh/lookup-selected state) + selected-shapes (map (d/getf objects) selected-ids)] + (assoc state :specialized-panel {:type type :shapes selected-shapes}))) + ptk/WatchEvent + (watch [_ _ stream] + (->> (rx/merge + (rx/filter interrupt? stream) + (rx/filter (ptk/type? ::dwc/undo) stream)) + (rx/take 1) + (rx/map clear-specialized-panel))))) diff --git a/frontend/src/app/main/data/workspace/text/shortcuts.cljs b/frontend/src/app/main/data/workspace/text/shortcuts.cljs index e60807eda..cd280aba2 100644 --- a/frontend/src/app/main/data/workspace/text/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/text/shortcuts.cljs @@ -76,11 +76,11 @@ (or (= variant-id "remove-bold") (= variant-id "toggle-bold"))) add-italic? (and (not italic?) - (or (= variant-id "add-italic") - (= variant-id "toggle-italic"))) + (or (= variant-id "add-italic") + (= variant-id "toggle-italic"))) remove-italic? (and italic? - (or (= variant-id "remove-italic") - (= variant-id "toggle-italic")))] + (or (= variant-id "remove-italic") + (= variant-id "toggle-italic")))] (cond (and add-bold? italic?) ;; it is italic, set it to bold+italic (choose-bold-italic) @@ -127,8 +127,7 @@ :attrs dwt/text-attrs})))) (defn- update-attrs [shape props] - (let [ - text-values (calculate-text-values shape) + (let [text-values (calculate-text-values shape) font-size (d/parse-double (:font-size text-values)) line-height (d/parse-double (:line-height text-values)) letter-spacing (d/parse-double (:letter-spacing text-values)) @@ -166,8 +165,7 @@ all-underline? (every? #(= (:text-decoration %) "underline") text-values) all-line-through? (every? #(= (:text-decoration %) "line-through") 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 (= (:text-decoration props) "toggle-underline") (if all-underline? @@ -197,9 +195,9 @@ (blend-props text-shapes props) props)] (when (and (not read-only?) text-shapes) - (st/emit! (dwu/start-undo-transaction undo-id)) - (run! #(update-attrs % props) text-shapes) - (st/emit! (dwu/commit-undo-transaction undo-id))))) + (st/emit! (dwu/start-undo-transaction undo-id)) + (run! #(update-attrs % props) text-shapes) + (st/emit! (dwu/commit-undo-transaction undo-id))))) (def shortcuts {:text-align-left {:tooltip (ds/meta (ds/alt "L")) diff --git a/frontend/src/app/main/data/workspace/texts.cljs b/frontend/src/app/main/data/workspace/texts.cljs index 767310130..c741a4e62 100644 --- a/frontend/src/app/main/data/workspace/texts.cljs +++ b/frontend/src/app/main/data/workspace/texts.cljs @@ -339,8 +339,7 @@ (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) - (assoc :fills [color-attrs]))) - )) + (assoc :fills [color-attrs]))))) (defn migrate-content [content] diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 16904a1ee..52cdaf53e 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -45,13 +45,13 @@ ;; for example, right will only grow in the x coordinate and left ;; will grow in the inverse of the x coordinate (def ^:private handler-multipliers - {:right [ 1 0] - :bottom [ 0 1] + {:right [1 0] + :bottom [0 1] :left [-1 0] - :top [ 0 -1] - :top-right [ 1 -1] + :top [0 -1] + :top-right [1 -1] :top-left [-1 -1] - :bottom-right [ 1 1] + :bottom-right [1 1] :bottom-left [-1 1]}) (defn- handler-resize-origin diff --git a/frontend/src/app/main/data/workspace/undo.cljs b/frontend/src/app/main/data/workspace/undo.cljs index 3c6036c8f..809c9f6a5 100644 --- a/frontend/src/app/main/data/workspace/undo.cljs +++ b/frontend/src/app/main/data/workspace/undo.cljs @@ -64,13 +64,13 @@ items (conj-undo-entry items entry)] (-> state (update :workspace-undo assoc :items items - :index (min (inc index) - (dec MAX-UNDO-SIZE))))) + :index (min (inc index) + (dec MAX-UNDO-SIZE))))) state)) (defn- stack-undo-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) (update-in state [:workspace-undo :items index] (fn [item] @@ -86,7 +86,7 @@ (update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes)) (cond-> (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))) (defn append-undo @@ -101,18 +101,18 @@ (ptk/reify ::append-undo ptk/UpdateEvent (update [_ state] - (cond - (and (get-in state [:workspace-undo :transaction]) - (or (not stack?) - (d/not-empty? (get-in state [:workspace-undo :transaction :undo-changes])) - (d/not-empty? (get-in state [:workspace-undo :transaction :redo-changes])))) - (accumulate-undo-entry state entry) + (cond + (and (get-in state [:workspace-undo :transaction]) + (or (not stack?) + (d/not-empty? (get-in state [:workspace-undo :transaction :undo-changes])) + (d/not-empty? (get-in state [:workspace-undo :transaction :redo-changes])))) + (accumulate-undo-entry state entry) - stack? - (stack-undo-entry state entry) + stack? + (stack-undo-entry state entry) - :else - (add-undo-entry state entry))))) + :else + (add-undo-entry state entry))))) (def empty-tx {:undo-changes [] :redo-changes []}) diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index 889f1c7f7..b6c8b2bf1 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -196,40 +196,40 @@ (if-not (exists? js/window) ;; If we are in the worker environment, we just mark it as loaded ;; without really loading it. - (do - (swap! loaded-hints conj {:font-id font-id :font-variant-id variant-id}) - (p/resolved font-id)) + (do + (swap! loaded-hints conj {:font-id font-id :font-variant-id variant-id}) + (p/resolved font-id)) - (let [font (get @fontsdb font-id)] - (cond - (nil? font) - (p/resolved font-id) + (let [font (get @fontsdb font-id)] + (cond + (nil? font) + (p/resolved font-id) ;; Font already loaded, we just continue - (contains? @loaded font-id) - (p/resolved font-id) + (contains? @loaded font-id) + (p/resolved font-id) ;; Font is currently downloading. We attach the caller to the promise - (contains? @loading font-id) - (p/resolved (get @loading font-id)) + (contains? @loading font-id) + (p/resolved (get @loading font-id)) ;; First caller, we create the promise and then wait - :else - (let [on-load (fn [resolve] - (swap! loaded conj font-id) - (swap! loading dissoc font-id) - (resolve font-id)) + :else + (let [on-load (fn [resolve] + (swap! loaded conj font-id) + (swap! loading dissoc font-id) + (resolve font-id)) - load-p (->> (p/create - (fn [resolve _] - (-> font - (assoc ::on-loaded (partial on-load resolve)) - (load-font)))) + load-p (->> (p/create + (fn [resolve _] + (-> font + (assoc ::on-loaded (partial on-load resolve)) + (load-font)))) ;; We need to wait for the font to be loaded - (p/delay 120))] + (p/delay 120))] - (swap! loading assoc font-id load-p) - load-p)))))) + (swap! loading assoc font-id load-p) + load-p)))))) (defn ready [cb] @@ -253,22 +253,22 @@ [node] (let [nodes (.from js/Array (dom/query-all node "[style*=font]")) result (.reduce nodes (fn [obj node] - (let [style (.-style node) - font-family (.-fontFamily style) - [_ font] (first - (filter (fn [[_ {:keys [id family]}]] - (or (= family font-family) - (= id font-family))) - @fontsdb)) - font-id (:id font) - font-variant (get-variant font (.-fontVariant style)) - font-variant-id (:id font-variant)] - (obj/set! - obj - (dm/str font-id ":" font-variant-id) - {:font-id font-id - :font-variant-id font-variant-id}))) - #js {})] + (let [style (.-style node) + font-family (.-fontFamily style) + [_ font] (first + (filter (fn [[_ {:keys [id family]}]] + (or (= family font-family) + (= id font-family))) + @fontsdb)) + font-id (:id font) + font-variant (get-variant font (.-fontVariant style)) + font-variant-id (:id font-variant)] + (obj/set! + obj + (dm/str font-id ":" font-variant-id) + {:font-id font-id + :font-variant-id font-variant-id}))) + #js {})] (.values js/Object result))) (defn get-content-fonts diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index c6bf57e9a..0e3e95429 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -339,53 +339,53 @@ {::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]} [{:keys [objects root-shape show-grids? zoom] :or {zoom 1} :as props}] (when root-shape - (let [root-shape-id (:id root-shape) - include-metadata (mf/use-ctx export/include-metadata-ctx) + (let [root-shape-id (:id root-shape) + include-metadata (mf/use-ctx export/include-metadata-ctx) - vector - (mf/use-memo - (mf/deps (:x root-shape) (:y root-shape)) - (fn [] - (-> (gpt/point (:x root-shape) (:y root-shape)) - (gpt/negate)))) + vector + (mf/use-memo + (mf/deps (:x root-shape) (:y root-shape)) + (fn [] + (-> (gpt/point (:x root-shape) (:y root-shape)) + (gpt/negate)))) - objects - (mf/use-memo - (mf/deps vector objects root-shape-id) - (fn [] - (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))] - (reduce update-fn objects children-ids)))) + objects + (mf/use-memo + (mf/deps vector objects root-shape-id) + (fn [] + (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))] + (reduce update-fn objects children-ids)))) - root-shape' (get objects root-shape-id) - width (* (:width root-shape') zoom) - height (* (:height root-shape') zoom) - vbox (format-viewbox {:width (:width root-shape' 0) - :height (:height root-shape' 0)}) - root-shape-wrapper - (mf/use-memo - (mf/deps objects root-shape') - (fn [] - (case (:type root-shape') - :group (group-wrapper-factory objects) - :frame (frame-wrapper-factory objects))))] + root-shape' (get objects root-shape-id) + width (* (:width root-shape') zoom) + height (* (:height root-shape') zoom) + vbox (format-viewbox {:width (:width root-shape' 0) + :height (:height root-shape' 0)}) + root-shape-wrapper + (mf/use-memo + (mf/deps objects root-shape') + (fn [] + (case (:type root-shape') + :group (group-wrapper-factory objects) + :frame (frame-wrapper-factory objects))))] - [:svg {:view-box vbox - :width (ust/format-precision width viewbox-decimal-precision) - :height (ust/format-precision height viewbox-decimal-precision) - :version "1.1" - :xmlns "http://www.w3.org/2000/svg" - :xmlnsXlink "http://www.w3.org/1999/xlink" - :xmlns:penpot (when include-metadata "https://penpot.app/xmlns") - :fill "none"} + [:svg {:view-box vbox + :width (ust/format-precision width viewbox-decimal-precision) + :height (ust/format-precision height viewbox-decimal-precision) + :version "1.1" + :xmlns "http://www.w3.org/2000/svg" + :xmlnsXlink "http://www.w3.org/1999/xlink" + :xmlns:penpot (when include-metadata "https://penpot.app/xmlns") + :fill "none"} - [:* - [:> shape-container {:shape root-shape'} - [:& (mf/provider muc/is-component?) {:value true} - [:& root-shape-wrapper {:shape root-shape' :view-box vbox}]]] + [:* + [:> shape-container {:shape root-shape'} + [:& (mf/provider muc/is-component?) {:value true} + [:& root-shape-wrapper {:shape root-shape' :view-box vbox}]]] - (when show-grids? - [:& empty-grids {:root-shape-id root-shape-id :objects objects}])]]))) + (when show-grids? + [:& empty-grids {:root-shape-id root-shape-id :objects objects}])]]))) (mf/defc component-svg-thumbnail {::mf/wrap [mf/memo #(mf/deferred % ts/idle-then-raf)]} diff --git a/frontend/src/app/main/repo.cljs b/frontend/src/app/main/repo.cljs index a38298143..56a49dd58 100644 --- a/frontend/src/app/main/repo.cljs +++ b/frontend/src/app/main/repo.cljs @@ -66,8 +66,7 @@ :form-data? true} :export-binfile {:response-type :blob} - :retrieve-list-of-builtin-templates {:query-params :all} - }) + :retrieve-list-of-builtin-templates {:query-params :all}}) (defn- send! "A simple helper for a common case of sending and receiving transit diff --git a/frontend/src/app/main/snap.cljs b/frontend/src/app/main/snap.cljs index 1b7cf7c9e..3cd6b7dc6 100644 --- a/frontend/src/app/main/snap.cljs +++ b/frontend/src/app/main/snap.cljs @@ -181,7 +181,7 @@ range-tree (- cd snap-distance-accuracy) (+ cd snap-distance-accuracy)) - (map #(- (first %) cd )))))))) + (map #(- (first %) cd)))))))) get-middle-snaps (fn [lt-dist gt-dist] diff --git a/frontend/src/app/main/store.cljs b/frontend/src/app/main/store.cljs index 46e77f4d7..7c162d030 100644 --- a/frontend/src/app/main/store.cljs +++ b/frontend/src/app/main/store.cljs @@ -43,7 +43,7 @@ (when (and *debug-events* (ptk/event? 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 (ptk/store {:resolve ptk/resolve diff --git a/frontend/src/app/main/style.clj b/frontend/src/app/main/style.clj index 5a64f57c9..1881d59d8 100644 --- a/frontend/src/app/main/style.clj +++ b/frontend/src/app/main/style.clj @@ -33,16 +33,16 @@ (def ^:private xform-css (keep (fn [k] - (cond - (keyword? k) - (let [knm (name k) - kns (namespace k)] - (case kns - "global" knm - (str *css-prefix* knm))) + (cond + (keyword? k) + (let [knm (name k) + kns (namespace k)] + (case kns + "global" knm + (str *css-prefix* knm))) - (string? k) - k)))) + (string? k) + k)))) (defmacro css* "Just coerces all params to strings and concats them with diff --git a/frontend/src/app/main/ui/auth/login.cljs b/frontend/src/app/main/ui/auth/login.cljs index abf47e040..9a710d9a8 100644 --- a/frontend/src/app/main/ui/auth/login.cljs +++ b/frontend/src/app/main/ui/auth/login.cljs @@ -40,18 +40,18 @@ (dom/prevent-default event) (->> (rp/cmd! :login-with-oidc (assoc params :provider provider)) (rx/subs! (fn [{:keys [redirect-uri] :as rsp}] - (if redirect-uri - (.replace js/location redirect-uri) - (log/error :hint "unexpected response from OIDC method" - :resp (pr-str rsp)))) - (fn [{:keys [type code] :as error}] - (cond - (and (= type :restriction) - (= code :provider-not-configured)) - (st/emit! (dm/error (tr "errors.auth-provider-not-configured"))) + (if redirect-uri + (.replace js/location redirect-uri) + (log/error :hint "unexpected response from OIDC method" + :resp (pr-str rsp)))) + (fn [{:keys [type code] :as error}] + (cond + (and (= type :restriction) + (= code :provider-not-configured)) + (st/emit! (dm/error (tr "errors.auth-provider-not-configured"))) - :else - (st/emit! (dm/error (tr "errors.generic")))))))) + :else + (st/emit! (dm/error (tr "errors.generic")))))))) (defn- login-with-ldap [event params] @@ -60,20 +60,20 @@ (let [{:keys [on-error]} (meta params)] (->> (rp/cmd! :login-with-ldap params) (rx/subs! (fn [profile] - (if-let [token (:invitation-token profile)] - (st/emit! (rt/nav :auth-verify-token {} {:token token})) - (st/emit! (du/login-from-token {:profile profile})))) - (fn [{:keys [type code] :as error}] - (cond - (and (= type :restriction) - (= code :ldap-not-initialized)) - (st/emit! (dm/error (tr "errors.ldap-disabled"))) + (if-let [token (:invitation-token profile)] + (st/emit! (rt/nav :auth-verify-token {} {:token token})) + (st/emit! (du/login-from-token {:profile profile})))) + (fn [{:keys [type code] :as error}] + (cond + (and (= type :restriction) + (= code :ldap-not-initialized)) + (st/emit! (dm/error (tr "errors.ldap-disabled"))) - (fn? on-error) - (on-error error) + (fn? on-error) + (on-error error) - :else - (st/emit! (dm/error (tr "errors.generic"))))))))) + :else + (st/emit! (dm/error (tr "errors.generic"))))))))) (s/def ::email ::us/email) (s/def ::password ::us/not-empty-string) diff --git a/frontend/src/app/main/ui/auth/register.cljs b/frontend/src/app/main/ui/auth/register.cljs index 573c98920..c200b4a4d 100644 --- a/frontend/src/app/main/ui/auth/register.cljs +++ b/frontend/src/app/main/ui/auth/register.cljs @@ -232,7 +232,7 @@ (->> (rp/cmd! :register-profile params) (rx/finalize #(reset! submitted? false)) (rx/subs! on-success - (partial handle-register-error form))))))] + (partial handle-register-error form))))))] [:& fm/form {:on-submit on-submit :form form} [:div {:class (stl/css :fields-row)} diff --git a/frontend/src/app/main/ui/comments.cljs b/frontend/src/app/main/ui/comments.cljs index 2e2c359b0..1147cf99a 100644 --- a/frontend/src/app/main/ui/comments.cljs +++ b/frontend/src/app/main/ui/comments.cljs @@ -28,7 +28,7 @@ [rumext.v2 :as mf])) (mf/defc resizing-textarea - {::mf/wrap-props false } + {::mf/wrap-props false} [props] (let [value (d/nilv (unchecked-get props "value") "") on-focus (unchecked-get props "on-focus") @@ -51,14 +51,14 @@ on-key-down (mf/use-fn - (mf/deps on-esc on-ctrl-enter on-change*) - (fn [event] - (cond - (and (kbd/esc? event) (fn? on-esc)) (on-esc event) - (and (kbd/mod? event) (kbd/enter? event) (fn? on-ctrl-enter)) - (do - (on-change* event) - (on-ctrl-enter event))))) + (mf/deps on-esc on-ctrl-enter on-change*) + (fn [event] + (cond + (and (kbd/esc? event) (fn? on-esc)) (on-esc event) + (and (kbd/mod? event) (kbd/enter? event) (fn? on-ctrl-enter)) + (do + (on-change* event) + (on-ctrl-enter event))))) on-focus* (mf/use-fn @@ -168,13 +168,13 @@ on-change (mf/use-fn (mf/deps draft) - (fn [content] - (st/emit! (dcm/update-draft-thread {:content content})))) + (fn [content] + (st/emit! (dcm/update-draft-thread {:content content})))) on-submit (mf/use-fn - (mf/deps draft) - (partial on-submit draft))] + (mf/deps draft) + (partial on-submit draft))] [:* [:div diff --git a/frontend/src/app/main/ui/components/buttons/simple_button.cljs b/frontend/src/app/main/ui/components/buttons/simple_button.cljs index 112971c6c..fb4bdd995 100644 --- a/frontend/src/app/main/ui/components/buttons/simple_button.cljs +++ b/frontend/src/app/main/ui/components/buttons/simple_button.cljs @@ -1,10 +1,10 @@ (ns app.main.ui.components.buttons.simple-button (:require-macros [app.main.style :as stl]) (:require - [rumext.v2 :as mf])) + [rumext.v2 :as mf])) (mf/defc simple-button {::mf/wrap-props false} [{:keys [on-click children]}] - [:button {:on-click on-click :class (stl/css :button)} children]) + [:button {:on-click on-click :class (stl/css :button)} children]) diff --git a/frontend/src/app/main/ui/components/color_bullet.cljs b/frontend/src/app/main/ui/components/color_bullet.cljs index 23be4183a..0b273aac2 100644 --- a/frontend/src/app/main/ui/components/color_bullet.cljs +++ b/frontend/src/app/main/ui/components/color_bullet.cljs @@ -37,11 +37,11 @@ (cond (:gradient color) [:div.color-bullet-wrapper {:style {:background (uc/color->background color)}}] - + (:image color) (let [uri (cfg/resolve-file-media (:image color))] [:div.color-bullet-wrapper {:style {:background-size "contain" :background-image (str/ffmt "url(%)" uri)}}]) - + :else [:div.color-bullet-wrapper [:div.color-bullet-left {:style {:background (uc/color->background (assoc color :opacity 1))}}] diff --git a/frontend/src/app/main/ui/components/color_input.cljs b/frontend/src/app/main/ui/components/color_input.cljs index 2f5777fa5..4130939b7 100644 --- a/frontend/src/app/main/ui/components/color_input.cljs +++ b/frontend/src/app/main/ui/components/color_input.cljs @@ -114,20 +114,20 @@ on-mouse-up (mf/use-fn - (fn [event] - (dom/prevent-default event))) + (fn [event] + (dom/prevent-default event))) handle-focus (mf/use-fn - (fn [event] - (let [target (dom/get-target event)] - (when on-focus - (on-focus event)) + (fn [event] + (let [target (dom/get-target event)] + (when on-focus + (on-focus event)) - (when select-on-focus? - (-> event (dom/get-target) (.select)) + (when select-on-focus? + (-> event (dom/get-target) (.select)) ;; 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) (obj/unset! "selectOnFocus") diff --git a/frontend/src/app/main/ui/components/forms.cljs b/frontend/src/app/main/ui/components/forms.cljs index 2187e81b7..88cd4fd42 100644 --- a/frontend/src/app/main/ui/components/forms.cljs +++ b/frontend/src/app/main/ui/components/forms.cljs @@ -361,17 +361,17 @@ (zero? (count @items))) klass (str (get props :class) " " - (stl/css-case - :focus @focus? - :valid (and touched? (not error)) - :invalid (and touched? error) - :empty empty? - :custom-multi-input true)) + (stl/css-case + :focus @focus? + :valid (and touched? (not error)) + :invalid (and touched? error) + :empty empty? + :custom-multi-input true)) in-klass (str class " " - (stl/css-case - :inside-input true - :no-padding (pos? (count @items)))) + (stl/css-case + :inside-input true + :no-padding (pos? (count @items)))) on-focus (mf/use-fn #(reset! focus? true)) @@ -481,7 +481,7 @@ (> (count value) length)) (defn validate-length - [field length errors-msg ] + [field length errors-msg] (fn [errors data] (cond-> errors (max-length? (get data field) length) @@ -500,6 +500,6 @@ (let [value (get data field)] (cond-> errors (and - (all-spaces? value) - (> (count value) 0)) + (all-spaces? value) + (> (count value) 0)) (assoc field {:message error-msg}))))) diff --git a/frontend/src/app/main/ui/components/link.cljs b/frontend/src/app/main/ui/components/link.cljs index 3e845628e..ad010f093 100644 --- a/frontend/src/app/main/ui/components/link.cljs +++ b/frontend/src/app/main/ui/components/link.cljs @@ -18,4 +18,4 @@ (keyboard-action event))) :tab-index "0" :data-test data-test} - [:* children]])) + [:* children]])) diff --git a/frontend/src/app/main/ui/components/search_bar.cljs b/frontend/src/app/main/ui/components/search_bar.cljs index 705bb3b4d..24f362cd2 100644 --- a/frontend/src/app/main/ui/components/search_bar.cljs +++ b/frontend/src/app/main/ui/components/search_bar.cljs @@ -46,7 +46,7 @@ (when ^boolean enter? (dom/blur! node)) (when ^boolean esc? (dom/blur! node)))))] [:span {:class (stl/css-case :search-box true - :has-children (some? children))} + :has-children (some? children))} children [:div {:class (stl/css :search-input-wrapper)} icon diff --git a/frontend/src/app/main/ui/components/tab_container.cljs b/frontend/src/app/main/ui/components/tab_container.cljs index be104cfcf..3f1aac1cd 100644 --- a/frontend/src/app/main/ui/components/tab_container.cljs +++ b/frontend/src/app/main/ui/components/tab_container.cljs @@ -50,7 +50,7 @@ (when (fn? on-change) (on-change id)))))] [: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? [:button {:on-click handle-collapse @@ -67,7 +67,7 @@ :data-id (d/name id) :on-click select-fn :class (stl/css-case :tab-container-tab-title true - :current (= selected id))} + :current (= selected id))} 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)]])) diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index ec956fa08..36aa4b7ef 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -43,7 +43,7 @@ team-id (get-in route [:params :path :team-id]) project-id (get-in route [:params :path :project-id])] (cond-> - {:search-term search-term} + {:search-term search-term} (uuid-str? team-id) (assoc :team-id (uuid team-id)) diff --git a/frontend/src/app/main/ui/dashboard/comments.cljs b/frontend/src/app/main/ui/dashboard/comments.cljs index fcc550251..aa55bddf8 100644 --- a/frontend/src/app/main/ui/dashboard/comments.cljs +++ b/frontend/src/app/main/ui/dashboard/comments.cljs @@ -75,9 +75,9 @@ (with-meta {::ev/origin "dashboard"})))))] (mf/use-effect - (mf/deps team-id) - (fn [] - (st/emit! (dcm/retrieve-unread-comment-threads team-id)))) + (mf/deps team-id) + (fn [] + (st/emit! (dcm/retrieve-unread-comment-threads team-id)))) (mf/use-effect (mf/deps show?) diff --git a/frontend/src/app/main/ui/dashboard/file_menu.cljs b/frontend/src/app/main/ui/dashboard/file_menu.cljs index d0ebba7aa..edda4f2f4 100644 --- a/frontend/src/app/main/ui/dashboard/file_menu.cljs +++ b/frontend/src/app/main/ui/dashboard/file_menu.cljs @@ -196,7 +196,7 @@ (->> (rp/cmd! :get-all-projects) (rx/map group-by-team) (rx/subs! #(when (mf/ref-val mounted-ref) - (reset! teams %))))))) + (reset! teams %))))))) (when current-team (let [sub-options (concat (vec (for [project current-projects] diff --git a/frontend/src/app/main/ui/dashboard/fonts.cljs b/frontend/src/app/main/ui/dashboard/fonts.cljs index 8a5d5a859..26519781f 100644 --- a/frontend/src/app/main/ui/dashboard/fonts.cljs +++ b/frontend/src/app/main/ui/dashboard/fonts.cljs @@ -67,9 +67,9 @@ (fn [blobs] (->> (df/process-upload blobs (:id team)) (rx/subs! (fn [result] - (swap! fonts df/merge-and-group-fonts installed-fonts result)) - (fn [error] - (js/console.error "error" error)))))) + (swap! fonts df/merge-and-group-fonts installed-fonts result)) + (fn [error] + (js/console.error "error" error)))))) on-upload (mf/use-callback @@ -79,11 +79,11 @@ (->> (rp/cmd! :create-font-variant item) (rx/delay-at-least 2000) (rx/subs! (fn [font] - (swap! fonts dissoc (:id item)) - (swap! uploading disj (:id item)) - (st/emit! (df/add-font font))) - (fn [error] - (js/console.log "error" error)))))) + (swap! fonts dissoc (:id item)) + (swap! uploading disj (:id item)) + (st/emit! (df/add-font font))) + (fn [error] + (js/console.log "error" error)))))) on-upload-all (fn [items] diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index 67dac1f45..b71bc1eb0 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -74,12 +74,12 @@ (when (and visible? (not thumbnail-uri)) (->> (ask-for-thumbnail file-id revn) (rx/subs! (fn [url] - (st/emit! (dd/set-file-thumbnail file-id url))) - (fn [cause] - (log/error :hint "unable to render thumbnail" - :file-if file-id - :revn revn - :message (ex-message cause))))))) + (st/emit! (dd/set-file-thumbnail file-id url))) + (fn [cause] + (log/error :hint "unable to render thumbnail" + :file-if file-id + :revn revn + :message (ex-message cause))))))) [:div {:class (stl/css :grid-item-th) :style {:background-color background-color} @@ -514,12 +514,12 @@ (do (dom/prevent-default e) (when-not (or (dnd/from-child? e) - (dnd/broken-event? e)) + (dnd/broken-event? e)) (when (not= selected-project project-id) (reset! dragging? true)))) (or (dnd/has-type? e "Files") - (dnd/has-type? e "application/x-moz-file")) + (dnd/has-type? e "application/x-moz-file")) (do (dom/prevent-default e) (reset! dragging? true))))) @@ -559,7 +559,7 @@ (st/emit! (dd/move-files (with-meta data mdata)))))) (or (dnd/has-type? e "Files") - (dnd/has-type? e "application/x-moz-file")) + (dnd/has-type? e "application/x-moz-file")) (do (dom/prevent-default e) (reset! dragging? false) diff --git a/frontend/src/app/main/ui/dashboard/project_menu.cljs b/frontend/src/app/main/ui/dashboard/project_menu.cljs index d5dc1d976..bd725a905 100644 --- a/frontend/src/app/main/ui/dashboard/project_menu.cljs +++ b/frontend/src/app/main/ui/dashboard/project_menu.cljs @@ -82,40 +82,40 @@ (when (fn? on-import) (on-import)))) options [(when-not (:is-default project) - {:option-name (tr "labels.rename") - :id "project-menu-rename" - :option-handler on-edit - :data-test "project-rename"}) - (when-not (:is-default project) - {:option-name (tr "dashboard.duplicate") - :id "project-menu-duplicated" - :option-handler on-duplicate - :data-test "project-duplicate"}) - (when-not (:is-default project) - {:option-name (tr "dashboard.pin-unpin") - :id "project-menu-pin" - :option-handler toggle-pin}) + {:option-name (tr "labels.rename") + :id "project-menu-rename" + :option-handler on-edit + :data-test "project-rename"}) + (when-not (:is-default project) + {:option-name (tr "dashboard.duplicate") + :id "project-menu-duplicated" + :option-handler on-duplicate + :data-test "project-duplicate"}) + (when-not (:is-default project) + {:option-name (tr "dashboard.pin-unpin") + :id "project-menu-pin" + :option-handler toggle-pin}) - (when (and (seq teams) (not (:is-default project))) - {:option-name (tr "dashboard.move-to") - :id "project-menu-move-to" - :sub-options (for [team teams] - {:option-name (:name team) - :id (:name team) - :option-handler (on-move (:id team))}) - :data-test "project-move-to"}) - (when (some? on-import) - {:option-name (tr "dashboard.import") - :id "project-menu-import" - :option-handler on-import-files - :data-test "file-import"}) - (when-not (:is-default project) - {:option-name :separator}) - (when-not (:is-default project) - {:option-name (tr "labels.delete") - :id "project-menu-delete" - :option-handler on-delete - :data-test "project-delete"})]] + (when (and (seq teams) (not (:is-default project))) + {:option-name (tr "dashboard.move-to") + :id "project-menu-move-to" + :sub-options (for [team teams] + {:option-name (:name team) + :id (:name team) + :option-handler (on-move (:id team))}) + :data-test "project-move-to"}) + (when (some? on-import) + {:option-name (tr "dashboard.import") + :id "project-menu-import" + :option-handler on-import-files + :data-test "file-import"}) + (when-not (:is-default project) + {:option-name :separator}) + (when-not (:is-default project) + {:option-name (tr "labels.delete") + :id "project-menu-delete" + :option-handler on-delete + :data-test "project-delete"})]] [:* [:& udi/import-form {:ref file-input diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 035385bb4..b9f059289 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -370,8 +370,8 @@ you-admin? (get-in team [:permissions :is-admin]) can-invite? (or you-owner? you-admin?) team-hero? (and can-invite? - (:team-hero? props true) - (not (:is-default team))) + (:team-hero? props true) + (not (:is-default team))) tutorial-viewed? (:viewed-tutorial? props true) walkthrough-viewed? (:viewed-walkthrough? props true) diff --git a/frontend/src/app/main/ui/dashboard/team.cljs b/frontend/src/app/main/ui/dashboard/team.cljs index 8a2f958a3..50a83cb30 100644 --- a/frontend/src/app/main/ui/dashboard/team.cljs +++ b/frontend/src/app/main/ui/dashboard/team.cljs @@ -949,7 +949,7 @@ (mf/with-effect [team] (st/emit! (dd/fetch-team-webhooks))) - [:* + [:* [:& header {:team team :section :dashboard-team-webhooks}] [:section {:class (stl/css :dashboard-container :dashboard-team-webhooks)} [:* diff --git a/frontend/src/app/main/ui/delete_shared.cljs b/frontend/src/app/main/ui/delete_shared.cljs index f51f62df1..c31b77bdf 100644 --- a/frontend/src/app/main/ui/delete_shared.cljs +++ b/frontend/src/app/main/ui/delete_shared.cljs @@ -5,7 +5,7 @@ ;; Copyright (c) KALEIDOS INC (ns app.main.ui.delete-shared - (:require-macros [app.main.style :as stl]) + (:require-macros [app.main.style :as stl]) (:require [app.common.data.macros :as dm] [app.main.data.modal :as modal] diff --git a/frontend/src/app/main/ui/export.cljs b/frontend/src/app/main/ui/export.cljs index 778d96885..90df53173 100644 --- a/frontend/src/app/main/ui/export.cljs +++ b/frontend/src/app/main/ui/export.cljs @@ -147,9 +147,9 @@ [:div {:class (stl/css :modal-footer)} [:div {:class (stl/css :action-buttons)} [:input {:class (stl/css :cancel-button) - :type "button" - :value (tr "labels.cancel") - :on-click cancel-fn}] + :type "button" + :value (tr "labels.cancel") + :on-click cancel-fn}] [:input {:class (stl/css-case :accept-btn true :btn-disabled (or in-progress? all-unchecked?)) diff --git a/frontend/src/app/main/ui/frame_preview.cljs b/frontend/src/app/main/ui/frame_preview.cljs index 12f3a0054..bff3da3ab 100644 --- a/frontend/src/app/main/ui/frame_preview.cljs +++ b/frontend/src/app/main/ui/frame_preview.cljs @@ -13,14 +13,14 @@ {::mf/wrap-props false ::mf/wrap [mf/memo]} [] - + (let [iframe-ref (mf/use-ref nil) last-data* (mf/use-state nil) zoom-ref (mf/use-ref nil) zoom* (mf/use-state 1) zoom @zoom* - + handle-load (mf/use-callback @@ -33,7 +33,7 @@ (-> iframe-dom .-contentWindow .-document .open) (-> iframe-dom .-contentWindow .-document (.write data)) (-> iframe-dom .-contentWindow .-document .close))))) - + load-ref (mf/use-callback (fn [iframe-dom] @@ -54,7 +54,7 @@ (fn [] (aset js/window "load" handle-load) #(js-delete js/window "load"))) - + [:div {:style {:display "flex" :width "100%" :height "100%" :flex-direction "column" :overflow "auto" :align-items "center"}} [:input {:id "zoom-input" :ref zoom-ref @@ -65,6 +65,6 @@ [:div {:style {:width "100%" :height "100%" :overflow "auto"}} [:iframe {:ref load-ref :frame-border "0" - :scrolling "no" + :scrolling "no" :style {:transform-origin "top left" :transform (str "scale(" zoom ")")}}]]])) diff --git a/frontend/src/app/main/ui/hooks.cljs b/frontend/src/app/main/ui/hooks.cljs index 79bf1fa81..b5a46415e 100644 --- a/frontend/src/app/main/ui/hooks.cljs +++ b/frontend/src/app/main/ui/hooks.cljs @@ -385,11 +385,11 @@ mnt? (volatile! true) sub (->> (wapi/observe-resize node) (rx/subs! (fn [entries] - (let [row (first entries) - row-rect (.-contentRect ^js row) - row-width (.-width ^js row-rect)] - (when @mnt? - (reset! width* row-width))))))] + (let [row (first entries) + row-rect (.-contentRect ^js row) + row-width (.-width ^js row-rect)] + (when @mnt? + (reset! width* row-width))))))] (fn [] (vreset! mnt? false) (rx/dispose! sub)))) diff --git a/frontend/src/app/main/ui/measurements.cljs b/frontend/src/app/main/ui/measurements.cljs index f1245d86d..057794e30 100644 --- a/frontend/src/app/main/ui/measurements.cljs +++ b/frontend/src/app/main/ui/measurements.cljs @@ -96,18 +96,18 @@ (or (and (neg? ss) (pos? se)) (and (pos? ss) (neg? ee)) (and (neg? ss) (> ss se))) - (conj [ from-s (+ from-s ss) ]) + (conj [from-s (+ from-s ss)]) (and (neg? se) (<= ss se)) - (conj [ from-s (+ from-s se) ]) + (conj [from-s (+ from-s se)]) (and (pos? es) (<= es ee)) - (conj [ from-e (+ from-e es) ]) + (conj [from-e (+ from-e es)]) (or (and (pos? ee) (neg? es)) (and (neg? ee) (pos? ss)) (and (pos? ee) (< ee es))) - (conj [ from-e (+ from-e ee) ])))) + (conj [from-e (+ from-e ee)])))) ;; ------------------------------------------------ ;; COMPONENTS @@ -383,9 +383,9 @@ pill-width (/ flex-display-pill-width zoom) pill-height (/ flex-display-pill-height zoom) hover? #(or hover-all? - (and (or (= % :p1) (= % :p3)) hover-v?) - (and (or (= % :p2) (= % :p4)) hover-h?) - (= @hover %)) + (and (or (= % :p1) (= % :p3)) hover-v?) + (and (or (= % :p2) (= % :p4)) hover-h?) + (= @hover %)) negate {:p1 (if (:flip-y frame) true false) :p2 (if (:flip-x frame) true false) :p3 (if (:flip-y frame) true false) @@ -459,7 +459,7 @@ :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 - rect-data hover? selected? mouse-pos hover-value]}] + rect-data hover? selected? mouse-pos hover-value]}] (let [resizing? (mf/use-var false) start (mf/use-var nil) original-value (mf/use-var 0) @@ -582,7 +582,7 @@ :resize-negate? (:flip-x frame)}}] [:g.margins {:pointer-events "visible"} - (for [[margin-num rect-data] margin-display-data] + (for [[margin-num rect-data] margin-display-data] [:& margin-display {:key (:key rect-data) :shape-id shape-id @@ -611,7 +611,7 @@ :value @hover-value}])])) (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) start (mf/use-var nil) original-value (mf/use-var 0) @@ -654,19 +654,19 @@ (reset! hover-value val) (st/emit! (dwm/set-modifiers modifiers)))))))] - [:rect.gap-rect {:x (:x rect-data) - :y (:y rect-data) - :width (:width rect-data) - :height (:height rect-data) - :on-pointer-enter on-pointer-enter - :on-pointer-leave on-pointer-leave - :on-pointer-down on-pointer-down - :on-lost-pointer-capture on-lost-pointer-capture - :on-pointer-move on-pointer-move - :class (when (or hover? selected?) - (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") - :opacity (if selected? 0.5 0.25)}}])) + [:rect.gap-rect {:x (:x rect-data) + :y (:y rect-data) + :width (:width rect-data) + :height (:height rect-data) + :on-pointer-enter on-pointer-enter + :on-pointer-leave on-pointer-leave + :on-pointer-down on-pointer-down + :on-lost-pointer-capture on-lost-pointer-capture + :on-pointer-move on-pointer-move + :class (when (or hover? selected?) + (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") + :opacity (if selected? 0.5 0.25)}}])) (mf/defc gap-rects [{:keys [frame zoom]}] (let [frame-id (:id frame) diff --git a/frontend/src/app/main/ui/onboarding/questions.cljs b/frontend/src/app/main/ui/onboarding/questions.cljs index 4f9a61215..cead11ff4 100644 --- a/frontend/src/app/main/ui/onboarding/questions.cljs +++ b/frontend/src/app/main/ui/onboarding/questions.cljs @@ -93,7 +93,7 @@ (s/def ::questions-form-step-3 (s/keys :req-un [::experience-design-tool] - :opt-un[::experience-design-tool-other])) + :opt-un [::experience-design-tool-other])) (defn- step-3-form-validator [errors data] @@ -134,7 +134,7 @@ (s/def ::questions-form-step-4 (s/keys :req-un [::team-size ::role] - :opt-un [::role-other])) + :opt-un [::role-other])) (defn- step-4-form-validator [errors data] diff --git a/frontend/src/app/main/ui/onboarding/templates.cljs b/frontend/src/app/main/ui/onboarding/templates.cljs index 1744f69c7..af0abb2b1 100644 --- a/frontend/src/app/main/ui/onboarding/templates.cljs +++ b/frontend/src/app/main/ui/onboarding/templates.cljs @@ -40,11 +40,11 @@ (reset! downloading? true) (->> (http/send! {:method :get :uri link :response-type :blob :mode :no-cors}) (rx/subs! (fn [{:keys [body] :as response}] - (open-import-modal {:name name :uri (wapi/create-uri body)})) - (fn [error] - (js/console.log "error" error)) - (fn [] - (reset! downloading? false)))))] + (open-import-modal {:name name :uri (wapi/create-uri body)})) + (fn [error] + (js/console.log "error" error)) + (fn [] + (reset! downloading? false)))))] [:div.template-item [:div.template-item-content diff --git a/frontend/src/app/main/ui/routes.cljs b/frontend/src/app/main/ui/routes.cljs index 1a796f32d..eeb5f156c 100644 --- a/frontend/src/app/main/ui/routes.cljs +++ b/frontend/src/app/main/ui/routes.cljs @@ -113,15 +113,15 @@ ;; invitations workflows (and probably other cases). (->> (rp/cmd! :get-profile) (rx/subs! (fn [{:keys [id] :as profile}] - (cond - (= id uuid/zero) - (st/emit! (rt/nav :auth-login)) + (cond + (= id uuid/zero) + (st/emit! (rt/nav :auth-login)) - empty-path? - (st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)})) + empty-path? + (st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)})) - :else - (st/emit! (rt/assign-exception {:type :not-found}))))))))) + :else + (st/emit! (rt/assign-exception {:type :not-found}))))))))) (defn init-routes [] diff --git a/frontend/src/app/main/ui/settings/change_email.cljs b/frontend/src/app/main/ui/settings/change_email.cljs index 37d4f54c7..f50a7bf6d 100644 --- a/frontend/src/app/main/ui/settings/change_email.cljs +++ b/frontend/src/app/main/ui/settings/change_email.cljs @@ -89,13 +89,13 @@ on-email-change (mf/use-callback - (fn [_ _] - (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-2 (dma/get-in @form [:clean-data :email-2])] - (println "different-emails-error?" (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])))))] + (fn [_ _] + (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-2 (dma/get-in @form [:clean-data :email-2])] + (println "different-emails-error?" (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])))))] [:div {:class (stl/css :modal-overlay)} [:div {:class (stl/css :modal-container)} @@ -134,8 +134,7 @@ [:div {:class (stl/css :action-buttons) :data-test "change-email-submit"} [:> fm/submit-button* - {:label (tr "modals.change-email.submit")}]]]]]] - )) + {:label (tr "modals.change-email.submit")}]]]]]])) diff --git a/frontend/src/app/main/ui/settings/options.cljs b/frontend/src/app/main/ui/settings/options.cljs index 34b539a84..075bb2bfa 100644 --- a/frontend/src/app/main/ui/settings/options.cljs +++ b/frontend/src/app/main/ui/settings/options.cljs @@ -75,11 +75,11 @@ (mf/defc options-page [] - (mf/use-effect - #(dom/set-html-title (tr "title.settings.options"))) + (mf/use-effect + #(dom/set-html-title (tr "title.settings.options"))) - [:div {:class (stl/css :dashboard-settings)} - [:div {:class (stl/css :form-container) :data-test "settings-form"} - [:h2 (tr "labels.settings")] - [:& options-form {}]]]) + [:div {:class (stl/css :dashboard-settings)} + [:div {:class (stl/css :form-container) :data-test "settings-form"} + [:h2 (tr "labels.settings")] + [:& options-form {}]]]) diff --git a/frontend/src/app/main/ui/settings/sidebar.cljs b/frontend/src/app/main/ui/settings/sidebar.cljs index c82664b11..c9dbcb678 100644 --- a/frontend/src/app/main/ui/settings/sidebar.cljs +++ b/frontend/src/app/main/ui/settings/sidebar.cljs @@ -30,42 +30,42 @@ go-dashboard (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))) + (mf/deps profile) + #(st/emit! (rt/nav :dashboard-projects {:team-id (du/get-current-team-id profile)}))) go-settings-profile (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :settings-profile))) + (mf/deps profile) + #(st/emit! (rt/nav :settings-profile))) go-settings-feedback (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :settings-feedback))) + (mf/deps profile) + #(st/emit! (rt/nav :settings-feedback))) go-settings-password (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :settings-password))) + (mf/deps profile) + #(st/emit! (rt/nav :settings-password))) go-settings-options (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :settings-options))) + (mf/deps profile) + #(st/emit! (rt/nav :settings-options))) go-settings-access-tokens (mf/use-callback - (mf/deps profile) - #(st/emit! (rt/nav :settings-access-tokens))) + (mf/deps profile) + #(st/emit! (rt/nav :settings-access-tokens))) show-release-notes (mf/use-callback - (fn [event] - (let [version (:main cf/version)] - (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) - (if (and (kbd/alt? event) (kbd/mod? event)) - (st/emit! (modal/show {:type :onboarding})) - (st/emit! (modal/show {:type :release-notes :version version}))))))] + (fn [event] + (let [version (:main cf/version)] + (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) + (if (and (kbd/alt? event) (kbd/mod? event)) + (st/emit! (modal/show {:type :onboarding})) + (st/emit! (modal/show {:type :release-notes :version version}))))))] [:div {:class (stl/css :sidebar-content)} [:div {:class (stl/css :sidebar-content-section)} diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 707d40719..d7daebf3b 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -144,7 +144,7 @@ (not= caps-start caps-end))) (obj/set! attrs "markerEnd" (str/ffmt "url(#marker-%-%)" render-id (name caps-end)))))))) - attrs)) + attrs)) (defn add-layer-styles! [props shape] @@ -197,15 +197,15 @@ (add-layer-styles! shape)) url-fill? (or ^boolean (some? (:fill-image shape)) - ^boolean (cfh/image-shape? shape) - ^boolean (> (count shape-fills) 1) - ^boolean (some? (some :fill-color-gradient shape-fills)) - ^boolean (some? (some :fill-image shape-fills))) + ^boolean (cfh/image-shape? shape) + ^boolean (> (count shape-fills) 1) + ^boolean (some? (some :fill-color-gradient shape-fills)) + ^boolean (some? (some :fill-image shape-fills))) props (if (cfh/frame-shape? shape) props (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)) props))] @@ -219,9 +219,9 @@ ;; reset to normal if a Penpot frame shape appears below ;; (see main.ui.shapes.frame/frame-container). (and ^boolean (contains? shape :svg-attrs) - ^boolean (or ^boolean (= :svg-raw shape-type) - ^boolean (= :group shape-type)) - ^boolean (empty? shape-fills)) + ^boolean (or ^boolean (= :svg-raw shape-type) + ^boolean (= :group shape-type)) + ^boolean (empty? shape-fills)) (let [wstyle (get shape :wrapper-styles) fill (obj/get wstyle "fill") fill (d/nilv fill clr/black)] @@ -234,7 +234,7 @@ (obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id))) (and ^boolean (some? svg-styles) - ^boolean (obj/contains? svg-styles "fill")) + ^boolean (obj/contains? svg-styles "fill")) (let [fill (obj/get svg-styles "fill") opacity (obj/get svg-styles "fillOpacity")] (when (some? fill) @@ -243,7 +243,7 @@ (obj/set! style "fillOpacity" opacity))) (and ^boolean (some? svg-attrs) - ^boolean (empty? shape-fills)) + ^boolean (empty? shape-fills)) (let [fill (obj/get svg-attrs "fill") opacity (obj/get svg-attrs "fillOpacity")] (when (some? fill) @@ -256,7 +256,7 @@ (obj/merge! style (get-fill-style fill render-id 0 shape-type))) (and ^boolean (cfh/path-shape? shape) - ^boolean (empty? shape-fills)) + ^boolean (empty? shape-fills)) (obj/set! style "fill" "none")) (-> props diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index d44af4ac6..91d4586ae 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -105,106 +105,106 @@ (:stroke-opacity stroke))] [:* - (when (or (= cap-start :line-arrow) - (= cap-end :line-arrow)) - [:marker {:id (dm/str id-prefix "-line-arrow") - :viewBox "0 0 3 6" - :refX "2" - :refY "3" - :markerWidth "8.5" - :markerHeight "8.5" - :orient "auto-start-reverse" - :fill color - :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"}]]) + (when (or (= cap-start :line-arrow) + (= cap-end :line-arrow)) + [:marker {:id (dm/str id-prefix "-line-arrow") + :viewBox "0 0 3 6" + :refX "2" + :refY "3" + :markerWidth "8.5" + :markerHeight "8.5" + :orient "auto-start-reverse" + :fill color + :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"}]]) - (when (or (= cap-start :triangle-arrow) - (= cap-end :triangle-arrow)) - [:marker {:id (dm/str id-prefix "-triangle-arrow") - :viewBox "0 0 3 6" - :refX "2" - :refY "3" - :markerWidth "8.5" - :markerHeight "8.5" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:path {:d "M 0 0 L 3 3 L 0 6 z"}]]) + (when (or (= cap-start :triangle-arrow) + (= cap-end :triangle-arrow)) + [:marker {:id (dm/str id-prefix "-triangle-arrow") + :viewBox "0 0 3 6" + :refX "2" + :refY "3" + :markerWidth "8.5" + :markerHeight "8.5" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [:path {:d "M 0 0 L 3 3 L 0 6 z"}]]) - (when (or (= cap-start :square-marker) - (= cap-end :square-marker)) - [:marker {:id (dm/str id-prefix "-square-marker") - :viewBox "0 0 6 6" - :refX "3" - :refY "3" - :markerWidth "4.2426" ;; diagonal length of a 3x3 square - :markerHeight "4.2426" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:rect {:x 0 :y 0 :width 6 :height 6}]]) + (when (or (= cap-start :square-marker) + (= cap-end :square-marker)) + [:marker {:id (dm/str id-prefix "-square-marker") + :viewBox "0 0 6 6" + :refX "3" + :refY "3" + :markerWidth "4.2426" ;; diagonal length of a 3x3 square + :markerHeight "4.2426" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [:rect {:x 0 :y 0 :width 6 :height 6}]]) - (when (or (= cap-start :circle-marker) - (= cap-end :circle-marker)) - [:marker {:id (dm/str id-prefix "-circle-marker") - :viewBox "0 0 6 6" - :refX "3" - :refY "3" - :markerWidth "4" - :markerHeight "4" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:circle {:cx "3" :cy "3" :r "3"}]]) + (when (or (= cap-start :circle-marker) + (= cap-end :circle-marker)) + [:marker {:id (dm/str id-prefix "-circle-marker") + :viewBox "0 0 6 6" + :refX "3" + :refY "3" + :markerWidth "4" + :markerHeight "4" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [:circle {:cx "3" :cy "3" :r "3"}]]) - (when (or (= cap-start :diamond-marker) - (= cap-end :diamond-marker)) - [:marker {:id (dm/str id-prefix "-diamond-marker") - :viewBox "0 0 6 6" - :refX "3" - :refY "3" - :markerWidth "6" - :markerHeight "6" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:path {:d "M 3 0 L 6 3 L 3 6 L 0 3 z"}]]) + (when (or (= cap-start :diamond-marker) + (= cap-end :diamond-marker)) + [:marker {:id (dm/str id-prefix "-diamond-marker") + :viewBox "0 0 6 6" + :refX "3" + :refY "3" + :markerWidth "6" + :markerHeight "6" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [: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, ;; simulate it with markers. - (when (and (or (= cap-start :round) - (= cap-end :round)) - (not= cap-start cap-end)) - [:marker {:id (dm/str id-prefix "-round") - :viewBox "0 0 6 6" - :refX "3" - :refY "3" - :markerWidth "6" - :markerHeight "6" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:path {:d "M 3 2.5 A 0.5 0.5 0 0 1 3 3.5 "}]]) + (when (and (or (= cap-start :round) + (= cap-end :round)) + (not= cap-start cap-end)) + [:marker {:id (dm/str id-prefix "-round") + :viewBox "0 0 6 6" + :refX "3" + :refY "3" + :markerWidth "6" + :markerHeight "6" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [:path {:d "M 3 2.5 A 0.5 0.5 0 0 1 3 3.5 "}]]) - (when (and (or (= cap-start :square) - (= cap-end :square)) - (not= cap-start cap-end)) - [:marker {:id (dm/str id-prefix "-square") - :viewBox "0 0 6 6" - :refX "3" - :refY "3" - :markerWidth "6" - :markerHeight "6" - :orient "auto-start-reverse" - :fill color - :fillOpacity opacity} - [:rect {:x 3 :y 2.5 :width 0.5 :height 1}]])])) + (when (and (or (= cap-start :square) + (= cap-end :square)) + (not= cap-start cap-end)) + [:marker {:id (dm/str id-prefix "-square") + :viewBox "0 0 6 6" + :refX "3" + :refY "3" + :markerWidth "6" + :markerHeight "6" + :orient "auto-start-reverse" + :fill color + :fillOpacity opacity} + [:rect {:x 3 :y 2.5 :width 0.5 :height 1}]])])) (mf/defc stroke-defs {::mf/wrap-props false} [{:keys [shape stroke render-id index]}] (let [open-path? (and ^boolean (cfh/path-shape? shape) - ^boolean (gsh/open-path? shape)) + ^boolean (gsh/open-path? shape)) gradient (:stroke-color-gradient stroke) alignment (:stroke-alignment stroke :center) width (:stroke-width stroke 0) @@ -487,11 +487,11 @@ props (cond-> props (and (some? shape-blur) - (not ^boolean (:hidden shape-blur))) + (not ^boolean (:hidden shape-blur))) (obj/set! "filter" (dm/fmt "url(#filter-blur-%)" render-id)) (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))))] (when (d/not-empty? shape-strokes) diff --git a/frontend/src/app/main/ui/shapes/embed.cljs b/frontend/src/app/main/ui/shapes/embed.cljs index 4e9fe7d49..218b9687b 100644 --- a/frontend/src/app/main/ui/shapes/embed.cljs +++ b/frontend/src/app/main/ui/shapes/embed.cljs @@ -38,9 +38,9 @@ (url-mapping) (rx/reduce conj {}) (rx/subs! (fn [data] - (when-not (= data (mf/ref-val uri-data)) - (mf/set-ref-val! uri-data data) - (reset! state inc)))))] + (when-not (= data (mf/ref-val uri-data)) + (mf/set-ref-val! uri-data data) + (reset! state inc)))))] #(when sub (rx/dispose! sub))))) diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index fde3f2fdd..959be058f 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -169,10 +169,10 @@ (mf/defc export-flows [{:keys [flows]}] [:> "penpot:flows" #js {} - (for [{:keys [id name starting-frame]} flows] - [:> "penpot:flow" #js {:id id - :name name - :starting-frame starting-frame}])]) + (for [{:keys [id name starting-frame]} flows] + [:> "penpot:flow" #js {:id id + :name name + :starting-frame starting-frame}])]) (mf/defc export-guides [{:keys [guides]}] @@ -253,7 +253,7 @@ [:* (when (contains? shape :svg-attrs) (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 ","))] [:> "penpot:svg-import" #js {:penpot:svg-attrs (when-not (empty? svg-attrs) svg-attrs) @@ -292,47 +292,47 @@ (when-let [fills (seq fills)] (let [render-id (mf/use-ctx muc/render-id)] (mf/html - [:> "penpot:fills" #js {} - (for [[index fill] (d/enumerate fills)] - (let [fill-image-id (dm/str "fill-image-" render-id "-" index)] - [:> "penpot:fill" - #js {:penpot:fill-color (cond - (some? (:fill-color-gradient fill)) - (str/format "url(#%s)" (str "fill-color-gradient-" render-id "-" index)) + [:> "penpot:fills" #js {} + (for [[index fill] (d/enumerate fills)] + (let [fill-image-id (dm/str "fill-image-" render-id "-" index)] + [:> "penpot:fill" + #js {:penpot:fill-color (cond + (some? (:fill-color-gradient fill)) + (str/format "url(#%s)" (str "fill-color-gradient-" render-id "-" index)) - :else - (d/name (:fill-color fill))) - :key (swap! internal-counter inc) + :else + (d/name (:fill-color fill))) + :key (swap! internal-counter inc) - :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-id (d/name (:fill-color-ref-id fill)) - :penpot:fill-opacity (d/name (:fill-opacity fill))}]))])))) + :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-id (d/name (:fill-color-ref-id fill)) + :penpot:fill-opacity (d/name (:fill-opacity fill))}]))])))) (defn- export-strokes-data [{:keys [strokes]}] (when-let [strokes (seq strokes)] (let [render-id (mf/use-ctx muc/render-id)] (mf/html - [:> "penpot:strokes" #js {} - (for [[index stroke] (d/enumerate strokes)] - (let [stroke-image-id (dm/str "stroke-image-" render-id "-" index)] - [:> "penpot:stroke" - #js {:penpot:stroke-color (cond - (some? (:stroke-color-gradient stroke)) - (str/format "url(#%s)" (str "stroke-color-gradient-" render-id "-" index)) + [:> "penpot:strokes" #js {} + (for [[index stroke] (d/enumerate strokes)] + (let [stroke-image-id (dm/str "stroke-image-" render-id "-" index)] + [:> "penpot:stroke" + #js {:penpot:stroke-color (cond + (some? (:stroke-color-gradient stroke)) + (str/format "url(#%s)" (str "stroke-color-gradient-" render-id "-" index)) - :else - (d/name (:stroke-color stroke))) - :key (swap! internal-counter inc) - :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-id (d/name (:stroke-color-ref-id stroke)) - :penpot:stroke-opacity (d/name (:stroke-opacity stroke)) - :penpot:stroke-style (d/name (:stroke-style stroke)) - :penpot:stroke-width (d/name (:stroke-width stroke)) - :penpot:stroke-alignment (d/name (:stroke-alignment stroke)) - :penpot:stroke-cap-start (d/name (:stroke-cap-start stroke)) - :penpot:stroke-cap-end (d/name (:stroke-cap-end stroke))}]))])))) + :else + (d/name (:stroke-color stroke))) + :key (swap! internal-counter inc) + :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-id (d/name (:stroke-color-ref-id stroke)) + :penpot:stroke-opacity (d/name (:stroke-opacity stroke)) + :penpot:stroke-style (d/name (:stroke-style stroke)) + :penpot:stroke-width (d/name (:stroke-width stroke)) + :penpot:stroke-alignment (d/name (:stroke-alignment stroke)) + :penpot:stroke-cap-start (d/name (:stroke-cap-start stroke)) + :penpot:stroke-cap-end (d/name (:stroke-cap-end stroke))}]))])))) (defn- export-interactions-data [{:keys [interactions]}] (when-let [interactions (seq interactions)] diff --git a/frontend/src/app/main/ui/shapes/fills.cljs b/frontend/src/app/main/ui/shapes/fills.cljs index cea64f7ca..0abc32400 100644 --- a/frontend/src/app/main/ui/shapes/fills.cljs +++ b/frontend/src/app/main/ui/shapes/fills.cljs @@ -35,7 +35,7 @@ height (dm/get-prop selrect :height) has-image? (or (some? metadata) - (some? image)) + (some? image)) uri (cond (some? metadata) @@ -45,10 +45,10 @@ (cf/resolve-file-media image)) uris (into [uri] - (comp - (keep :fill-image) - (map cf/resolve-file-media)) - fills) + (comp + (keep :fill-image) + (map cf/resolve-file-media)) + fills) transform (gsh/transform-str shape) @@ -59,8 +59,8 @@ :height height} pat-props (if (= :path type) - (obj/set! pat-props "patternTransform" transform) - pat-props)] + (obj/set! pat-props "patternTransform" transform) + pat-props)] (for [[shape-index shape] (d/enumerate (or (:position-data shape) [shape]))] [:* {:key (dm/str shape-index)} diff --git a/frontend/src/app/main/ui/shapes/mask.cljs b/frontend/src/app/main/ui/shapes/mask.cljs index 3438a8444..250b7bd40 100644 --- a/frontend/src/app/main/ui/shapes/mask.cljs +++ b/frontend/src/app/main/ui/shapes/mask.cljs @@ -60,8 +60,8 @@ points (dm/get-prop mask :points) points-str (mf/with-memo [points] - (->> (map point->str points) - (str/join " "))) + (->> (map point->str points) + (str/join " "))) bounds (mf/with-memo [points] (grc/points->rect points)) diff --git a/frontend/src/app/main/ui/shapes/path.cljs b/frontend/src/app/main/ui/shapes/path.cljs index 424265f27..f44d43042 100644 --- a/frontend/src/app/main/ui/shapes/path.cljs +++ b/frontend/src/app/main/ui/shapes/path.cljs @@ -22,9 +22,9 @@ (upf/format-path content) (catch :default e (log/error :hint "unexpected error on formatting path" - :shape-name (:name shape) - :shape-id (:id shape) - :cause e) + :shape-name (:name shape) + :shape-id (:id shape) + :cause e) ""))) props (-> #js {} diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs index 081cf2297..50092747c 100644 --- a/frontend/src/app/main/ui/shapes/svg_defs.cljs +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -59,11 +59,11 @@ (= :group type)) (update :className #(if % (dm/str % " svg-def") "svg-def"))) (cond-> - transform-gradient? (add-matrix :gradientTransform transform) - transform-pattern? (add-matrix :patternTransform transform) - transform-clippath? (add-matrix :transform transform) - (or transform-filter? - transform-mask?) (merge bounds))) + transform-gradient? (add-matrix :gradientTransform transform) + transform-pattern? (add-matrix :patternTransform transform) + transform-clippath? (add-matrix :transform transform) + (or transform-filter? + transform-mask?) (merge bounds))) ;; Fixes race condition with dynamic modifiers forcing redraw this properties before ;; the effect triggers diff --git a/frontend/src/app/main/ui/shapes/svg_raw.cljs b/frontend/src/app/main/ui/shapes/svg_raw.cljs index 4a5642884..21f8c1951 100644 --- a/frontend/src/app/main/ui/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/shapes/svg_raw.cljs @@ -83,7 +83,7 @@ (usa/add-fill-props! shape render-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))) props))] diff --git a/frontend/src/app/main/ui/shapes/text/fo_text.cljs b/frontend/src/app/main/ui/shapes/text/fo_text.cljs index f1241238d..8e2b1e528 100644 --- a/frontend/src/app/main/ui/shapes/text/fo_text.cljs +++ b/frontend/src/app/main/ui/shapes/text/fo_text.cljs @@ -196,7 +196,7 @@ ;; We use a class here because react has a bug that won't use the appropriate selector for ;; `background-clip` [:style ".text-node { background-clip: text; - -webkit-background-clip: text; }" ] + -webkit-background-clip: text; }"] [:& render-node {:index 0 :shape shape :node content}]])) diff --git a/frontend/src/app/main/ui/shapes/text/html_text.cljs b/frontend/src/app/main/ui/shapes/text/html_text.cljs index 859228157..da23426c2 100644 --- a/frontend/src/app/main/ui/shapes/text/html_text.cljs +++ b/frontend/src/app/main/ui/shapes/text/html_text.cljs @@ -121,7 +121,7 @@ ;; `background-clip` (when (not code?) [:style ".text-node { background-clip: text; - -webkit-background-clip: text; }" ]) + -webkit-background-clip: text; }"]) [:& render-node {:index 0 :shape shape :node content diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index 2f86b0bce..90243b917 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -121,7 +121,7 @@ [{:keys [section index users frame page]}] (let [comments-local (mf/deref refs/comments-local) show-sidebar? (and (= section :comments) (:show-sidebar? comments-local))] - [:* + [:* [:& viewer-pagination {:index index :num-frames (count (:frames page)) diff --git a/frontend/src/app/main/ui/viewer/comments.cljs b/frontend/src/app/main/ui/viewer/comments.cljs index 2514fbb14..1372696fe 100644 --- a/frontend/src/app/main/ui/viewer/comments.cljs +++ b/frontend/src/app/main/ui/viewer/comments.cljs @@ -40,7 +40,7 @@ (let [mode (-> (dom/get-current-target event) (dom/get-data "value") (keyword))] - (st/emit! (dcm/update-filters {:mode mode}))))) + (st/emit! (dcm/update-filters {:mode mode}))))) update-show (mf/use-callback @@ -48,7 +48,7 @@ (let [mode (-> (dom/get-current-target event) (dom/get-data "value") (d/read-string))] - (st/emit! (dcm/update-filters {:show mode}))))) + (st/emit! (dcm/update-filters {:show mode}))))) update-options (mf/use-callback diff --git a/frontend/src/app/main/ui/viewer/header.cljs b/frontend/src/app/main/ui/viewer/header.cljs index ab5933155..b168cad56 100644 --- a/frontend/src/app/main/ui/viewer/header.cljs +++ b/frontend/src/app/main/ui/viewer/header.cljs @@ -275,13 +275,13 @@ (mf/use-fn (mf/deps permissions) (fn [event] - (let [section (-> (dom/get-current-target event) - (dom/get-data "value") - (keyword))] + (let [section (-> (dom/get-current-target event) + (dom/get-data "value") + (keyword))] - (if (or (= section :interactions) (:is-logged permissions)) - (st/emit! (dv/go-to-section section)) - (open-login-dialog)))))] + (if (or (= section :interactions) (:is-logged permissions)) + (st/emit! (dv/go-to-section section)) + (open-login-dialog)))))] [:header {:class (stl/css :viewer-header)} [:div {:class (stl/css :nav-zone)} diff --git a/frontend/src/app/main/ui/viewer/inspect.cljs b/frontend/src/app/main/ui/viewer/inspect.cljs index d65351834..b2397d30b 100644 --- a/frontend/src/app/main/ui/viewer/inspect.cljs +++ b/frontend/src/app/main/ui/viewer/inspect.cljs @@ -80,7 +80,7 @@ handle-expand (mf/use-callback (mf/deps right-size) - (fn[] + (fn [] (set-right-size (if (> right-size 276) 276 768))))] (mf/use-effect on-mount) diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index 4f9886d28..8074ca7bc 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -148,7 +148,7 @@ (if (= (:type shape) :frame) ;; manual interactions are always from "self" (:frame-id shape) (:id shape)) - (:position-relative-to interaction)) + (:position-relative-to interaction)) relative-to-shape (or (get objects relative-to-id) base-frame) overlays-ids (set (map :id overlays)) 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" [component] (mf/fnc generic-wrapper - {::mf/wrap-props false} - [props] - (let [shape (unchecked-get props "shape") - childs (unchecked-get props "childs") - frame (unchecked-get props "frame") - objects (unchecked-get props "objects") - all-objects (or (unchecked-get props "all-objects") objects) - base-frame (mf/use-ctx base-frame-ctx) - frame-offset (mf/use-ctx frame-offset-ctx) - interactions-show? (mf/deref viewer-interactions-show?) - overlays (mf/deref refs/viewer-overlays) - interactions (:interactions shape) - svg-element? (and (= :svg-raw (:type shape)) - (not= :svg (get-in shape [:content :tag]))) + {::mf/wrap-props false} + [props] + (let [shape (unchecked-get props "shape") + childs (unchecked-get props "childs") + frame (unchecked-get props "frame") + objects (unchecked-get props "objects") + all-objects (or (unchecked-get props "all-objects") objects) + base-frame (mf/use-ctx base-frame-ctx) + frame-offset (mf/use-ctx frame-offset-ctx) + interactions-show? (mf/deref viewer-interactions-show?) + overlays (mf/deref refs/viewer-overlays) + interactions (:interactions shape) + svg-element? (and (= :svg-raw (:type shape)) + (not= :svg (get-in shape [:content :tag]))) - ;; 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 - ;; handling we need access to all objects inside the page. + ;; 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 + ;; handling we need access to all objects inside the page. - on-pointer-down - (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 + (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-up - (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 + (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-enter - (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 + (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-leave - (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 + (mf/use-fn (mf/deps shape base-frame frame-offset all-objects) + #(on-pointer-leave % shape base-frame frame-offset all-objects overlays))] - (mf/with-effect [] - (let [sems (on-load shape base-frame frame-offset objects overlays)] - (partial run! tm/dispose! sems))) + (mf/with-effect [] + (let [sems (on-load shape base-frame frame-offset objects overlays)] + (partial run! tm/dispose! sems))) - (if-not svg-element? - [:> shape-container {:shape shape - :cursor (when (ctsi/actionable? interactions) "pointer") - :on-pointer-down on-pointer-down - :on-pointer-up on-pointer-up - :on-pointer-enter on-pointer-enter - :on-pointer-leave on-pointer-leave} + (if-not svg-element? + [:> shape-container {:shape shape + :cursor (when (ctsi/actionable? interactions) "pointer") + :on-pointer-down on-pointer-down + :on-pointer-up on-pointer-up + :on-pointer-enter on-pointer-enter + :on-pointer-leave on-pointer-leave} - [:& component {:shape shape - :frame frame - :childs childs - :is-child-selected? true - :objects objects}] + [:& component {:shape shape + :frame frame + :childs childs + :is-child-selected? true + :objects objects}] - [:& interaction {:shape shape - :interactions interactions - :interactions-show? interactions-show?}]] + [:& interaction {:shape shape + :interactions interactions + :interactions-show? interactions-show?}]] ;; Don't wrap svg elements inside a otherwise some can break - [:& component {:shape shape - :frame frame - :childs childs - :objects objects}])))) + [:& component {:shape shape + :frame frame + :childs childs + :objects objects}])))) (defn frame-wrapper [shape-container] @@ -400,41 +400,41 @@ (let [shape-container (shape-container-factory objects all-objects) group-wrapper (group-wrapper shape-container)] (mf/fnc group-container - {::mf/wrap-props false} - [props] - (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) - props (obj/merge! #js {} props - #js {:childs childs - :objects objects})] - (when (not-empty childs) - [:> group-wrapper props]))))) + {::mf/wrap-props false} + [props] + (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) + props (obj/merge! #js {} props + #js {:childs childs + :objects objects})] + (when (not-empty childs) + [:> group-wrapper props]))))) (defn bool-container-factory [objects all-objects] (let [shape-container (shape-container-factory objects all-objects) bool-wrapper (bool-wrapper shape-container)] (mf/fnc bool-container - {::mf/wrap-props false} - [props] - (let [childs (->> (cfh/get-children-ids objects (:id (unchecked-get props "shape"))) - (select-keys objects)) - props (obj/merge! #js {} props - #js {:childs childs - :objects objects})] - [:> bool-wrapper props])))) + {::mf/wrap-props false} + [props] + (let [childs (->> (cfh/get-children-ids objects (:id (unchecked-get props "shape"))) + (select-keys objects)) + props (obj/merge! #js {} props + #js {:childs childs + :objects objects})] + [:> bool-wrapper props])))) (defn svg-raw-container-factory [objects all-objects] (let [shape-container (shape-container-factory objects all-objects) svg-raw-wrapper (svg-raw-wrapper shape-container)] (mf/fnc svg-raw-container - {::mf/wrap-props false} - [props] - (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) - props (obj/merge! #js {} props - #js {:childs childs - :objects objects})] - [:> svg-raw-wrapper props])))) + {::mf/wrap-props false} + [props] + (let [childs (mapv #(get objects %) (:shapes (unchecked-get props "shape"))) + props (obj/merge! #js {} props + #js {:childs childs + :objects objects})] + [:> svg-raw-wrapper props])))) (defn shape-container-factory [objects all-objects] @@ -444,28 +444,28 @@ image-wrapper (image-wrapper) circle-wrapper (circle-wrapper)] (mf/fnc shape-container - {::mf/wrap-props false - ::mf/wrap [mf/memo]} - [props] - (let [shape (unchecked-get props "shape") - frame (unchecked-get props "frame") + {::mf/wrap-props false + ::mf/wrap [mf/memo]} + [props] + (let [shape (unchecked-get props "shape") + frame (unchecked-get props "frame") - group-container - (mf/with-memo [objects] - (group-container-factory objects all-objects)) + group-container + (mf/with-memo [objects] + (group-container-factory objects all-objects)) - frame-container - (mf/with-memo [objects] - (frame-container-factory objects all-objects)) + frame-container + (mf/with-memo [objects] + (frame-container-factory objects all-objects)) - bool-container - (mf/with-memo [objects] - (bool-container-factory objects all-objects)) + bool-container + (mf/with-memo [objects] + (bool-container-factory objects all-objects)) - svg-raw-container - (mf/with-memo [objects] - (svg-raw-container-factory objects all-objects))] - (when (and shape (not (:hidden shape))) + svg-raw-container + (mf/with-memo [objects] + (svg-raw-container-factory objects all-objects))] + (when (and shape (not (:hidden shape))) (let [shape (if frame (gsh/translate-to-frame shape frame) shape) @@ -473,13 +473,13 @@ opts #js {:shape shape :objects objects :all-objects all-objects}] - (case (:type shape) - :frame [:> frame-container opts] - :text [:> text-wrapper opts] - :rect [:> rect-wrapper opts] - :path [:> path-wrapper opts] - :image [:> image-wrapper opts] - :circle [:> circle-wrapper opts] - :group [:> group-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}]))))))) + (case (:type shape) + :frame [:> frame-container opts] + :text [:> text-wrapper opts] + :rect [:> rect-wrapper opts] + :path [:> path-wrapper opts] + :image [:> image-wrapper opts] + :circle [:> circle-wrapper opts] + :group [:> group-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}]))))))) diff --git a/frontend/src/app/main/ui/workspace/color_palette.cljs b/frontend/src/app/main/ui/workspace/color_palette.cljs index ccecb957b..ceaeebd9b 100644 --- a/frontend/src/app/main/ui/workspace/color_palette.cljs +++ b/frontend/src/app/main/ui/workspace/color_palette.cljs @@ -26,8 +26,8 @@ (letfn [(select-color [event] (st/emit! (mdc/apply-color-from-palette color (kbd/alt? event))))] [:div {:class (stl/css-case :color-cell true - :is-not-library-color (nil? (:id color)) - :no-text (<= size 64)) + :is-not-library-color (nil? (:id color)) + :no-text (<= size 64)) :title (uc/get-color-name color) :on-click select-color} [:& cb/color-bullet {:color color}] diff --git a/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs b/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs index c3a5ea541..72be7f0a8 100644 --- a/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs +++ b/frontend/src/app/main/ui/workspace/color_palette_ctx_menu.cljs @@ -57,7 +57,7 @@ [:div {:class (stl/css :lib-name-wrapper)} [: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)} (dm/str "(" (count file-colors) ")")]] @@ -81,7 +81,7 @@ [:span {:class (stl/css :lib-name)} (dm/str (tr "workspace.libraries.colors.recent-colors"))] [:span {:class (stl/css :lib-num)} - (dm/str "("(count recent-colors) ")")]] + (dm/str "(" (count recent-colors) ")")]] (when (= selected :recent) [:span {:class (stl/css :icon-wrapper)} diff --git a/frontend/src/app/main/ui/workspace/colorpicker.cljs b/frontend/src/app/main/ui/workspace/colorpicker.cljs index 4972589ed..eaf166037 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker.cljs @@ -78,21 +78,21 @@ selected-mode (get state :type :color) disabled-color-accept? (and - (= selected-mode :image) - (not (:image current-color))) + (= selected-mode :image) + (not (:image current-color))) on-fill-image-success (mf/use-fn - (fn [image] - (st/emit! (dc/update-colorpicker-color {:image (select-keys image [:id :width :height :mtype :name])} (not @drag?))))) + (fn [image] + (st/emit! (dc/update-colorpicker-color {:image (select-keys image [:id :width :height :mtype :name])} (not @drag?))))) on-fill-image-click (mf/use-callback #(dom/click (mf/ref-val fill-image-ref))) on-fill-image-selected (mf/use-fn - (fn [file] - (st/emit! (dwm/upload-fill-image file on-fill-image-success)))) + (fn [file] + (st/emit! (dwm/upload-fill-image file on-fill-image-success)))) set-tab! (mf/use-fn @@ -218,7 +218,7 @@ options (mf/with-memo [selected-mode disable-gradient disable-image] - (d/concat-vec + (d/concat-vec [{:value :color :label (tr "media.solid")}] (when (not disable-gradient) [{:value :linear-gradient :label (tr "media.linear")} diff --git a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs index 5970835a0..fe52c2e92 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker/libraries.cljs @@ -58,7 +58,7 @@ (-> (dw/toggle-layout-flag :colorpalette) (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")} @@ -69,7 +69,7 @@ on-color-click (mf/use-fn (mf/deps state) - (fn[event] + (fn [event] (on-select-color state event)))] ;; Load library colors when the select is changed diff --git a/frontend/src/app/main/ui/workspace/context_menu.cljs b/frontend/src/app/main/ui/workspace/context_menu.cljs index af84fffa6..cb5e635f8 100644 --- a/frontend/src/app/main/ui/workspace/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/context_menu.cljs @@ -555,7 +555,7 @@ (mf/deps grid-id type index) (fn [] (st/emit! (dwsl/remove-layout-track [grid-id] type index {:with-shapes? true}))))] - + (if (= type :column) [:* [:& menu-entry {:title (tr "workspace.context-menu.grid-track.column.duplicate") :on-click do-duplicate-track}] diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index 1be9a2a83..11bf95774 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -42,8 +42,8 @@ (refs/children-objects shape-id)) childs (mf/deref childs-ref)] - [:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)} - [:& frame-shape {:shape shape :childs childs}]])))) + [:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)} + [:& frame-shape {:shape shape :childs childs}]])))) (defn check-props [new-props old-props] diff --git a/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs b/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs index f2fe8e3b9..41f0584b3 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame/dynamic_modifiers.cljs @@ -311,6 +311,4 @@ (reset! prev-modifiers modifiers) (reset! prev-transforms transforms) - (reset! prev-shapes shapes)) - - )) + (reset! prev-shapes shapes)))) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs index 964c194df..e9a413714 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs @@ -308,7 +308,7 @@ ;; edited (mf/use-effect (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)] (run! fonts/ensure-loaded! fonts)))) diff --git a/frontend/src/app/main/ui/workspace/sidebar.cljs b/frontend/src/app/main/ui/workspace/sidebar.cljs index ddda4cf01..faa27b292 100644 --- a/frontend/src/app/main/ui/workspace/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar.cljs @@ -111,7 +111,7 @@ (mf/defc right-sidebar {::mf/wrap-props false ::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)) is-comments? (= drawing-tool :comments) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index cb67bf83d..09118cffa 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -127,31 +127,31 @@ (mf/use-fn #(swap! filters* assoc :open-menu false)) options (into [] (remove nil? - [{:option-name (tr "workspace.assets.box-filter-all") - :id "section-all" - :option-handler on-section-filter-change - :data-test "all"} + [{:option-name (tr "workspace.assets.box-filter-all") + :id "section-all" + :option-handler on-section-filter-change + :data-test "all"} - {:option-name (tr "workspace.assets.components") - :id "section-components" - :option-handler on-section-filter-change - :data-test "components"} + {:option-name (tr "workspace.assets.components") + :id "section-components" + :option-handler on-section-filter-change + :data-test "components"} - (when (not components-v2) - {:option-name (tr "workspace.assets.graphics") - :id "section-graphics" - :option-handler on-section-filter-change - :data-test "graphics"}) + (when (not components-v2) + {:option-name (tr "workspace.assets.graphics") + :id "section-graphics" + :option-handler on-section-filter-change + :data-test "graphics"}) - {:option-name (tr "workspace.assets.colors") - :id "section-color" - :option-handler on-section-filter-change - :data-test "colors"} + {:option-name (tr "workspace.assets.colors") + :id "section-color" + :option-handler on-section-filter-change + :data-test "colors"} - {:option-name (tr "workspace.assets.typography") - :id "section-typography" - :option-handler on-section-filter-change - :data-test "typographies"}]))] + {:option-name (tr "workspace.assets.typography") + :id "section-typography" + :option-handler on-section-filter-change + :data-test "typographies"}]))] [:div {:class (stl/css :assets-bar)} [:div {:class (stl/css :assets-header)} diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs index 833c573f7..b44390286 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/components.cljs @@ -59,10 +59,10 @@ ;; NOTE: We don't schedule the thumbnail generation on idle right now ;; until we can queue and handle thumbnail batching properly. - #_(mf/with-effect [] - (when-not (some? thumbnail-uri) - (tm/schedule-on-idle - #(st/emit! (dwl/update-component-thumbnail (:id component) file-id))))) +#_(mf/with-effect [] + (when-not (some? thumbnail-uri) + (tm/schedule-on-idle + #(st/emit! (dwl/update-component-thumbnail (:id component) file-id))))) (mf/defc components-item diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs index d85b1979c..2f549e67f 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets/typographies.cljs @@ -387,71 +387,71 @@ (partial on-asset-click groups))] (mf/use-effect - (mf/deps local-data ) + (mf/deps local-data) (fn [] (when (:edit-typography local-data) (st/emit! #(update % :workspace-global dissoc :edit-typography))))) [:* [:& cmm/asset-section {:file-id file-id - :title (tr "workspace.assets.typography") - :section :typographies - :assets-count (count typographies) - :open? open?} - (when local? - [:& cmm/asset-section-block {:role :title-button} - (when-not read-only? - [:button {:class (stl/css :assets-btn) - :on-click add-typography} - i/add-refactor])]) + :title (tr "workspace.assets.typography") + :section :typographies + :assets-count (count typographies) + :open? open?} + (when local? + [:& cmm/asset-section-block {:role :title-button} + (when-not read-only? + [:button {:class (stl/css :assets-btn) + :on-click add-typography} + i/add-refactor])]) - [:& cmm/asset-section-block {:role :content} - [:& typographies-group {:file-id file-id - :prefix "" - :groups groups - :open-groups open-groups - :force-open? force-open? - :state state - :file file - :local? local? - :selected selected - :editing-id editing-id - :renaming-id renaming-id - :local-data local-data - :on-asset-click on-asset-click - :handle-change handle-change - :apply-typography apply-typography - :on-rename-group on-rename-group - :on-ungroup on-ungroup - :on-context-menu on-context-menu - :selected-full selected-full}] + [:& cmm/asset-section-block {:role :content} + [:& typographies-group {:file-id file-id + :prefix "" + :groups groups + :open-groups open-groups + :force-open? force-open? + :state state + :file file + :local? local? + :selected selected + :editing-id editing-id + :renaming-id renaming-id + :local-data local-data + :on-asset-click on-asset-click + :handle-change handle-change + :apply-typography apply-typography + :on-rename-group on-rename-group + :on-ungroup on-ungroup + :on-context-menu on-context-menu + :selected-full selected-full}] - (if local? - [:& cmm/assets-context-menu - {:on-close on-close-menu - :state @menu-state - :options [(when-not (or multi-typographies? multi-assets?) - {:option-name (tr "workspace.assets.rename") - :id "assets-rename-typography" - :option-handler handle-rename-typography-clicked}) + (if local? + [:& cmm/assets-context-menu + {:on-close on-close-menu + :state @menu-state + :options [(when-not (or multi-typographies? multi-assets?) + {:option-name (tr "workspace.assets.rename") + :id "assets-rename-typography" + :option-handler handle-rename-typography-clicked}) - (when-not (or multi-typographies? multi-assets?) - {:option-name (tr "workspace.assets.edit") - :id "assets-edit-typography" - :option-handler handle-edit-typography-clicked}) + (when-not (or multi-typographies? multi-assets?) + {:option-name (tr "workspace.assets.edit") + :id "assets-edit-typography" + :option-handler handle-edit-typography-clicked}) - {:option-name (tr "workspace.assets.delete") - :id "assets-delete-typography" - :option-handler handle-delete-typography} + {:option-name (tr "workspace.assets.delete") + :id "assets-delete-typography" + :option-handler handle-delete-typography} - (when-not multi-assets? - {:option-name (tr "workspace.assets.group") - :id "assets-group-typography" - :option-handler on-group})]}] + (when-not multi-assets? + {:option-name (tr "workspace.assets.group") + :id "assets-group-typography" + :option-handler on-group})]}] - [:& cmm/assets-context-menu - {:on-close on-close-menu - :state @menu-state - :options [{:option-name "show info" - :id "assets-rename-typography" - :option-handler handle-edit-typography-clicked}]}])]]])) + [:& cmm/assets-context-menu + {:on-close on-close-menu + :state @menu-state + :options [{:option-name "show info" + :id "assets-rename-typography" + :option-handler handle-edit-typography-clicked}]}])]]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/history.cljs b/frontend/src/app/main/ui/workspace/sidebar/history.cljs index 4c292d905..b124e6215 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/history.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/history.cljs @@ -260,27 +260,27 @@ (let [{entries :items} (mf/deref workspace-undo) objects (mf/deref refs/workspace-page-objects)] - [:div {:class (stl/css :history-entry-detail)} - (case (:operation entry) - :new - (:name (get-object (:detail entry) entries objects)) + [:div {:class (stl/css :history-entry-detail)} + (case (:operation entry) + :new + (:name (get-object (:detail entry) entries objects)) - :delete - [:ul {:class (stl/css :history-entry-details-list)} - (for [id (:detail entry)] - (let [shape-name (:name (get-object id entries objects))] - [:li {:key id} shape-name]))] + :delete + [:ul {:class (stl/css :history-entry-details-list)} + (for [id (:detail entry)] + (let [shape-name (:name (get-object id entries objects))] + [:li {:key id} shape-name]))] - :modify - [:ul {:class (stl/css :history-entry-details-list)} - (for [[id attributes] (:detail entry)] - (let [shape-name (:name (get-object id entries objects))] - [:li {:key id} - [:div shape-name] - [:div (str/join ", " attributes)]]))] + :modify + [:ul {:class (stl/css :history-entry-details-list)} + (for [[id attributes] (:detail entry)] + (let [shape-name (:name (get-object id entries objects))] + [:li {:key id} + [:div shape-name] + [:div (str/join ", " attributes)]]))] - nil)])) + nil)])) (mf/defc history-entry [{:keys [locale entry idx-entry disabled? current?]}] (let [hover? (mf/use-state false) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs index e5f1a9479..8fda8b495 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/component.cljs @@ -317,78 +317,78 @@ (fn [style] (swap! filters* assoc :listing-thumbs? (= style "grid"))))] - [:div {:class (stl/css :component-swap)} - [:div {:class (stl/css :element-set-title)} - [:span (tr "workspace.options.component.swap")]] - [:div {:class (stl/css :component-swap-content)} - [:div {:class (stl/css :search-field)} - [:& search-bar {:on-change on-search-term-change - :clear-action on-search-clear-click - :value (:term filters) - :placeholder (str (tr "labels.search") " " (get-in libraries [current-library-id :name])) - :icon (mf/html [:span {:class (stl/css :search-icon)} i/search-refactor])}]] + [:div {:class (stl/css :component-swap)} + [:div {:class (stl/css :element-set-title)} + [:span (tr "workspace.options.component.swap")]] + [:div {:class (stl/css :component-swap-content)} + [:div {:class (stl/css :search-field)} + [:& search-bar {:on-change on-search-term-change + :clear-action on-search-clear-click + :value (:term filters) + :placeholder (str (tr "labels.search") " " (get-in libraries [current-library-id :name])) + :icon (mf/html [:span {:class (stl/css :search-icon)} i/search-refactor])}]] - [:div {:class (stl/css :select-field)} - [:& select - {:class (stl/css :select-library) - :default-value current-library-id - :options libraries-options - :on-change on-library-change}]] + [:div {:class (stl/css :select-field)} + [:& select + {:class (stl/css :select-library) + :default-value current-library-id + :options libraries-options + :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)} - [:& radio-buttons {:class (stl/css :listing-options) - :selected (if (:listing-thumbs? filters) "grid" "list") - :on-change toggle-list-style - :name "swap-listing-style"} - [:& radio-button {:icon i/view-as-list-refactor - :icon-class (stl/css :radio-button) - :value "list" - :id "swap-opt-list"}] - [:& radio-button {:icon i/flex-grid-refactor - :icon-class (stl/css :radio-button) - :value "grid" - :id "swap-opt-grid"}]]] + [:div {:class (stl/css :listing-options-wrapper)} + [:& radio-buttons {:class (stl/css :listing-options) + :selected (if (:listing-thumbs? filters) "grid" "list") + :on-change toggle-list-style + :name "swap-listing-style"} + [:& radio-button {:icon i/view-as-list-refactor + :icon-class (stl/css :radio-button) + :value "list" + :id "swap-opt-list"}] + [:& radio-button {:icon i/flex-grid-refactor + :icon-class (stl/css :radio-button) + :value "grid" + :id "swap-opt-grid"}]]] - (if (or is-search? (str/empty? (:path filters))) - [:div {:class (stl/css :component-path-empty)}] - [:button {:class (stl/css :component-path) - :on-click on-go-back - :title (:path filters)} - [:span i/arrow-slide] - [:span (:path filters)]]) + (if (or is-search? (str/empty? (:path filters))) + [:div {:class (stl/css :component-path-empty)}] + [:button {:class (stl/css :component-path) + :on-click on-go-back + :title (:path filters)} + [:span i/arrow-slide] + [:span (:path filters)]]) - (when (empty? items) - [:div {:class (stl/css :component-list-empty)} - (tr "workspace.options.component.swap.empty")]) + (when (empty? items) + [:div {:class (stl/css :component-list-empty)} + (tr "workspace.options.component.swap.empty")]) - (when (:listing-thumbs? filters) - [:div {:class (stl/css :component-list)} - (for [item groups] - [:& component-group-item {:item item :on-enter-group on-enter-group}])]) + (when (:listing-thumbs? filters) + [:div {:class (stl/css :component-list)} + (for [item groups] + [:& component-group-item {:item item :on-enter-group on-enter-group}])]) - [:div {:class (stl/css-case :component-grid (:listing-thumbs? filters) - :component-list (not (:listing-thumbs? filters)))} - (for [item items] - (if (:id item) - (let [data (get-in libraries [current-library-id :data]) - container (ctf/get-component-page data item) - root-shape (ctf/get-component-root data item) - loop? (or (contains? parent-components (:main-instance-id item)) - (contains? parent-components (:id item)))] - [:& component-swap-item {:key (:id item) - :item item - :loop loop? - :shapes shapes - :file-id current-library-id - :root-shape root-shape - :container container - :component-id current-comp-id - :is-search is-search? - :listing-thumbs (:listing-thumbs? filters)}]) - [:& component-group-item {:item item :on-enter-group on-enter-group}]))]]])) + [:div {:class (stl/css-case :component-grid (:listing-thumbs? filters) + :component-list (not (:listing-thumbs? filters)))} + (for [item items] + (if (:id item) + (let [data (get-in libraries [current-library-id :data]) + container (ctf/get-component-page data item) + root-shape (ctf/get-component-root data item) + loop? (or (contains? parent-components (:main-instance-id item)) + (contains? parent-components (:id item)))] + [:& component-swap-item {:key (:id item) + :item item + :loop loop? + :shapes shapes + :file-id current-library-id + :root-shape root-shape + :container container + :component-id current-comp-id + :is-search is-search? + :listing-thumbs (:listing-thumbs? filters)}]) + [:& component-group-item {:item item :on-enter-group on-enter-group}]))]]])) (mf/defc component-ctx-menu [{:keys [menu-entries on-close show] :as props}] @@ -397,14 +397,14 @@ (dom/stop-propagation event) (action) (on-close))] - [:& dropdown {:show show :on-close on-close} - [:ul {:class (stl/css :custom-select-dropdown)} - (for [entry menu-entries :when (not (nil? entry))] - [:li {:key (uuid/next) - :class (stl/css :dropdown-element) - :on-click (partial do-action (:action entry))} - [:span {:class (stl/css :dropdown-label)} - (tr (:msg entry))]])]])) + [:& dropdown {:show show :on-close on-close} + [:ul {:class (stl/css :custom-select-dropdown)} + (for [entry menu-entries :when (not (nil? entry))] + [:li {:key (uuid/next) + :class (stl/css :dropdown-element) + :on-click (partial do-action (:action entry))} + [:span {:class (stl/css :dropdown-label)} + (tr (:msg entry))]])]])) (mf/defc component-menu [{:keys [shapes swap-opened?] :as props}] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs index 58fe4f1e9..4e45960c5 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/fill.cljs @@ -74,7 +74,7 @@ (st/emit! (dc/add-fill ids {:color default-color :opacity 1})) - (when (not (some? (seq fills))) (open-content)))) + (when (not (some? (seq fills))) (open-content)))) on-change (mf/use-fn diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/grid_cell.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/grid_cell.cljs index 7d9da9121..dacb1d8d7 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/grid_cell.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/grid_cell.cljs @@ -46,28 +46,28 @@ (set-alignment (-> value keyword))))] [:div {:class (stl/css :self-align-menu)} - [:& radio-buttons {:selected (d/name alignment) - :on-change handle-set-alignment - :name (dm/str "flex-align-items-" type)} - [:& radio-button {:value "start" - :icon (if is-col? i/align-self-row-left-refactor i/align-self-column-top-refactor) - :title "Align self start" - :id (dm/str "align-self-start-" type)}] + [:& radio-buttons {:selected (d/name alignment) + :on-change handle-set-alignment + :name (dm/str "flex-align-items-" type)} + [:& radio-button {:value "start" + :icon (if is-col? i/align-self-row-left-refactor i/align-self-column-top-refactor) + :title "Align self start" + :id (dm/str "align-self-start-" type)}] - [:& radio-button {:value "center" - :icon (if is-col? i/align-self-row-center-refactor i/align-self-column-center-refactor) - :title "Align self center" - :id (dm/str "align-self-center-" type)}] + [:& radio-button {:value "center" + :icon (if is-col? i/align-self-row-center-refactor i/align-self-column-center-refactor) + :title "Align self center" + :id (dm/str "align-self-center-" type)}] - [:& radio-button {:value "end" - :icon (if is-col? i/align-self-row-right-refactor i/align-self-column-bottom-refactor) - :title "Align self end" - :id (dm/str "align-self-end-" type)}] + [:& radio-button {:value "end" + :icon (if is-col? i/align-self-row-right-refactor i/align-self-column-bottom-refactor) + :title "Align self end" + :id (dm/str "align-self-end-" type)}] - [:& radio-button {:value "stretch" - :icon (if is-col? i/align-self-row-strech i/align-self-column-strech) - :title "Align self stretch" - :id (dm/str "align-self-stretch-" type)}]]])) + [:& radio-button {:value "stretch" + :icon (if is-col? i/align-self-row-strech i/align-self-column-strech) + :title "Align self stretch" + :id (dm/str "align-self-stretch-" type)}]]])) (mf/defc options diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs index 67138d85e..42c371801 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs @@ -225,7 +225,7 @@ (mf/use-fn (mf/deps index) (fn [value] - (update-interaction index #(ctsi/set-delay % value)))) + (update-interaction index #(ctsi/set-delay % value)))) change-destination (mf/use-fn @@ -246,27 +246,27 @@ (mf/use-fn (mf/deps index) (fn [event] - (let [value (-> event dom/get-target dom/checked?)] - (update-interaction index #(ctsi/set-preserve-scroll % value))))) + (let [value (-> event dom/get-target dom/checked?)] + (update-interaction index #(ctsi/set-preserve-scroll % value))))) change-url (mf/use-fn (mf/deps index) (fn [event] - (let [target (dom/get-target event) - value (dom/get-value target) - has-prefix? (or (str/starts-with? value "http://") - (str/starts-with? value "https://")) - value (if has-prefix? - value - (str "http://" value))] - (when-not has-prefix? - (dom/set-value! target value)) - (if (dom/valid? target) - (do - (dom/remove-class! target "error") - (update-interaction index #(ctsi/set-url % value))) - (dom/add-class! target "error"))))) + (let [target (dom/get-target event) + value (dom/get-value target) + has-prefix? (or (str/starts-with? value "http://") + (str/starts-with? value "https://")) + value (if has-prefix? + value + (str "http://" value))] + (when-not has-prefix? + (dom/set-value! target value)) + (if (dom/valid? target) + (do + (dom/remove-class! target "error") + (update-interaction index #(ctsi/set-url % value))) + (dom/add-class! target "error"))))) change-overlay-pos-type (mf/use-fn @@ -290,15 +290,15 @@ (mf/use-fn (mf/deps index) (fn [event] - (let [value (-> event dom/get-target dom/checked?)] - (update-interaction index #(ctsi/set-close-click-outside % value))))) + (let [value (-> event dom/get-target dom/checked?)] + (update-interaction index #(ctsi/set-close-click-outside % value))))) change-background-overlay (mf/use-fn (mf/deps index) (fn [event] - (let [value (-> event dom/get-target dom/checked?)] - (update-interaction index #(ctsi/set-background-overlay % value))))) + (let [value (-> event dom/get-target dom/checked?)] + (update-interaction index #(ctsi/set-background-overlay % value))))) change-animation-type (mf/use-fn @@ -310,36 +310,36 @@ (update-interaction index #(ctsi/set-animation-type % value))))) change-duration - (mf/use-fn(fn [value] - (update-interaction index #(ctsi/set-duration % value)))) + (mf/use-fn (fn [value] + (update-interaction index #(ctsi/set-duration % value)))) change-easing (mf/use-fn (mf/deps index) (fn [event] - (let [value (keyword event)] - (update-interaction index #(ctsi/set-easing % value))))) + (let [value (keyword event)] + (update-interaction index #(ctsi/set-easing % value))))) change-way (mf/use-fn (mf/deps index) (fn [event] - (let [value (keyword event)] - (update-interaction index #(ctsi/set-way % value))))) + (let [value (keyword event)] + (update-interaction index #(ctsi/set-way % value))))) change-direction (mf/use-fn (mf/deps index) (fn [event] - (let [value (keyword event)] - (update-interaction index #(ctsi/set-direction % value))))) + (let [value (keyword event)] + (update-interaction index #(ctsi/set-direction % value))))) change-offset-effect (mf/use-fn (mf/deps index) (fn [event] - (let [value (-> event dom/get-target dom/checked?)] - (update-interaction index #(ctsi/set-offset-effect % value))))) + (let [value (-> event dom/get-target dom/checked?)] + (update-interaction index #(ctsi/set-offset-effect % value))))) event-type-options [{:value :click :label (tr "workspace.options.interaction-on-click")} diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs index 13e181efb..5d98c2b6e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/layout_item.cljs @@ -41,13 +41,13 @@ (let [margin-type (or (:layout-item-margin-type values) :simple) m1 (when (and (not (= :multiple (:layout-item-margin values))) - (= (dm/get-in values [:layout-item-margin :m1]) - (dm/get-in values [:layout-item-margin :m3]))) + (= (dm/get-in values [:layout-item-margin :m1]) + (dm/get-in values [:layout-item-margin :m3]))) (dm/get-in values [:layout-item-margin :m1])) m2 (when (and (not (= :multiple (:layout-item-margin values))) - (= (dm/get-in values [:layout-item-margin :m2]) - (dm/get-in values [:layout-item-margin :m4]))) + (= (dm/get-in values [:layout-item-margin :m2]) + (dm/get-in values [:layout-item-margin :m4]))) (dm/get-in values [:layout-item-margin :m2])) select-margins (fn [m1? m2? m3? m4?] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs index 874e4628a..063466dcc 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/shadow.cljs @@ -113,7 +113,7 @@ (st/emit! (dch/update-shapes ids #(assoc-in % [:shadow index :color] - (dissoc color :id :file-id)))))) + (dissoc color :id :file-id)))))) detach-color (mf/use-fn diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index 15be74946..906925620 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -264,7 +264,5 @@ (when select-only [:button {:class (stl/css :select-btn) :on-click handle-select} - i/move-refactor])] - - )) + i/move-refactor])])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs index a562269ae..736a71c30 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs @@ -231,8 +231,8 @@ (-> values (merge-attrs (select-keys shape attrs)) (merge-attrs (merge - (select-keys txt/default-text-attrs attrs) - (attrs/get-attrs-multi (txt/node-seq content) attrs))))] + (select-keys txt/default-text-attrs attrs) + (attrs/get-attrs-multi (txt/node-seq content) attrs))))] :children (let [children (->> (:shapes shape []) (map #(get objects %))) [new-ids new-values] (get-attrs* children objects attr-group)] diff --git a/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs b/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs index bd8a90200..8e4988a09 100644 --- a/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs +++ b/frontend/src/app/main/ui/workspace/text_palette_ctx_menu.cljs @@ -21,7 +21,7 @@ shared-libs (mf/deref refs/workspace-libraries)] [:& dropdown {:show show-menu? :on-close close-menu} - [:ul {:class (stl/css :workspace-context-menu) } + [:ul {:class (stl/css :workspace-context-menu)} (for [[idx cur-library] (map-indexed vector (vals shared-libs))] (let [typographies (-> cur-library (get-in [:data :typographies]) vals)] [:li diff --git a/frontend/src/app/main/ui/workspace/viewport/comments.cljs b/frontend/src/app/main/ui/workspace/viewport/comments.cljs index aa59d9e91..ce44c0292 100644 --- a/frontend/src/app/main/ui/workspace/viewport/comments.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/comments.cljs @@ -78,6 +78,4 @@ [:& cmt/draft-thread {:draft draft :on-cancel on-draft-cancel :on-submit on-draft-submit - :zoom zoom}])]]] - - )) + :zoom zoom}])]]])) diff --git a/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs b/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs index 99f692f6e..61246ea70 100644 --- a/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/frame_grid.cljs @@ -173,7 +173,7 @@ [:g.grid-display {:style {:pointer-events "none"}} (for [frame frames] (when (and #_(not (is-transform? frame)) - (not (ctst/rotated-frame? frame)) + (not (ctst/rotated-frame? frame)) (or (empty? focus) (contains? focus (:id frame)))) [:& grid-display-frame {:key (str "grid-" (:id frame)) :zoom zoom diff --git a/frontend/src/app/main/ui/workspace/viewport/gradients.cljs b/frontend/src/app/main/ui/workspace/viewport/gradients.cljs index f1cb78ee2..ae1dee653 100644 --- a/frontend/src/app/main/ui/workspace/viewport/gradients.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/gradients.cljs @@ -250,7 +250,7 @@ width-v (-> gradient-vec (gpt/normal-left) - (gpt/multiply (gpt/point (* (:width gradient) (/ gradient-length (/ height 2) )))) + (gpt/multiply (gpt/point (* (:width gradient) (/ gradient-length (/ height 2))))) (gpt/multiply (gpt/point (/ width 2)))) width-p (gpt/add from-p width-v) diff --git a/frontend/src/app/main/ui/workspace/viewport/grid_layout_editor.cljs b/frontend/src/app/main/ui/workspace/viewport/grid_layout_editor.cljs index fcac73c07..0e95f631f 100644 --- a/frontend/src/app/main/ui/workspace/viewport/grid_layout_editor.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/grid_layout_editor.cljs @@ -553,7 +553,7 @@ [:rect.drop {:x (:x start-p-drop) :y (:y start-p-drop) - :width (if (= type :column)(/ 10 zoom) width) + :width (if (= type :column) (/ 10 zoom) width) :height (if (= type :row) (/ 10 zoom) height) :fill "var(--grid-editor-area-background)"}]) diff --git a/frontend/src/app/main/ui/workspace/viewport/guides.cljs b/frontend/src/app/main/ui/workspace/viewport/guides.cljs index 82b220fc6..9d1b481d2 100644 --- a/frontend/src/app/main/ui/workspace/viewport/guides.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/guides.cljs @@ -250,11 +250,11 @@ [guide frame] (if (= :x (:axis guide)) - (and (>= (:position guide) (:x frame) ) - (<= (:position guide) (+ (:x frame) (:width frame)) )) + (and (>= (:position guide) (:x frame)) + (<= (:position guide) (+ (:x frame) (:width frame)))) - (and (>= (:position guide) (:y frame) ) - (<= (:position guide) (+ (:y frame) (:height frame)) )))) + (and (>= (:position guide) (:y frame)) + (<= (:position guide) (+ (:y frame) (:height frame)))))) (mf/defc guide {::mf/wrap [mf/memo]} diff --git a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs index 602d08b38..583eeddda 100644 --- a/frontend/src/app/main/ui/workspace/viewport/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/interactions.cljs @@ -55,11 +55,11 @@ dest-x-center (+ dest-x-left (/ (:width dest-rect) 2)) orig-pos (if (<= orig-x-right dest-x-left) :right - (if (>= orig-x-left dest-x-right) :left - (if (<= orig-x-center dest-x-center) :left :right))) + (if (>= orig-x-left dest-x-right) :left + (if (<= orig-x-center dest-x-center) :left :right))) dest-pos (if (<= orig-x-right dest-x-left) :left - (if (>= orig-x-left dest-x-right) :right - (if (<= orig-x-center dest-x-center) :left :right))) + (if (>= orig-x-left dest-x-right) :right + (if (<= orig-x-center dest-x-center) :left :right))) orig-x (if (= orig-pos :right) orig-x-right orig-x-left) dest-x (if (= dest-pos :right) dest-x-right dest-x-left) @@ -84,11 +84,11 @@ dest-y (:y dest-point) orig-pos (if (<= orig-x-right dest-x) :right - (if (>= orig-x-left dest-x) :left - (if (<= orig-x-center dest-x) :right :left))) + (if (>= orig-x-left dest-x) :left + (if (<= orig-x-center dest-x) :right :left))) dest-pos (if (<= orig-x-right dest-x) :left - (if (>= orig-x-left dest-x) :right - (if (<= orig-x-center dest-x) :right :left))) + (if (>= orig-x-left dest-x) :right + (if (<= orig-x-center dest-x) :right :left))) orig-x (if (= orig-pos :right) orig-x-right orig-x-left) orig-y (+ (:y orig-rect) (/ (:height orig-rect) 2))] @@ -121,21 +121,21 @@ nil) inv-zoom (/ 1 zoom)] [:* - [:circle {:cx 0 - :cy 0 - :r (if (some? action-type) 11 4) - :fill stroke - :transform (str - "scale(" inv-zoom ", " inv-zoom ") " - "translate(" (* zoom x) ", " (* zoom y) ")")}] - (when icon-pdata - [:path {:fill stroke - :stroke-width 2 - :stroke "var(--color-white)" - :d icon-pdata - :transform (str - "scale(" inv-zoom ", " inv-zoom ") " - "translate(" (* zoom x) ", " (* zoom y) ")")}])])) + [:circle {:cx 0 + :cy 0 + :r (if (some? action-type) 11 4) + :fill stroke + :transform (str + "scale(" inv-zoom ", " inv-zoom ") " + "translate(" (* zoom x) ", " (* zoom y) ")")}] + (when icon-pdata + [:path {:fill stroke + :stroke-width 2 + :stroke "var(--color-white)" + :d icon-pdata + :transform (str + "scale(" inv-zoom ", " inv-zoom ") " + "translate(" (* zoom x) ", " (* zoom y) ")")}])])) (mf/defc interaction-path @@ -252,7 +252,7 @@ [:g {:on-pointer-down start-move-position :on-pointer-enter #(reset! hover-disabled? true) :on-pointer-leave #(reset! hover-disabled? false)} - [:g {:transform (gmt/translate-matrix (gpt/point (- marker-x dest-x) (- marker-y dest-y))) } + [:g {:transform (gmt/translate-matrix (gpt/point (- marker-x dest-x) (- marker-y dest-y)))} [:& (mf/provider muc/render-thumbnails) {:value true} [:& (mf/provider embed/context) {:value false} [:& shape-wrapper {:shape dest-shape}]]]] diff --git a/frontend/src/app/main/ui/workspace/viewport/outline.cljs b/frontend/src/app/main/ui/workspace/viewport/outline.cljs index 43efeda91..a2d14bb33 100644 --- a/frontend/src/app/main/ui/workspace/viewport/outline.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/outline.cljs @@ -90,8 +90,7 @@ :height h :rx (obj/get border-attrs "rx") :ry (obj/get border-attrs "ry") - :d (obj/get border-attrs "d")}))) - ] + :d (obj/get border-attrs "d")})))] [:> outline-type props])) diff --git a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs index babee7495..1a1b0a9a6 100644 --- a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs @@ -38,14 +38,14 @@ canvas)) (def get-offscreen-canvas ((fn [] - (let [internal-state #js { :canvas nil }] - (fn [width height] - (let [canvas (unchecked-get internal-state "canvas")] - (if canvas - (resize-offscreen-canvas canvas width height) - (let [new-canvas (create-offscreen-canvas width height)] - (obj/set! internal-state "canvas" new-canvas) - new-canvas)))))))) + (let [internal-state #js {:canvas nil}] + (fn [width height] + (let [canvas (unchecked-get internal-state "canvas")] + (if canvas + (resize-offscreen-canvas canvas width height) + (let [new-canvas (create-offscreen-canvas width height)] + (obj/set! internal-state "canvas" new-canvas) + new-canvas)))))))) (mf/defc pixel-overlay {::mf/wrap-props false} @@ -143,11 +143,11 @@ :styles styles))) (rx/mapcat thr/render-node) (rx/subs! (fn [image-bitmap] - (.drawImage canvas-context image-bitmap 0 0) - (let [width (unchecked-get canvas "width") - height (unchecked-get canvas "height") - image-data (.getImageData canvas-context 0 0 width height)] - (mf/set-ref-val! canvas-image-data image-data)))))))) + (.drawImage canvas-context image-bitmap 0 0) + (let [width (unchecked-get canvas "width") + height (unchecked-get canvas "height") + image-data (.getImageData canvas-context 0 0 width height)] + (mf/set-ref-val! canvas-image-data image-data)))))))) handle-svg-change (mf/use-callback diff --git a/frontend/src/app/main/ui/workspace/viewport/rules.cljs b/frontend/src/app/main/ui/workspace/viewport/rules.cljs index af978fef0..c3af821de 100644 --- a/frontend/src/app/main/ui/workspace/viewport/rules.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/rules.cljs @@ -262,7 +262,7 @@ :style {:fill rules-background :fill-opacity over-number-opacity}}] - [:rect {:x (+ (- center-x (/ (:height selection-rect) 2) (* rule-area-half-size zoom-inverse) ) (:height selection-rect)) + [:rect {:x (+ (- center-x (/ (:height selection-rect) 2) (* rule-area-half-size zoom-inverse)) (:height selection-rect)) :y (- center-y (* rule-area-half-size zoom-inverse)) :width (* over-number-size zoom-inverse) :height (* rule-area-size zoom-inverse) @@ -278,7 +278,7 @@ :fill selection-area-color}} (fmt/format-number (- (:y2 selection-rect) offset-y))] - [:text {:x (+ center-x (/ (:height selection-rect) 2) ) + [:text {:x (+ center-x (/ (:height selection-rect) 2)) :y center-y :text-anchor "start" :dominant-baseline "middle" diff --git a/frontend/src/app/main/ui/workspace/viewport/selection.cljs b/frontend/src/app/main/ui/workspace/viewport/selection.cljs index 65437ed8d..5da05fe33 100644 --- a/frontend/src/app/main/ui/workspace/viewport/selection.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/selection.cljs @@ -69,7 +69,7 @@ :outside :inside)] (->> - [ ;; TOP-LEFT + [;; TOP-LEFT {:type :rotation :position :top-left :props {:cx x :cy y}} diff --git a/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs b/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs index f0739fbc2..8b0b477cf 100644 --- a/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/snap_distances.cljs @@ -257,8 +257,8 @@ ;; change (rx/switch-map (partial query-worker page-id coord)) (rx/subs! (fn [[lt-shapes gt-shapes]] - (reset! lt-shapes* lt-shapes) - (reset! gt-shapes* gt-shapes))))] + (reset! lt-shapes* lt-shapes) + (reset! gt-shapes* gt-shapes))))] ;; On unmount dispose #(rx/dispose! sub))) diff --git a/frontend/src/app/main/ui/workspace/viewport/utils.cljs b/frontend/src/app/main/ui/workspace/viewport/utils.cljs index 6d17baf8a..fac3c4ba0 100644 --- a/frontend/src/app/main/ui/workspace/viewport/utils.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/utils.cljs @@ -15,7 +15,7 @@ (defn format-viewbox "Format a viewbox to a string" [vbox] - (dm/str (format-number(:x vbox 0)) " " + (dm/str (format-number (:x vbox 0)) " " (format-number (:y vbox 0)) " " (format-number (:width vbox 0)) " " (format-number (:height vbox 0)))) diff --git a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs index ec646a966..ccd92afc3 100644 --- a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs @@ -232,8 +232,8 @@ on-double-click (mf/use-callback - (mf/deps (:id frame)) - #(st/emit! (dwi/start-rename-flow (:id flow)))) + (mf/deps (:id frame)) + #(st/emit! (dwi/start-rename-flow (:id flow)))) on-pointer-enter (mf/use-callback @@ -253,12 +253,12 @@ :height 24 :transform (vwu/text-transform flow-pos zoom)} [:div {:class (stl/css-case :flow-badge true - :selected selected?)} + :selected selected?)} [:div {:class (stl/css :content) - :on-pointer-down on-pointer-down - :on-double-click on-double-click - :on-pointer-enter on-pointer-enter - :on-pointer-leave on-pointer-leave} + :on-pointer-down on-pointer-down + :on-double-click on-double-click + :on-pointer-enter on-pointer-enter + :on-pointer-leave on-pointer-leave} i/play-refactor [:span (:name flow)]]]])) diff --git a/frontend/src/app/rasterizer.cljs b/frontend/src/app/rasterizer.cljs index 157b57a65..19c278593 100644 --- a/frontend/src/app/rasterizer.cljs +++ b/frontend/src/app/rasterizer.cljs @@ -262,7 +262,7 @@ (= scope "penpot/rasterizer")) (->> (render payload) (rx/subs! (partial send-success! id) - (partial send-failure! id)))))))) + (partial send-failure! id)))))))) (defn- listen "Initializes the listener for messages from the main thread." diff --git a/frontend/src/app/render.cljs b/frontend/src/app/render.cljs index f3f13a098..8dbcbf43f 100644 --- a/frontend/src/app/render.cljs +++ b/frontend/src/app/render.cljs @@ -217,9 +217,7 @@ :embed embed} (when-let [component-id (:component-id @state)] - [:use {:x 0 :y 0 :href (str "#" component-id)}])]] - - ]))) + [:use {:x 0 :y 0 :href (str "#" component-id)}])]]]))) (defn- fetch-components-bundle [& {:keys [file-id]}] diff --git a/frontend/src/app/util/code_gen/style_css_formats.cljs b/frontend/src/app/util/code_gen/style_css_formats.cljs index ad38a6303..69f841dc9 100644 --- a/frontend/src/app/util/code_gen/style_css_formats.cljs +++ b/frontend/src/app/util/code_gen/style_css_formats.cljs @@ -31,8 +31,7 @@ :padding :size-array :margin :size-array :grid-template-rows :tracks - :grid-template-columns :tracks - }) + :grid-template-columns :tracks}) (defmulti format-value (fn [property _value _options] (css-formatters property))) @@ -139,7 +138,7 @@ [_ value options] (->> value (map #(format-shadow % options)) - (str/join ", " ))) + (str/join ", "))) (defmethod format-value :blur [_ value _options] diff --git a/frontend/src/app/util/color.cljs b/frontend/src/app/util/color.cljs index 5bc165580..d7fc4a2bd 100644 --- a/frontend/src/app/util/color.cljs +++ b/frontend/src/app/util/color.cljs @@ -56,7 +56,7 @@ (not= color :multiple) (case format :rgba (let [[r g b] (cc/hex->rgb color)] - (str/fmt "rgba(%s, %s, %s, %s)" r g b opacity)) + (str/fmt "rgba(%s, %s, %s, %s)" r g b opacity)) :hsla (let [[h s l] (cc/hex->hsl color)] (str/fmt "hsla(%s, %s, %s, %s)" h (* 100 s) (* 100 l) opacity)) diff --git a/frontend/src/app/util/css.cljs b/frontend/src/app/util/css.cljs index c0fbae2b6..5681bd307 100644 --- a/frontend/src/app/util/css.cljs +++ b/frontend/src/app/util/css.cljs @@ -32,6 +32,6 @@ (dom/set-attribute! style "type" "text/css") (dom/append-child! js/document.head style) (wrap-style-sheet style))))) - + diff --git a/frontend/src/app/util/debug.cljs b/frontend/src/app/util/debug.cljs index 7bf6304bd..b02cbf48f 100644 --- a/frontend/src/app/util/debug.cljs +++ b/frontend/src/app/util/debug.cljs @@ -77,8 +77,7 @@ :grid-layout ;; Show an overlay to the grid cells to know its properties - :grid-cells - }) + :grid-cells}) (defn enable! [option] diff --git a/frontend/src/app/util/dom/dnd.cljs b/frontend/src/app/util/dom/dnd.cljs index 06d21bc85..5ea91a22a 100644 --- a/frontend/src/app/util/dom/dnd.cljs +++ b/frontend/src/app/util/dom/dnd.cljs @@ -42,14 +42,14 @@ (let [;;currentTarget (.-currentTarget event) relatedTarget (.-relatedTarget event)] (js/console.log - label - "[" (:name data) "]" + label + "[" (:name data) "]" ;; (if currentTarget ;; (str "<" (.-localName currentTarget) " " (.-textContent currentTarget) ">") ;; "null") - (if relatedTarget - (str "<" (.-localName relatedTarget) " " (.-textContent relatedTarget) ">") - "null")))) + (if relatedTarget + (str "<" (.-localName relatedTarget) " " (.-textContent relatedTarget) ">") + "null")))) (defn set-data! ([e data] diff --git a/frontend/src/app/util/import/parser.cljs b/frontend/src/app/util/import/parser.cljs index 42063204f..28271502b 100644 --- a/frontend/src/app/util/import/parser.cljs +++ b/frontend/src/app/util/import/parser.cljs @@ -778,7 +778,7 @@ :stroke-cap-end (get-meta stroke-node :stroke-cap-end keyword)}))) (mapv d/without-nils) (filterv #(not= (:stroke-color %) "none")))] - + (if (seq strokes) strokes (->> [(-> (add-stroke {} node svg-data) @@ -848,7 +848,7 @@ (find-node :g) (find-node :g) (find-node :image))] - + (or (= type :image) (some? pattern-image)))) @@ -1034,8 +1034,7 @@ :layout-item-min-w (get-meta data :layout-item-min-w d/parse-double) :layout-item-align-self (get-meta data :layout-item-align-self keyword) :layout-item-align-absolute (get-meta data :layout-item-align-absolute str->bool) - :layout-item-align-index (get-meta data :layout-item-align-index d/parse-double) - })) + :layout-item-align-index (get-meta data :layout-item-align-index d/parse-double)})) props)) (defn parse-data diff --git a/frontend/src/app/util/path/format.cljs b/frontend/src/app/util/path/format.cljs index 28a43adf3..5a5860341 100644 --- a/frontend/src/app/util/path/format.cljs +++ b/frontend/src/app/util/path/format.cljs @@ -30,8 +30,7 @@ (.toFixed a path-precision) (.toFixed b path-precision) (.toFixed c path-precision) - (.toFixed d path-precision) - )) + (.toFixed d path-precision))) ([a b c d e] (js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}" (.toFixed a path-precision) @@ -46,8 +45,7 @@ (.toFixed c path-precision) (.toFixed d path-precision) (.toFixed e path-precision) - (.toFixed f path-precision) - )) + (.toFixed f path-precision))) ([a b c d e f g] (js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}" (.toFixed a path-precision) diff --git a/frontend/src/app/util/perf.cljs b/frontend/src/app/util/perf.cljs index d1c6b81ae..f958ba34f 100644 --- a/frontend/src/app/util/perf.cljs +++ b/frontend/src/app/util/perf.cljs @@ -8,11 +8,11 @@ "Performance profiling for react components." (:require-macros [app.util.perf]) (:require - [app.common.math :as mth] - [rumext.v2 :as mf] - [goog.functions :as f] ["react" :as react] - ["tdigest" :as td])) + ["tdigest" :as td] + [app.common.math :as mth] + [goog.functions :as f] + [rumext.v2 :as mf])) ;; For use it, just wrap the component you want to profile with ;; `perf/profiler` component and pass a label for debug purpose. diff --git a/frontend/src/app/util/queue.cljs b/frontend/src/app/util/queue.cljs index 9d3e02dbb..1c68763f1 100644 --- a/frontend/src/app/util/queue.cljs +++ b/frontend/src/app/util/queue.cljs @@ -55,12 +55,12 @@ ;; NOTE: Right now there are no cases where we need to cancel a process ;; but if we do, we can use this function #_(defn- cancel-process - [queue] - (l/dbg :hint "queue::cancel-process") - (let [timeout (unchecked-get queue "timeout")] - (when (some? timeout) - (js/clearTimeout timeout)) - (unchecked-set queue "timeout" nil))) + [queue] + (l/dbg :hint "queue::cancel-process") + (let [timeout (unchecked-get queue "timeout")] + (when (some? timeout) + (js/clearTimeout timeout)) + (unchecked-set queue "timeout" nil))) (defn- process [queue] diff --git a/frontend/src/app/util/router.cljs b/frontend/src/app/util/router.cljs index 83284596a..be54cb855 100644 --- a/frontend/src/app/util/router.cljs +++ b/frontend/src/app/util/router.cljs @@ -154,9 +154,9 @@ router (:router state)] (ts/schedule #(on-change router (.getToken ^js history))) (->> (rx/create (fn [subs] - (let [key (e/listen history "navigate" (fn [o] (rx/push! subs (.-token ^js o))))] - (fn [] - (bhistory/disable! history) - (e/unlistenByKey key))))) - (rx/take-until stoper) - (rx/subs! #(on-change router %))))))) + (let [key (e/listen history "navigate" (fn [o] (rx/push! subs (.-token ^js o))))] + (fn [] + (bhistory/disable! history) + (e/unlistenByKey key))))) + (rx/take-until stoper) + (rx/subs! #(on-change router %))))))) diff --git a/frontend/src/app/util/rxops.cljs b/frontend/src/app/util/rxops.cljs index f085d037e..0b08a23ae 100644 --- a/frontend/src/app/util/rxops.cljs +++ b/frontend/src/app/util/rxops.cljs @@ -31,8 +31,8 @@ args (js-arguments)] (this-as this - (set! (.-context state) this) - (set! (.-args state) args)) + (set! (.-context state) this) + (set! (.-args state) args)) (let [timeout-id (.-timeoutId state)] (if (>= (- ctime ltime) delay) diff --git a/frontend/src/app/util/simple_math.cljs b/frontend/src/app/util/simple_math.cljs index 33049a22e..7b203fdd1 100644 --- a/frontend/src/app/util/simple_math.cljs +++ b/frontend/src/app/util/simple_math.cljs @@ -15,7 +15,7 @@ (def parser (insta/parser - "opt-expr = '' | expr + "opt-expr = '' | expr expr = term ( ('+'|'-') expr)* | ('+'|'-'|'*'|'/') factor term = factor ( ('*'|'/') term)* @@ -98,7 +98,7 @@ (map :expecting) (filter some?))] (js/console.debug - (str "Invalid value '" text "' at index " index - ". Expected one of " expecting ".")) + (str "Invalid value '" text "' at index " index + ". Expected one of " expecting ".")) nil)))) diff --git a/frontend/src/app/util/snap_data.cljs b/frontend/src/app/util/snap_data.cljs index 39f259a0e..2fef2aa7b 100644 --- a/frontend/src/app/util/snap_data.cljs +++ b/frontend/src/app/util/snap_data.cljs @@ -76,11 +76,11 @@ parent-id (:parent-id frame) frame-data (if (:blocked frame) - [] - (->> (snap/shape->snap-points frame) - (mapv #(array-map :type :shape - :id frame-id - :pt %)))) + [] + (->> (snap/shape->snap-points frame) + (mapv #(array-map :type :shape + :id frame-id + :pt %)))) grid-x-data (get-grids-snap-points frame :x) grid-y-data (get-grids-snap-points frame :y)] diff --git a/frontend/src/app/util/thumbnails.cljs b/frontend/src/app/util/thumbnails.cljs index 210b5e7a8..e12963228 100644 --- a/frontend/src/app/util/thumbnails.cljs +++ b/frontend/src/app/util/thumbnails.cljs @@ -43,9 +43,9 @@ ([width height min-width max-width min-height max-height] (let [clamped-width (mth/clamp width min-width max-width) clamped-height (mth/clamp height min-height max-height)] - (if (> width height) - [clamped-width (get-height-from-width width height clamped-width)] - [(get-width-from-height width height clamped-height) clamped-height])))) + (if (> width height) + [clamped-width (get-height-from-width width height clamped-width)] + [(get-width-from-height width height clamped-height) clamped-height])))) (defn get-relative-size "Returns a recommended size given a width and height." diff --git a/frontend/src/app/worker.cljs b/frontend/src/app/worker.cljs index 8ca98681b..4b36decc9 100644 --- a/frontend/src/app/worker.cljs +++ b/frontend/src/app/worker.cljs @@ -132,16 +132,16 @@ (rx/subs! (fn [[messages dropped last]] ;; Send back the dropped messages replies - (doseq [msg dropped] - (drop-message msg)) + (doseq [msg dropped] + (drop-message msg)) ;; Process the message - (doseq [msg (vals messages)] - (handle-message msg)) + (doseq [msg (vals messages)] + (handle-message msg)) ;; After process the buffer we send a clear - (when-not (= last ::clear) - (rx/push! buffer ::clear))))))) + (when-not (= last ::clear) + (rx/push! buffer ::clear))))))) (defonce process-message-sub (subscribe-buffer-messages)) diff --git a/frontend/src/app/worker/export.cljs b/frontend/src/app/worker/export.cljs index 7425135f3..24de022fd 100644 --- a/frontend/src/app/worker/export.cljs +++ b/frontend/src/app/worker/export.cljs @@ -229,8 +229,7 @@ (contains? node :typography-ref-id) (conj {:id (:typography-ref-id node) - :file-id (:typography-ref-file node)}) - ))) + :file-id (:typography-ref-file node)})))) (into []))) @@ -406,8 +405,8 @@ (rx/reduce conj []) (rx/with-latest-from files-stream) (rx/merge-map (fn [[data files]] - (->> (uz/compress-files data) - (rx/map #(vector (get files file-id) %))))))))) + (->> (uz/compress-files data) + (rx/map #(vector (get files file-id) %))))))))) (defmethod impl/handler :export-binary-file [{:keys [files export-type] :as message}] @@ -450,5 +449,5 @@ (rx/catch (fn [err] (js/console.error err) (rx/of {:type :error - :error (str err) - :file-id (:id file)})))))))) + :error (str err) + :file-id (:id file)})))))))) diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index fe923aec7..3946075c8 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -319,9 +319,9 @@ (defn resolve-media [context file-id node] (if (or (and (not (cip/close? node)) - (cip/has-image? node)) - (cip/has-stroke-images? node) - (cip/has-fill-images? node)) + (cip/has-image? node)) + (cip/has-stroke-images? node) + (cip/has-fill-images? node)) (let [name (cip/get-image-name node) has-image (cip/has-image? node) image-data (cip/get-image-data node) @@ -332,34 +332,34 @@ (map #(assoc % :type :stroke))) images-data (concat - fill-images-data - stroke-images-data - (when has-image - [{:href image-data}]))] + fill-images-data + stroke-images-data + (when has-image + [{:href image-data}]))] (->> (rx/from images-data) (rx/mapcat (fn [image-data] (->> (upload-media-files context file-id name (:href image-data)) (rx/catch #(do (.error js/console "Error uploading media: " name) - (rx/of node))) + (rx/of node))) (rx/map #(vector (:id image-data) %))))) (rx/reduce (fn [acc [id data]] (assoc acc id data)) {}) (rx/map - (fn [images] - (let [media (get images nil)] - (-> node - (assoc :images images) - (cond-> (some? media) - (-> - (assoc-in [:attrs :penpot:media-id] (:id media)) - (assoc-in [:attrs :penpot:media-width] (:width media)) - (assoc-in [:attrs :penpot:media-height] (:height media)) - (assoc-in [:attrs :penpot:media-mtype] (:mtype media)) + (fn [images] + (let [media (get images nil)] + (-> node + (assoc :images images) + (cond-> (some? media) + (-> + (assoc-in [:attrs :penpot:media-id] (:id media)) + (assoc-in [:attrs :penpot:media-width] (:width media)) + (assoc-in [:attrs :penpot:media-height] (:height media)) + (assoc-in [:attrs :penpot:media-mtype] (:mtype media)) - (assoc-in [:attrs :penpot:fill-color] (:fill image-fill)) - (assoc-in [:attrs :penpot:fill-color-ref-file] (:fill-color-ref-file image-fill)) - (assoc-in [:attrs :penpot:fill-color-ref-id] (:fill-color-ref-id image-fill)) - (assoc-in [:attrs :penpot:fill-opacity] (:fill-opacity image-fill)) - (assoc-in [:attrs :penpot:fill-color-gradient] (:fill-color-gradient image-fill)))))))))) + (assoc-in [:attrs :penpot:fill-color] (:fill image-fill)) + (assoc-in [:attrs :penpot:fill-color-ref-file] (:fill-color-ref-file image-fill)) + (assoc-in [:attrs :penpot:fill-color-ref-id] (:fill-color-ref-id image-fill)) + (assoc-in [:attrs :penpot:fill-opacity] (:fill-opacity image-fill)) + (assoc-in [:attrs :penpot:fill-color-gradient] (:fill-color-gradient image-fill)))))))))) ;; If the node is not an image just return the node (->> (rx/of node) @@ -367,10 +367,10 @@ (defn media-node? [node] (or (and (cip/shape? node) - (cip/has-image? node) - (not (cip/close? node))) - (cip/has-stroke-images? node) - (cip/has-fill-images? node))) + (cip/has-image? node) + (not (cip/close? node))) + (cip/has-stroke-images? node) + (cip/has-fill-images? node))) (defn import-page [context file [page-id page-name content]] @@ -549,7 +549,7 @@ (rx/tap #(progress! context :upload-media (:name %))) (rx/merge-map #(rp/cmd! :upload-file-media-object %)) (rx/map (constantly media)) - (rx/catch #(do (.error js/console (str "Error uploading media: " (:name media)) ) + (rx/catch #(do (.error js/console (str "Error uploading media: " (:name media))) (rx/empty))))))) (rx/reduce fb/add-library-media file))) (rx/of file))) @@ -607,8 +607,8 @@ (->> (rx/from files) (rx/map #(merge context %)) (rx/merge-map (fn [context] - (->> (create-file context features) - (rx/map #(vector % (first (get data (:file-id context))))))))) + (->> (create-file context features) + (rx/map #(vector % (first (get data (:file-id context))))))))) (->> (rx/from files) (rx/map #(merge context %)) diff --git a/frontend/src/app/worker/selection.cljs b/frontend/src/app/worker/selection.cljs index bdf5847d6..6de386953 100644 --- a/frontend/src/app/worker/selection.cljs +++ b/frontend/src/app/worker/selection.cljs @@ -127,20 +127,20 @@ match-criteria? (fn [shape] (and (not (:hidden shape)) - (or (= :frame (:type shape)) ;; We return frames even if blocked - (not (:blocked shape))) - (or (not frame-id) (= frame-id (:frame-id shape))) - (case (:type shape) - :frame include-frames? - (:bool :group) (not ignore-groups?) - true) + (or (= :frame (:type shape)) ;; We return frames even if blocked + (not (:blocked shape))) + (or (not frame-id) (= frame-id (:frame-id shape))) + (case (:type shape) + :frame include-frames? + (:bool :group) (not ignore-groups?) + true) - (or (not full-frame?) - (not= :frame (:type shape)) - (and (d/not-empty? (:shapes shape)) - (gsh/rect-contains-shape? rect shape)) - (and (empty? (:shapes shape)) - (gsh/overlaps? shape rect))))) + (or (not full-frame?) + (not= :frame (:type shape)) + (and (d/not-empty? (:shapes shape)) + (gsh/rect-contains-shape? rect shape)) + (and (empty? (:shapes shape)) + (gsh/overlaps? shape rect))))) overlaps-outer-shape? (fn [shape] @@ -153,8 +153,8 @@ scalev (gpt/point (/ (+ (:width shape) padding) (:width shape)) - (/ (+ (:height shape) padding) - (:height shape))) + (/ (+ (:height shape) padding) + (:height shape))) outer-shape (-> shape (gsh/transform-shape (-> (ctm/empty) @@ -173,8 +173,8 @@ scalev (gpt/point (/ (- (:width shape) padding) (:width shape)) - (/ (- (:height shape) padding) - (:height shape))) + (/ (- (:height shape) padding) + (:height shape))) inner-shape (-> shape (gsh/transform-shape (-> (ctm/empty) diff --git a/frontend/src/app/worker/thumbnails.cljs b/frontend/src/app/worker/thumbnails.cljs index 0c548b52d..161ed28d5 100644 --- a/frontend/src/app/worker/thumbnails.cljs +++ b/frontend/src/app/worker/thumbnails.cljs @@ -66,17 +66,17 @@ background-color (dm/get-in page [:options :background]) element (if frame (mf/element render/frame-svg #js - {:objects objects - :frame frame - :use-thumbnails true - :background-color background-color - :aspect-ratio (/ 2 3)}) + {:objects objects + :frame frame + :use-thumbnails true + :background-color background-color + :aspect-ratio (/ 2 3)}) (mf/element render/page-svg #js - {:data page - :use-thumbnails true - :embed true - :aspect-ratio (/ 2 3)})) + {:data page + :use-thumbnails true + :embed true + :aspect-ratio (/ 2 3)})) data (rds/renderToStaticMarkup element)] {:data data :fonts @fonts/loaded-hints diff --git a/frontend/src/debug.cljs b/frontend/src/debug.cljs index 02964dcab..f944e0e70 100644 --- a/frontend/src/debug.cljs +++ b/frontend/src/debug.cljs @@ -433,10 +433,10 @@ (->> (rp/cmd! :update-file params) (rx/subs! (fn [_] - (when reload? - (dom/reload-current-window))) - (fn [cause] - (errors/print-error! cause))))))))) + (when reload? + (dom/reload-current-window))) + (fn [cause] + (errors/print-error! cause))))))))) (defn ^:export fix-orphan-shapes [] @@ -464,12 +464,12 @@ (rx/map http/conditional-decode-transit) (rx/mapcat rp/handle-response) (rx/subs! (fn [result] - (let [result (map (fn [row] - (update row :id str)) - result)] - (js/console.table (clj->js result)))) - (fn [cause] - (js/console.log "EE:" cause)))) + (let [result (map (fn [row] + (update row :id str)) + result)] + (js/console.table (clj->js result)))) + (fn [cause] + (js/console.log "EE:" cause)))) nil)) (defn ^:export take-snapshot @@ -482,9 +482,9 @@ (rx/map http/conditional-decode-transit) (rx/mapcat rp/handle-response) (rx/subs! (fn [{:keys [id]}] - (println "Snapshot saved:" (str id))) - (fn [cause] - (js/console.log "EE:" cause)))))) + (println "Snapshot saved:" (str id))) + (fn [cause] + (js/console.log "EE:" cause)))))) (defn ^:export restore-snapshot [id file-id] @@ -497,7 +497,7 @@ (rx/map http/conditional-decode-transit) (rx/mapcat rp/handle-response) (rx/subs! (fn [_] - (println "Snapshot restored " id) - #_(.reload js/location)) - (fn [cause] - (js/console.log "EE:" cause))))))) + (println "Snapshot restored " id) + #_(.reload js/location)) + (fn [cause] + (js/console.log "EE:" cause))))))) diff --git a/frontend/test/frontend_tests/helpers/pages.cljs b/frontend/test/frontend_tests/helpers/pages.cljs index 8de3e2d23..8f28aebb4 100644 --- a/frontend/test/frontend_tests/helpers/pages.cljs +++ b/frontend/test/frontend_tests/helpers/pages.cljs @@ -145,7 +145,7 @@ cfsh/prepare-create-artboard-from-selection)] (swap! idmap assoc instance-label (:id group) - component-label component-id) + component-label component-id) (update state :workspace-data cp/process-changes (:redo-changes changes)))) diff --git a/frontend/test/frontend_tests/helpers_shapes_test.cljs b/frontend/test/frontend_tests/helpers_shapes_test.cljs index 8b01ad7a1..929b4301f 100644 --- a/frontend/test/frontend_tests/helpers_shapes_test.cljs +++ b/frontend/test/frontend_tests/helpers_shapes_test.cljs @@ -46,13 +46,13 @@ color {:color clr/white} store (the/prepare-store state done - (fn [new-state] - (t/is (= (get-in new-state [:workspace-data - :recent-colors]) - [color]))))] + (fn [new-state] + (t/is (= (get-in new-state [:workspace-data + :recent-colors]) + [color]))))] (ptk/emit! - store - (dwl/add-recent-color color) - :the/end))))) + store + (dwl/add-recent-color color) + :the/end))))) diff --git a/frontend/test/frontend_tests/setup_test.cljs b/frontend/test/frontend_tests/setup_test.cljs index 047d8d2d0..81eab9c0e 100644 --- a/frontend/test/frontend_tests/setup_test.cljs +++ b/frontend/test/frontend_tests/setup_test.cljs @@ -6,8 +6,8 @@ (ns frontend-tests.setup-test (:require - [app.common.schema :as sm] [app.common.pprint :as pp] + [app.common.schema :as sm] [cljs.test :as t])) (.on js/process "uncaughtException" (fn [cause] @@ -26,6 +26,6 @@ (set! (.-exitCode js/process) 1))) #_(set! *main-cli-fn* - #(t/run-tests 'frontend-tests.test-snap-data - 'frontend-tests.test-simple-math - 'frontend-tests.test-range-tree)) + #(t/run-tests 'frontend-tests.test-snap-data + 'frontend-tests.test-simple-math + 'frontend-tests.test-range-tree)) diff --git a/frontend/test/frontend_tests/state_components_sync_test.cljs b/frontend/test/frontend_tests/state_components_sync_test.cljs index bfdbdedc8..7e74291f8 100644 --- a/frontend/test/frontend_tests/state_components_sync_test.cljs +++ b/frontend/test/frontend_tests/state_components_sync_test.cljs @@ -77,8 +77,7 @@ (t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:touched c-shape1) nil)) (t/is (= (:fill-color c-shape1) clr/white)) - (t/is (= (:fill-opacity c-shape1) 1)) - )))] + (t/is (= (:fill-opacity c-shape1) 1)))))] (ptk/emit! store @@ -90,24 +89,24 @@ (t/deftest test-touched-children-add (t/async done - (let [state (-> thp/initial-state - (thp/sample-page) - (thp/sample-shape :shape1 :rect - {:name "Rect 1" - :fill-color clr/white - :fill-opacity 1}) - (thp/make-component :main1 :component1 - [(thp/id :shape1)]) - (thp/instantiate-component :instance1 - (thp/id :component1)) - (thp/sample-shape :shape2 :circle - {:name "Circle 1"})) + (let [state (-> thp/initial-state + (thp/sample-page) + (thp/sample-shape :shape1 :rect + {:name "Rect 1" + :fill-color clr/white + :fill-opacity 1}) + (thp/make-component :main1 :component1 + [(thp/id :shape1)]) + (thp/instantiate-component :instance1 + (thp/id :component1)) + (thp/sample-shape :shape2 :circle + {:name "Circle 1"})) - instance1 (thp/get-shape state :instance1) - shape2 (thp/get-shape state :shape2) + instance1 (thp/get-shape state :instance1) + shape2 (thp/get-shape state :shape2) - store (the/prepare-store state done - (fn [new-state] + store (the/prepare-store state done + (fn [new-state] ;; Expected shape tree: ;; [Page: Page 1] ;; Root Frame @@ -120,28 +119,28 @@ ;; [Component: Rect 1] core.cljs:200:23 ;; --> [Page 1] Rect 1 - (let [[[group shape1] [c-group c-shape1] _component] - (thl/resolve-instance-and-main-allow-dangling - new-state - (thp/id :instance1))] + (let [[[group shape1] [c-group c-shape1] _component] + (thl/resolve-instance-and-main-allow-dangling + new-state + (thp/id :instance1))] - (t/is (= (:name group) "Rect 1")) - (t/is (nil? (:touched group))) - (t/is (= (:name shape1) "Rect 1")) - (t/is (= (:touched shape1) nil)) - (t/is (not= (:shape-ref shape1) nil)) + (t/is (= (:name group) "Rect 1")) + (t/is (nil? (:touched group))) + (t/is (= (:name shape1) "Rect 1")) + (t/is (= (:touched shape1) nil)) + (t/is (not= (:shape-ref shape1) nil)) - (t/is (= (:name c-group) "Rect 1")) - (t/is (= (:touched c-group) nil)) - (t/is (= (:shape-ref c-group) nil)) - (t/is (= (:name c-shape1) "Rect 1")) - (t/is (= (:touched c-shape1) nil)) - (t/is (= (:shape-ref c-shape1) nil)))))] + (t/is (= (:name c-group) "Rect 1")) + (t/is (= (:touched c-group) nil)) + (t/is (= (:shape-ref c-group) nil)) + (t/is (= (:name c-shape1) "Rect 1")) + (t/is (= (:touched c-shape1) nil)) + (t/is (= (:shape-ref c-shape1) nil)))))] - (ptk/emit! - store - (dw/relocate-shapes #{(:id shape2)} (:id instance1) 0) ;; We cant't change the structure of component copies, so this operation will do nothing - :the/end)))) + (ptk/emit! + store + (dw/relocate-shapes #{(:id shape2)} (:id instance1) 0) ;; We cant't change the structure of component copies, so this operation will do nothing + :the/end)))) (t/deftest test-touched-children-delete (t/async done @@ -201,9 +200,7 @@ (t/is (= (:shape-ref c-shape1) nil)) (t/is (= (:name c-shape2) "Rect 2")) (t/is (= (:touched c-shape2) nil)) - (t/is (= (:shape-ref c-shape2) nil)) - - )))] + (t/is (= (:shape-ref c-shape2) nil)))))] (ptk/emit! store @@ -212,26 +209,26 @@ (t/deftest test-touched-children-move (t/async done - (let [state (-> thp/initial-state - (thp/sample-page) - (thp/sample-shape :shape1 :rect - {:name "Rect 1"}) - (thp/sample-shape :shape2 :rect - {:name "Rect 2"}) - (thp/sample-shape :shape3 :rect - {:name "Rect 3"}) - (thp/make-component :main1 :component1 - [(thp/id :shape1) - (thp/id :shape2) - (thp/id :shape3)]) - (thp/instantiate-component :instance1 - (thp/id :component1))) + (let [state (-> thp/initial-state + (thp/sample-page) + (thp/sample-shape :shape1 :rect + {:name "Rect 1"}) + (thp/sample-shape :shape2 :rect + {:name "Rect 2"}) + (thp/sample-shape :shape3 :rect + {:name "Rect 3"}) + (thp/make-component :main1 :component1 + [(thp/id :shape1) + (thp/id :shape2) + (thp/id :shape3)]) + (thp/instantiate-component :instance1 + (thp/id :component1))) - [group1' shape1'] - (thl/resolve-instance state (thp/id :instance1)) + [group1' shape1'] + (thl/resolve-instance state (thp/id :instance1)) - store (the/prepare-store state done - (fn [new-state] + store (the/prepare-store state done + (fn [new-state] ;; Expected shape tree: ;; [Page: Page 1] ;; Root Frame @@ -249,41 +246,41 @@ ;; [Component: Component 1] ;; --> [Page 1] Component 1 - (let [[[group shape1 shape2 shape3] - [c-group c-shape1 c-shape2 c-shape3] _component] - (thl/resolve-instance-and-main-allow-dangling - new-state - (thp/id :instance1))] + (let [[[group shape1 shape2 shape3] + [c-group c-shape1 c-shape2 c-shape3] _component] + (thl/resolve-instance-and-main-allow-dangling + new-state + (thp/id :instance1))] - (t/is (= (:name group) "Component 1")) - (t/is (nil? (:touched group))) - (t/is (= (:name shape1) "Rect 1")) - (t/is (= (:touched shape1) nil)) - (t/is (not= (:shape-ref shape1) nil)) - (t/is (= (:name shape2) "Rect 2")) - (t/is (= (:touched shape2) nil)) - (t/is (not= (:shape-ref shape2) nil)) - (t/is (= (:name shape3) "Rect 3")) - (t/is (= (:touched shape3) nil)) - (t/is (not= (:shape-ref shape3) nil)) + (t/is (= (:name group) "Component 1")) + (t/is (nil? (:touched group))) + (t/is (= (:name shape1) "Rect 1")) + (t/is (= (:touched shape1) nil)) + (t/is (not= (:shape-ref shape1) nil)) + (t/is (= (:name shape2) "Rect 2")) + (t/is (= (:touched shape2) nil)) + (t/is (not= (:shape-ref shape2) nil)) + (t/is (= (:name shape3) "Rect 3")) + (t/is (= (:touched shape3) nil)) + (t/is (not= (:shape-ref shape3) nil)) - (t/is (= (:name c-group) "Component 1")) - (t/is (= (:touched c-group) nil)) - (t/is (= (:shape-ref c-group) nil)) - (t/is (= (:name c-shape1) "Rect 1")) - (t/is (= (:touched c-shape1) nil)) - (t/is (= (:shape-ref c-shape1) nil)) - (t/is (= (:name c-shape2) "Rect 2")) - (t/is (= (:touched c-shape2) nil)) - (t/is (= (:shape-ref c-shape2) nil)) - (t/is (= (:name c-shape3) "Rect 3")) - (t/is (= (:touched c-shape3) nil)) - (t/is (= (:shape-ref c-shape3) nil)))))] + (t/is (= (:name c-group) "Component 1")) + (t/is (= (:touched c-group) nil)) + (t/is (= (:shape-ref c-group) nil)) + (t/is (= (:name c-shape1) "Rect 1")) + (t/is (= (:touched c-shape1) nil)) + (t/is (= (:shape-ref c-shape1) nil)) + (t/is (= (:name c-shape2) "Rect 2")) + (t/is (= (:touched c-shape2) nil)) + (t/is (= (:shape-ref c-shape2) nil)) + (t/is (= (:name c-shape3) "Rect 3")) + (t/is (= (:touched c-shape3) nil)) + (t/is (= (:shape-ref c-shape3) nil)))))] - (ptk/emit! - store - (dw/relocate-shapes #{(:id shape1')} (:id group1') 2) ;; We cant't change the structure of component copies, so this operation will do nothing - :the/end)))) + (ptk/emit! + store + (dw/relocate-shapes #{(:id shape1')} (:id group1') 2) ;; We cant't change the structure of component copies, so this operation will do nothing + :the/end)))) (t/deftest test-touched-from-lib (t/async @@ -603,8 +600,7 @@ (t/is (= (:fill-color c-shape1) clr/black)) (t/is (= (:fill-opacity c-shape1) 0)) (t/is (= (:name c-shape2) "Rect 1")) - (t/is (= (:touched c-shape2) #{:fill-group})) - )))] + (t/is (= (:touched c-shape2) #{:fill-group})))))] (ptk/emit! store @@ -1504,28 +1500,28 @@ (t/deftest test-update-children-add (t/async done - (let [state (-> thp/initial-state - (thp/sample-page) - (thp/sample-shape :shape1 :rect - {:name "Rect 1" - :fill-color clr/white - :fill-opacity 1}) - (thp/make-component :main1 :component1 - [(thp/id :shape1)]) - (thp/instantiate-component :instance1 - (thp/id :component1)) - (thp/instantiate-component :instance2 - (thp/id :component1)) - (thp/sample-shape :shape2 :circle - {:name "Circle 1"})) + (let [state (-> thp/initial-state + (thp/sample-page) + (thp/sample-shape :shape1 :rect + {:name "Rect 1" + :fill-color clr/white + :fill-opacity 1}) + (thp/make-component :main1 :component1 + [(thp/id :shape1)]) + (thp/instantiate-component :instance1 + (thp/id :component1)) + (thp/instantiate-component :instance2 + (thp/id :component1)) + (thp/sample-shape :shape2 :circle + {:name "Circle 1"})) - file (wsh/get-local-file state) + file (wsh/get-local-file state) - instance1 (thp/get-shape state :instance1) - shape2 (thp/get-shape state :shape2) + instance1 (thp/get-shape state :instance1) + shape2 (thp/get-shape state :shape2) - store (the/prepare-store state done - (fn [new-state] + store (the/prepare-store state done + (fn [new-state] ;; Expected shape tree: ;; ;; [Page: Page 1] @@ -1543,58 +1539,58 @@ ;; [Component: Rect 1] ;; --> [Page 1] Rect 1 ;; - (let [[[main1 shape1] - [c-main1 c-shape1] component1] - (thl/resolve-instance-and-main - new-state - (thp/id :main1)) + (let [[[main1 shape1] + [c-main1 c-shape1] component1] + (thl/resolve-instance-and-main + new-state + (thp/id :main1)) - [[instance1 shape2] - [c-instance1 c-shape2] component2] - (thl/resolve-instance-and-main - new-state - (thp/id :instance1)) + [[instance1 shape2] + [c-instance1 c-shape2] component2] + (thl/resolve-instance-and-main + new-state + (thp/id :instance1)) - [[instance2 shape3] - [c-instance2 c-shape3] component3] - (thl/resolve-instance-and-main - new-state - (thp/id :instance2))] + [[instance2 shape3] + [c-instance2 c-shape3] component3] + (thl/resolve-instance-and-main + new-state + (thp/id :instance2))] - (t/is (= (:name main1) "Rect 1")) - (t/is (= (:touched main1) nil)) - (t/is (= (:shape-ref main1) nil)) - (t/is (= (:name shape1) "Rect 1")) - (t/is (= (:touched shape1) nil)) - (t/is (= (:shape-ref shape1) nil)) + (t/is (= (:name main1) "Rect 1")) + (t/is (= (:touched main1) nil)) + (t/is (= (:shape-ref main1) nil)) + (t/is (= (:name shape1) "Rect 1")) + (t/is (= (:touched shape1) nil)) + (t/is (= (:shape-ref shape1) nil)) - (t/is (= (:name instance1) "Rect 1")) - (t/is (= (:touched instance1) nil)) - (t/is (= (:shape-ref instance1) (:id c-main1))) - (t/is (= (:name shape2) "Rect 1")) - (t/is (= (:touched shape2) nil)) - (t/is (= (:shape-ref shape2) (:id c-shape1))) + (t/is (= (:name instance1) "Rect 1")) + (t/is (= (:touched instance1) nil)) + (t/is (= (:shape-ref instance1) (:id c-main1))) + (t/is (= (:name shape2) "Rect 1")) + (t/is (= (:touched shape2) nil)) + (t/is (= (:shape-ref shape2) (:id c-shape1))) - (t/is (= (:name instance2) "Rect 1")) - (t/is (= (:touched instance2) nil)) - (t/is (= (:shape-ref instance2) (:id c-main1))) - (t/is (= (:name shape3) "Rect 1")) - (t/is (= (:touched shape3) nil)) - (t/is (= (:shape-ref shape2) (:id c-shape1))) + (t/is (= (:name instance2) "Rect 1")) + (t/is (= (:touched instance2) nil)) + (t/is (= (:shape-ref instance2) (:id c-main1))) + (t/is (= (:name shape3) "Rect 1")) + (t/is (= (:touched shape3) nil)) + (t/is (= (:shape-ref shape2) (:id c-shape1))) - (t/is (= component1 component2 component3)) - (t/is (= c-main1 main1)) - (t/is (= c-shape1 shape1)) - (t/is (= c-instance1 c-main1)) - (t/is (= c-shape2 c-shape1)) - (t/is (= c-instance2 c-main1)) - (t/is (= c-shape3 c-shape1)))))] + (t/is (= component1 component2 component3)) + (t/is (= c-main1 main1)) + (t/is (= c-shape1 shape1)) + (t/is (= c-instance1 c-main1)) + (t/is (= c-shape2 c-shape1)) + (t/is (= c-instance2 c-main1)) + (t/is (= c-shape3 c-shape1)))))] - (ptk/emit! - store - (dw/relocate-shapes #{(:id shape2)} (:id instance1) 0) ;; We cant't change the structure of component copies, so this operation will do nothing - (dwl/update-component-sync (:id instance1) (:id file)) - :the/end)))) + (ptk/emit! + store + (dw/relocate-shapes #{(:id shape2)} (:id instance1) 0) ;; We cant't change the structure of component copies, so this operation will do nothing + (dwl/update-component-sync (:id instance1) (:id file)) + :the/end)))) (t/deftest test-update-children-delete (t/async done @@ -1709,30 +1705,30 @@ (t/deftest test-update-children-move (t/async done - (let [state (-> thp/initial-state - (thp/sample-page) - (thp/sample-shape :shape1 :rect - {:name "Rect 1"}) - (thp/sample-shape :shape2 :rect - {:name "Rect 2"}) - (thp/sample-shape :shape3 :rect - {:name "Rect 3"}) - (thp/make-component :main1 :component1 - [(thp/id :shape1) - (thp/id :shape2) - (thp/id :shape3)]) - (thp/instantiate-component :instance1 - (thp/id :component1)) - (thp/instantiate-component :instance2 - (thp/id :component1))) + (let [state (-> thp/initial-state + (thp/sample-page) + (thp/sample-shape :shape1 :rect + {:name "Rect 1"}) + (thp/sample-shape :shape2 :rect + {:name "Rect 2"}) + (thp/sample-shape :shape3 :rect + {:name "Rect 3"}) + (thp/make-component :main1 :component1 + [(thp/id :shape1) + (thp/id :shape2) + (thp/id :shape3)]) + (thp/instantiate-component :instance1 + (thp/id :component1)) + (thp/instantiate-component :instance2 + (thp/id :component1))) - file (wsh/get-local-file state) + file (wsh/get-local-file state) - [instance1 shape1' _shape2' _shape3'] - (thl/resolve-instance state (thp/id :instance1)) + [instance1 shape1' _shape2' _shape3'] + (thl/resolve-instance state (thp/id :instance1)) - store (the/prepare-store state done - (fn [new-state] + store (the/prepare-store state done + (fn [new-state] ;; Expected shape tree: ;; ;; [Page] @@ -1753,82 +1749,82 @@ ;; [Component 1] ;; page1 / Component 1 ;; - (let [[[main1 shape1 shape2 shape3] - [c-main1 c-shape1 c-shape2 c-shape3] component1] - (thl/resolve-instance-and-main - new-state - (thp/id :main1)) + (let [[[main1 shape1 shape2 shape3] + [c-main1 c-shape1 c-shape2 c-shape3] component1] + (thl/resolve-instance-and-main + new-state + (thp/id :main1)) - [[instance1 shape4 shape5 shape6] - [c-instance1 c-shape4 c-shape5 c-shape6] component2] - (thl/resolve-instance-and-main - new-state - (thp/id :instance1)) + [[instance1 shape4 shape5 shape6] + [c-instance1 c-shape4 c-shape5 c-shape6] component2] + (thl/resolve-instance-and-main + new-state + (thp/id :instance1)) - [[instance2 shape7 shape8 shape9] - [c-instance2 c-shape7 c-shape8 c-shape9] component3] - (thl/resolve-instance-and-main - new-state - (thp/id :instance2))] + [[instance2 shape7 shape8 shape9] + [c-instance2 c-shape7 c-shape8 c-shape9] component3] + (thl/resolve-instance-and-main + new-state + (thp/id :instance2))] - (t/is (= (:name main1) "Component 1")) - (t/is (= (:touched main1) nil)) - (t/is (= (:shape-ref main1) nil)) - (t/is (= (:name shape1) "Rect 1")) - (t/is (= (:touched shape1) nil)) - (t/is (= (:shape-ref shape1) nil)) - (t/is (= (:name shape2) "Rect 2")) - (t/is (= (:touched shape2) nil)) - (t/is (= (:shape-ref shape2) nil)) - (t/is (= (:name shape3) "Rect 3")) - (t/is (= (:touched shape3) nil)) - (t/is (= (:shape-ref shape3) nil)) + (t/is (= (:name main1) "Component 1")) + (t/is (= (:touched main1) nil)) + (t/is (= (:shape-ref main1) nil)) + (t/is (= (:name shape1) "Rect 1")) + (t/is (= (:touched shape1) nil)) + (t/is (= (:shape-ref shape1) nil)) + (t/is (= (:name shape2) "Rect 2")) + (t/is (= (:touched shape2) nil)) + (t/is (= (:shape-ref shape2) nil)) + (t/is (= (:name shape3) "Rect 3")) + (t/is (= (:touched shape3) nil)) + (t/is (= (:shape-ref shape3) nil)) - (t/is (= (:name instance1) "Component 1")) - (t/is (= (:touched instance1) nil)) - (t/is (= (:shape-ref instance1) (:id c-main1))) - (t/is (= (:name shape4) "Rect 1")) - (t/is (= (:touched shape4) nil)) - (t/is (= (:shape-ref shape4) (:id c-shape1))) - (t/is (= (:name shape5) "Rect 2")) - (t/is (= (:touched shape5) nil)) - (t/is (= (:shape-ref shape5) (:id c-shape2))) - (t/is (= (:name shape6) "Rect 3")) - (t/is (= (:touched shape6) nil)) - (t/is (= (:shape-ref shape6) (:id c-shape3))) + (t/is (= (:name instance1) "Component 1")) + (t/is (= (:touched instance1) nil)) + (t/is (= (:shape-ref instance1) (:id c-main1))) + (t/is (= (:name shape4) "Rect 1")) + (t/is (= (:touched shape4) nil)) + (t/is (= (:shape-ref shape4) (:id c-shape1))) + (t/is (= (:name shape5) "Rect 2")) + (t/is (= (:touched shape5) nil)) + (t/is (= (:shape-ref shape5) (:id c-shape2))) + (t/is (= (:name shape6) "Rect 3")) + (t/is (= (:touched shape6) nil)) + (t/is (= (:shape-ref shape6) (:id c-shape3))) - (t/is (= (:name instance2) "Component 1")) - (t/is (= (:touched instance2) nil)) - (t/is (= (:shape-ref instance2) (:id c-main1))) - (t/is (= (:name shape7) "Rect 1")) - (t/is (= (:touched shape7) nil)) - (t/is (= (:shape-ref shape7) (:id c-shape1))) - (t/is (= (:name shape8) "Rect 2")) - (t/is (= (:touched shape8) nil)) - (t/is (= (:shape-ref shape8) (:id c-shape2))) - (t/is (= (:name shape9) "Rect 3")) - (t/is (= (:touched shape9) nil)) - (t/is (= (:shape-ref shape9) (:id c-shape3))) + (t/is (= (:name instance2) "Component 1")) + (t/is (= (:touched instance2) nil)) + (t/is (= (:shape-ref instance2) (:id c-main1))) + (t/is (= (:name shape7) "Rect 1")) + (t/is (= (:touched shape7) nil)) + (t/is (= (:shape-ref shape7) (:id c-shape1))) + (t/is (= (:name shape8) "Rect 2")) + (t/is (= (:touched shape8) nil)) + (t/is (= (:shape-ref shape8) (:id c-shape2))) + (t/is (= (:name shape9) "Rect 3")) + (t/is (= (:touched shape9) nil)) + (t/is (= (:shape-ref shape9) (:id c-shape3))) - (t/is (= component1 component2 component3)) - (t/is (= c-main1 main1)) - (t/is (= c-shape1 shape1)) - (t/is (= c-shape2 shape2)) - (t/is (= c-shape3 shape3)) - (t/is (= c-instance1 c-main1)) - (t/is (= c-shape4 c-shape4)) - (t/is (= c-shape5 c-shape5)) - (t/is (= c-shape6 c-shape6)) - (t/is (= c-instance2 c-main1)) - (t/is (= c-shape7 c-shape7)) - (t/is (= c-shape8 c-shape8)) - (t/is (= c-shape9 c-shape9)))))] + (t/is (= component1 component2 component3)) + (t/is (= c-main1 main1)) + (t/is (= c-shape1 shape1)) + (t/is (= c-shape2 shape2)) + (t/is (= c-shape3 shape3)) + (t/is (= c-instance1 c-main1)) + (t/is (= c-shape4 c-shape4)) + (t/is (= c-shape5 c-shape5)) + (t/is (= c-shape6 c-shape6)) + (t/is (= c-instance2 c-main1)) + (t/is (= c-shape7 c-shape7)) + (t/is (= c-shape8 c-shape8)) + (t/is (= c-shape9 c-shape9)))))] - (ptk/emit! - store - (dw/relocate-shapes #{(:id shape1')} (:id instance1) 2) - (dwl/update-component-sync (:id instance1) (:id file)) - :the/end)))) + (ptk/emit! + store + (dw/relocate-shapes #{(:id shape1')} (:id instance1) 2) + (dwl/update-component-sync (:id instance1) (:id file)) + :the/end)))) (t/deftest test-update-from-lib (t/async done diff --git a/frontend/test/frontend_tests/state_components_test.cljs b/frontend/test/frontend_tests/state_components_test.cljs index 6b6dca73e..fb341f12e 100644 --- a/frontend/test/frontend_tests/state_components_test.cljs +++ b/frontend/test/frontend_tests/state_components_test.cljs @@ -341,8 +341,7 @@ ;; Rect 1 #--> ? ;; Rect 1 ---> ? ;;; - (let [ - [main1 shape1] + (let [[main1 shape1] (thl/resolve-noninstance new-state (thp/id :main1)) @@ -380,10 +379,7 @@ (t/is (some? (:objects component3))) (t/is (= (:name saved-main1) "Rect 1")) - (t/is (= (:name saved-shape2) "Rect 1")) - - ))) - ] + (t/is (= (:name saved-shape2) "Rect 1")))))] (ptk/emit! store (dwl/delete-component {:id (thp/id :component1)}) :the/end)))) diff --git a/frontend/test/frontend_tests/test_helpers_shapes.cljs b/frontend/test/frontend_tests/test_helpers_shapes.cljs index 45921648e..11e552542 100644 --- a/frontend/test/frontend_tests/test_helpers_shapes.cljs +++ b/frontend/test/frontend_tests/test_helpers_shapes.cljs @@ -40,13 +40,13 @@ color {:color clr/white} store (the/prepare-store state done - (fn [new-state] - (t/is (= (get-in new-state [:workspace-data - :recent-colors]) - [color]))))] + (fn [new-state] + (t/is (= (get-in new-state [:workspace-data + :recent-colors]) + [color]))))] (ptk/emit! - store - (dwl/add-recent-color color) - :the/end))))) + store + (dwl/add-recent-color color) + :the/end))))) diff --git a/frontend/test/frontend_tests/util_range_tree_test.cljs b/frontend/test/frontend_tests/util_range_tree_test.cljs index 5f3627f73..4d5e75e66 100644 --- a/frontend/test/frontend_tests/util_range_tree_test.cljs +++ b/frontend/test/frontend_tests/util_range_tree_test.cljs @@ -18,14 +18,14 @@ (t/deftest test-insert-and-retrieve-data (t/testing "Retrieve on empty tree" - (let [tree (rt/make-tree)] - (t/is (= (rt/get tree 100) nil)))) + (let [tree (rt/make-tree)] + (t/is (= (rt/get tree 100) nil)))) (t/testing "First insert/retrieval" - (let [tree (-> (rt/make-tree) - (rt/insert 100 :a))] - (t/is (= (rt/get tree 100) [:a])) - (t/is (= (rt/get tree 200) nil)))) + (let [tree (-> (rt/make-tree) + (rt/insert 100 :a))] + (t/is (= (rt/get tree 100) [:a])) + (t/is (= (rt/get tree 200) nil)))) (t/testing "Insert best case scenario" (let [tree (-> (rt/make-tree) diff --git a/frontend/test/frontend_tests/util_simple_math_test.cljs b/frontend/test/frontend_tests/util_simple_math_test.cljs index acd23526c..15bb2198c 100644 --- a/frontend/test/frontend_tests/util_simple_math_test.cljs +++ b/frontend/test/frontend_tests/util_simple_math_test.cljs @@ -6,10 +6,10 @@ (ns frontend-tests.util-simple-math-test (:require - [cljs.test :as t :include-macros true] - [cljs.pprint :refer [pprint]] [app.common.math :as cm] - [app.util.simple-math :as sm])) + [app.util.simple-math :as sm] + [cljs.pprint :refer [pprint]] + [cljs.test :as t :include-macros true])) (t/deftest test-parser-inst (t/testing "Evaluate an empty string" @@ -86,7 +86,5 @@ (t/testing "Evaluate a complex operation with decimals" (let [result1 (sm/expr-eval "(20.333 + 10%) * (1 / 3)" 20) result2 (sm/expr-eval "(20,333 + 10%) * (1 / 3)" 20)] - (t/is (cm/close? result1 result2 7.44433333)))) - - ) + (t/is (cm/close? result1 result2 7.44433333))))) diff --git a/frontend/test/frontend_tests/util_snap_data_test.cljs b/frontend/test/frontend_tests/util_snap_data_test.cljs index 2eafa7a87..bdd42b5af 100644 --- a/frontend/test/frontend_tests/util_snap_data_test.cljs +++ b/frontend/test/frontend_tests/util_snap_data_test.cljs @@ -7,8 +7,8 @@ (ns frontend-tests.util-snap-data-test (:require [app.common.files.builder :as fb] - [app.common.uuid :as uuid] [app.common.types.shape :as cts] + [app.common.uuid :as uuid] [app.util.snap-data :as sd] [cljs.pprint :refer [pprint]] [cljs.test :as t :include-macros true])) @@ -418,8 +418,7 @@ result-zero-x-2 (sd/query data (:id page) uuid/zero :x [0 200]) result-zero-y-2 (sd/query data (:id page) uuid/zero :y [0 200]) result-frame-x-2 (sd/query data (:id page) frame-id :x [0 200]) - result-frame-y-2 (sd/query data (:id page) frame-id :y [0 200]) - ] + result-frame-y-2 (sd/query data (:id page) frame-id :y [0 200])] (t/is (some? data)) @@ -431,5 +430,4 @@ (t/is (= (count result-zero-x-2) 1)) (t/is (= (count result-zero-y-2) 0)) (t/is (= (count result-frame-x-2) 1)) - (t/is (= (count result-frame-y-2) 0)))) - ) + (t/is (= (count result-frame-y-2) 0)))))