mirror of
https://github.com/penpot/penpot.git
synced 2025-07-04 04:37:16 +02:00
💄 Format frontend code
This commit is contained in:
parent
b6ecc8b1be
commit
833871df65
150 changed files with 1735 additions and 1770 deletions
|
@ -3,6 +3,7 @@
|
||||||
:remove-surrounding-whitespace? true
|
:remove-surrounding-whitespace? true
|
||||||
:remove-consecutive-blank-lines? false
|
:remove-consecutive-blank-lines? false
|
||||||
:extra-indents {rumext.v2/fnc [[:inner 0]]
|
:extra-indents {rumext.v2/fnc [[:inner 0]]
|
||||||
|
cljs.test/async [[:inner 0]]
|
||||||
promesa.exec/thread [[:inner 0]]
|
promesa.exec/thread [[:inner 0]]
|
||||||
specify! [[:inner 0] [:inner 1]]}
|
specify! [[:inner 0] [:inner 1]]}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1953,8 +1953,7 @@
|
||||||
(ptk/reify ::paste-shapes
|
(ptk/reify ::paste-shapes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [
|
(let [file-id (:current-file-id state)
|
||||||
file-id (:current-file-id state)
|
|
||||||
page (wsh/lookup-page state)
|
page (wsh/lookup-page state)
|
||||||
|
|
||||||
media-idx (->> (:media pdata)
|
media-idx (->> (:media pdata)
|
||||||
|
|
|
@ -64,8 +64,7 @@
|
||||||
|
|
||||||
:zoom-selected {:tooltip (ds/shift "2")
|
:zoom-selected {:tooltip (ds/shift "2")
|
||||||
:command "shift+2"
|
:command "shift+2"
|
||||||
:fn #(st/emit! dw/zoom-to-selected-shape)}
|
:fn #(st/emit! dw/zoom-to-selected-shape)}})
|
||||||
})
|
|
||||||
|
|
||||||
(defn get-tooltip [shortcut]
|
(defn get-tooltip [shortcut]
|
||||||
(assert (contains? shortcuts shortcut) (str shortcut))
|
(assert (contains? shortcuts shortcut) (str shortcut))
|
||||||
|
|
|
@ -544,8 +544,7 @@
|
||||||
:layout-item-margin-type
|
:layout-item-margin-type
|
||||||
:layout-grid-cells
|
:layout-grid-cells
|
||||||
:layout-grid-columns
|
:layout-grid-columns
|
||||||
:layout-grid-rows
|
:layout-grid-rows]})
|
||||||
]})
|
|
||||||
;; We've applied the text-modifier so we can dissoc the temporary data
|
;; We've applied the text-modifier so we can dissoc the temporary data
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(update state :workspace-text-modifier #(apply dissoc % ids)))
|
(update state :workspace-text-modifier #(apply dissoc % ids)))
|
||||||
|
|
|
@ -145,8 +145,7 @@
|
||||||
:revn file-revn
|
:revn file-revn
|
||||||
:session-id sid
|
:session-id sid
|
||||||
:changes-with-metadata (into [] changes)
|
:changes-with-metadata (into [] changes)
|
||||||
:features features
|
:features features}]
|
||||||
}]
|
|
||||||
|
|
||||||
(->> (rp/cmd! :update-file params)
|
(->> (rp/cmd! :update-file params)
|
||||||
(rx/mapcat (fn [lagged]
|
(rx/mapcat (fn [lagged]
|
||||||
|
|
|
@ -495,7 +495,7 @@
|
||||||
(not duplicating-component?)
|
(not duplicating-component?)
|
||||||
(ctk/detach-shape))
|
(ctk/detach-shape))
|
||||||
|
|
||||||
; We want the first added object to touch it's parent, but not subsequent children
|
;; We want the first added object to touch it's parent, but not subsequent children
|
||||||
changes (-> (pcb/add-object changes new-obj {:ignore-touched (and duplicating-component? child?)})
|
changes (-> (pcb/add-object changes new-obj {:ignore-touched (and duplicating-component? child?)})
|
||||||
(pcb/amend-last-change #(assoc % :old-id (:id obj)))
|
(pcb/amend-last-change #(assoc % :old-id (:id obj)))
|
||||||
(cond-> (ctl/grid-layout? objects (:parent-id obj))
|
(cond-> (ctl/grid-layout? objects (:parent-id obj))
|
||||||
|
@ -506,7 +506,7 @@
|
||||||
(and is-component-root? is-component-main?)
|
(and is-component-root? is-component-main?)
|
||||||
(regenerate-component new-obj))
|
(regenerate-component new-obj))
|
||||||
|
|
||||||
; This is needed for the recursive call to find the new object as parent
|
;; This is needed for the recursive call to find the new object as parent
|
||||||
page' (ctst/add-shape (:id new-obj)
|
page' (ctst/add-shape (:id new-obj)
|
||||||
new-obj
|
new-obj
|
||||||
{:objects objects}
|
{:objects objects}
|
||||||
|
|
|
@ -127,8 +127,7 @@
|
||||||
:attrs dwt/text-attrs}))))
|
:attrs dwt/text-attrs}))))
|
||||||
|
|
||||||
(defn- update-attrs [shape props]
|
(defn- update-attrs [shape props]
|
||||||
(let [
|
(let [text-values (calculate-text-values shape)
|
||||||
text-values (calculate-text-values shape)
|
|
||||||
font-size (d/parse-double (:font-size text-values))
|
font-size (d/parse-double (:font-size text-values))
|
||||||
line-height (d/parse-double (:line-height text-values))
|
line-height (d/parse-double (:line-height text-values))
|
||||||
letter-spacing (d/parse-double (:letter-spacing text-values))
|
letter-spacing (d/parse-double (:letter-spacing text-values))
|
||||||
|
@ -166,8 +165,7 @@
|
||||||
all-underline? (every? #(= (:text-decoration %) "underline") text-values)
|
all-underline? (every? #(= (:text-decoration %) "underline") text-values)
|
||||||
all-line-through? (every? #(= (:text-decoration %) "line-through") text-values)
|
all-line-through? (every? #(= (:text-decoration %) "line-through") text-values)
|
||||||
all-bold? (every? #(is-bold? (:font-variant-id %)) text-values)
|
all-bold? (every? #(is-bold? (:font-variant-id %)) text-values)
|
||||||
all-italic? (every? #(is-italic? (:font-variant-id %)) text-values)
|
all-italic? (every? #(is-italic? (:font-variant-id %)) text-values)]
|
||||||
]
|
|
||||||
(cond
|
(cond
|
||||||
(= (:text-decoration props) "toggle-underline")
|
(= (:text-decoration props) "toggle-underline")
|
||||||
(if all-underline?
|
(if all-underline?
|
||||||
|
|
|
@ -339,8 +339,7 @@
|
||||||
|
|
||||||
(and (d/not-empty? color-attrs) (nil? (:fills node)))
|
(and (d/not-empty? color-attrs) (nil? (:fills node)))
|
||||||
(-> (dissoc :fill-color :fill-opacity :fill-color-ref-id :fill-color-ref-file :fill-color-gradient)
|
(-> (dissoc :fill-color :fill-opacity :fill-color-ref-id :fill-color-ref-file :fill-color-gradient)
|
||||||
(assoc :fills [color-attrs])))
|
(assoc :fills [color-attrs])))))
|
||||||
))
|
|
||||||
|
|
||||||
(defn migrate-content
|
(defn migrate-content
|
||||||
[content]
|
[content]
|
||||||
|
|
|
@ -66,8 +66,7 @@
|
||||||
:form-data? true}
|
:form-data? true}
|
||||||
|
|
||||||
:export-binfile {:response-type :blob}
|
:export-binfile {:response-type :blob}
|
||||||
:retrieve-list-of-builtin-templates {:query-params :all}
|
:retrieve-list-of-builtin-templates {:query-params :all}})
|
||||||
})
|
|
||||||
|
|
||||||
(defn- send!
|
(defn- send!
|
||||||
"A simple helper for a common case of sending and receiving transit
|
"A simple helper for a common case of sending and receiving transit
|
||||||
|
|
|
@ -134,8 +134,7 @@
|
||||||
[:div {:class (stl/css :action-buttons)
|
[:div {:class (stl/css :action-buttons)
|
||||||
:data-test "change-email-submit"}
|
:data-test "change-email-submit"}
|
||||||
[:> fm/submit-button*
|
[:> fm/submit-button*
|
||||||
{:label (tr "modals.change-email.submit")}]]]]]]
|
{:label (tr "modals.change-email.submit")}]]]]]]))
|
||||||
))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -311,6 +311,4 @@
|
||||||
|
|
||||||
(reset! prev-modifiers modifiers)
|
(reset! prev-modifiers modifiers)
|
||||||
(reset! prev-transforms transforms)
|
(reset! prev-transforms transforms)
|
||||||
(reset! prev-shapes shapes))
|
(reset! prev-shapes shapes))))
|
||||||
|
|
||||||
))
|
|
||||||
|
|
|
@ -264,7 +264,5 @@
|
||||||
(when select-only
|
(when select-only
|
||||||
[:button {:class (stl/css :select-btn)
|
[:button {:class (stl/css :select-btn)
|
||||||
:on-click handle-select}
|
:on-click handle-select}
|
||||||
i/move-refactor])]
|
i/move-refactor])]))
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,4 @@
|
||||||
[:& cmt/draft-thread {:draft draft
|
[:& cmt/draft-thread {:draft draft
|
||||||
:on-cancel on-draft-cancel
|
:on-cancel on-draft-cancel
|
||||||
:on-submit on-draft-submit
|
:on-submit on-draft-submit
|
||||||
:zoom zoom}])]]]
|
:zoom zoom}])]]]))
|
||||||
|
|
||||||
))
|
|
||||||
|
|
|
@ -90,8 +90,7 @@
|
||||||
:height h
|
:height h
|
||||||
:rx (obj/get border-attrs "rx")
|
:rx (obj/get border-attrs "rx")
|
||||||
:ry (obj/get border-attrs "ry")
|
:ry (obj/get border-attrs "ry")
|
||||||
:d (obj/get border-attrs "d")})))
|
:d (obj/get border-attrs "d")})))]
|
||||||
]
|
|
||||||
|
|
||||||
[:> outline-type props]))
|
[:> outline-type props]))
|
||||||
|
|
||||||
|
|
|
@ -217,9 +217,7 @@
|
||||||
:embed embed}
|
:embed embed}
|
||||||
|
|
||||||
(when-let [component-id (:component-id @state)]
|
(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
|
(defn- fetch-components-bundle
|
||||||
[& {:keys [file-id]}]
|
[& {:keys [file-id]}]
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
:padding :size-array
|
:padding :size-array
|
||||||
:margin :size-array
|
:margin :size-array
|
||||||
:grid-template-rows :tracks
|
:grid-template-rows :tracks
|
||||||
:grid-template-columns :tracks
|
:grid-template-columns :tracks})
|
||||||
})
|
|
||||||
|
|
||||||
(defmulti format-value
|
(defmulti format-value
|
||||||
(fn [property _value _options] (css-formatters property)))
|
(fn [property _value _options] (css-formatters property)))
|
||||||
|
|
|
@ -77,8 +77,7 @@
|
||||||
:grid-layout
|
:grid-layout
|
||||||
|
|
||||||
;; Show an overlay to the grid cells to know its properties
|
;; Show an overlay to the grid cells to know its properties
|
||||||
:grid-cells
|
:grid-cells})
|
||||||
})
|
|
||||||
|
|
||||||
(defn enable!
|
(defn enable!
|
||||||
[option]
|
[option]
|
||||||
|
|
|
@ -1034,8 +1034,7 @@
|
||||||
:layout-item-min-w (get-meta data :layout-item-min-w d/parse-double)
|
: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-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-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))
|
props))
|
||||||
|
|
||||||
(defn parse-data
|
(defn parse-data
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
(.toFixed a path-precision)
|
(.toFixed a path-precision)
|
||||||
(.toFixed b path-precision)
|
(.toFixed b path-precision)
|
||||||
(.toFixed c path-precision)
|
(.toFixed c path-precision)
|
||||||
(.toFixed d path-precision)
|
(.toFixed d path-precision)))
|
||||||
))
|
|
||||||
([a b c d e]
|
([a b c d e]
|
||||||
(js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}"
|
(js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}"
|
||||||
(.toFixed a path-precision)
|
(.toFixed a path-precision)
|
||||||
|
@ -46,8 +45,7 @@
|
||||||
(.toFixed c path-precision)
|
(.toFixed c path-precision)
|
||||||
(.toFixed d path-precision)
|
(.toFixed d path-precision)
|
||||||
(.toFixed e path-precision)
|
(.toFixed e path-precision)
|
||||||
(.toFixed f path-precision)
|
(.toFixed f path-precision)))
|
||||||
))
|
|
||||||
([a b c d e f g]
|
([a b c d e f g]
|
||||||
(js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}"
|
(js* "\"\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}+\",\"+~{}"
|
||||||
(.toFixed a path-precision)
|
(.toFixed a path-precision)
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
"Performance profiling for react components."
|
"Performance profiling for react components."
|
||||||
(:require-macros [app.util.perf])
|
(:require-macros [app.util.perf])
|
||||||
(:require
|
(:require
|
||||||
[app.common.math :as mth]
|
|
||||||
[rumext.v2 :as mf]
|
|
||||||
[goog.functions :as f]
|
|
||||||
["react" :as react]
|
["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
|
;; For use it, just wrap the component you want to profile with
|
||||||
;; `perf/profiler` component and pass a label for debug purpose.
|
;; `perf/profiler` component and pass a label for debug purpose.
|
||||||
|
|
|
@ -229,8 +229,7 @@
|
||||||
|
|
||||||
(contains? node :typography-ref-id)
|
(contains? node :typography-ref-id)
|
||||||
(conj {:id (:typography-ref-id node)
|
(conj {:id (:typography-ref-id node)
|
||||||
:file-id (:typography-ref-file node)})
|
:file-id (:typography-ref-file node)}))))
|
||||||
)))
|
|
||||||
|
|
||||||
(into [])))
|
(into [])))
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
(ns frontend-tests.setup-test
|
(ns frontend-tests.setup-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
|
||||||
[app.common.pprint :as pp]
|
[app.common.pprint :as pp]
|
||||||
|
[app.common.schema :as sm]
|
||||||
[cljs.test :as t]))
|
[cljs.test :as t]))
|
||||||
|
|
||||||
(.on js/process "uncaughtException" (fn [cause]
|
(.on js/process "uncaughtException" (fn [cause]
|
||||||
|
|
|
@ -77,8 +77,7 @@
|
||||||
(t/is (= (:name c-shape1) "Rect 1"))
|
(t/is (= (:name c-shape1) "Rect 1"))
|
||||||
(t/is (= (:touched c-shape1) nil))
|
(t/is (= (:touched c-shape1) nil))
|
||||||
(t/is (= (:fill-color c-shape1) clr/white))
|
(t/is (= (:fill-color c-shape1) clr/white))
|
||||||
(t/is (= (:fill-opacity c-shape1) 1))
|
(t/is (= (:fill-opacity c-shape1) 1)))))]
|
||||||
)))]
|
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
@ -201,9 +200,7 @@
|
||||||
(t/is (= (:shape-ref c-shape1) nil))
|
(t/is (= (:shape-ref c-shape1) nil))
|
||||||
(t/is (= (:name c-shape2) "Rect 2"))
|
(t/is (= (:name c-shape2) "Rect 2"))
|
||||||
(t/is (= (:touched c-shape2) nil))
|
(t/is (= (:touched c-shape2) nil))
|
||||||
(t/is (= (:shape-ref c-shape2) nil))
|
(t/is (= (:shape-ref c-shape2) nil)))))]
|
||||||
|
|
||||||
)))]
|
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
@ -603,8 +600,7 @@
|
||||||
(t/is (= (:fill-color c-shape1) clr/black))
|
(t/is (= (:fill-color c-shape1) clr/black))
|
||||||
(t/is (= (:fill-opacity c-shape1) 0))
|
(t/is (= (:fill-opacity c-shape1) 0))
|
||||||
(t/is (= (:name c-shape2) "Rect 1"))
|
(t/is (= (:name c-shape2) "Rect 1"))
|
||||||
(t/is (= (:touched c-shape2) #{:fill-group}))
|
(t/is (= (:touched c-shape2) #{:fill-group})))))]
|
||||||
)))]
|
|
||||||
|
|
||||||
(ptk/emit!
|
(ptk/emit!
|
||||||
store
|
store
|
||||||
|
|
|
@ -341,8 +341,7 @@
|
||||||
;; Rect 1 #--> ?
|
;; Rect 1 #--> ?
|
||||||
;; Rect 1 ---> ?
|
;; Rect 1 ---> ?
|
||||||
;;;
|
;;;
|
||||||
(let [
|
(let [[main1 shape1]
|
||||||
[main1 shape1]
|
|
||||||
(thl/resolve-noninstance
|
(thl/resolve-noninstance
|
||||||
new-state
|
new-state
|
||||||
(thp/id :main1))
|
(thp/id :main1))
|
||||||
|
@ -380,10 +379,7 @@
|
||||||
(t/is (some? (:objects component3)))
|
(t/is (some? (:objects component3)))
|
||||||
|
|
||||||
(t/is (= (:name saved-main1) "Rect 1"))
|
(t/is (= (:name saved-main1) "Rect 1"))
|
||||||
(t/is (= (:name saved-shape2) "Rect 1"))
|
(t/is (= (:name saved-shape2) "Rect 1")))))]
|
||||||
|
|
||||||
)))
|
|
||||||
]
|
|
||||||
(ptk/emit! store
|
(ptk/emit! store
|
||||||
(dwl/delete-component {:id (thp/id :component1)})
|
(dwl/delete-component {:id (thp/id :component1)})
|
||||||
:the/end))))
|
:the/end))))
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
|
|
||||||
(ns frontend-tests.util-simple-math-test
|
(ns frontend-tests.util-simple-math-test
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :as t :include-macros true]
|
|
||||||
[cljs.pprint :refer [pprint]]
|
|
||||||
[app.common.math :as cm]
|
[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/deftest test-parser-inst
|
||||||
(t/testing "Evaluate an empty string"
|
(t/testing "Evaluate an empty string"
|
||||||
|
@ -86,7 +86,5 @@
|
||||||
(t/testing "Evaluate a complex operation with decimals"
|
(t/testing "Evaluate a complex operation with decimals"
|
||||||
(let [result1 (sm/expr-eval "(20.333 + 10%) * (1 / 3)" 20)
|
(let [result1 (sm/expr-eval "(20.333 + 10%) * (1 / 3)" 20)
|
||||||
result2 (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)))))
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
(ns frontend-tests.util-snap-data-test
|
(ns frontend-tests.util-snap-data-test
|
||||||
(:require
|
(:require
|
||||||
[app.common.files.builder :as fb]
|
[app.common.files.builder :as fb]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
[app.util.snap-data :as sd]
|
[app.util.snap-data :as sd]
|
||||||
[cljs.pprint :refer [pprint]]
|
[cljs.pprint :refer [pprint]]
|
||||||
[cljs.test :as t :include-macros true]))
|
[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-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-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-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))
|
(t/is (some? data))
|
||||||
|
|
||||||
|
@ -431,5 +430,4 @@
|
||||||
(t/is (= (count result-zero-x-2) 1))
|
(t/is (= (count result-zero-x-2) 1))
|
||||||
(t/is (= (count result-zero-y-2) 0))
|
(t/is (= (count result-zero-y-2) 0))
|
||||||
(t/is (= (count result-frame-x-2) 1))
|
(t/is (= (count result-frame-x-2) 1))
|
||||||
(t/is (= (count result-frame-y-2) 0))))
|
(t/is (= (count result-frame-y-2) 0)))))
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue