💄 Format frontend code

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

View file

@ -3,6 +3,7 @@
:remove-surrounding-whitespace? true
:remove-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]]}
}

View file

@ -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)

View file

@ -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))

View file

@ -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)))

View file

@ -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]

View file

@ -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}

View file

@ -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?

View file

@ -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]

View file

@ -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

View file

@ -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")}]]]]]]))

View file

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

View file

@ -264,7 +264,5 @@
(when select-only
[:button {:class (stl/css :select-btn)
:on-click handle-select}
i/move-refactor])]
))
i/move-refactor])]))

View file

@ -78,6 +78,4 @@
[:& cmt/draft-thread {:draft draft
:on-cancel on-draft-cancel
:on-submit on-draft-submit
:zoom zoom}])]]]
))
:zoom zoom}])]]]))

View file

@ -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]))

View file

@ -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]}]

View file

@ -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)))

View file

@ -77,8 +77,7 @@
:grid-layout
;; Show an overlay to the grid cells to know its properties
:grid-cells
})
:grid-cells})
(defn enable!
[option]

View file

@ -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

View file

@ -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)

View file

@ -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.

View file

@ -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 [])))

View file

@ -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]

View file

@ -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
@ -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
@ -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

View file

@ -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))))

View file

@ -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)))))

View file

@ -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)))))