mirror of
https://github.com/penpot/penpot.git
synced 2025-07-23 05:57:28 +02:00
💄 Format frontend code
This commit is contained in:
parent
b6ecc8b1be
commit
833871df65
150 changed files with 1735 additions and 1770 deletions
|
@ -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]
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -32,6 +32,6 @@
|
|||
(dom/set-attribute! style "type" "text/css")
|
||||
(dom/append-child! js/document.head style)
|
||||
(wrap-style-sheet style)))))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -77,8 +77,7 @@
|
|||
:grid-layout
|
||||
|
||||
;; Show an overlay to the grid cells to know its properties
|
||||
:grid-cells
|
||||
})
|
||||
:grid-cells})
|
||||
|
||||
(defn enable!
|
||||
[option]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 %)))))))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(def parser
|
||||
(insta/parser
|
||||
"opt-expr = '' | expr
|
||||
"opt-expr = '' | expr
|
||||
expr = term (<spaces> ('+'|'-') <spaces> expr)* |
|
||||
('+'|'-'|'*'|'/') <spaces> factor
|
||||
term = factor (<spaces> ('*'|'/') <spaces> 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))))
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
||||
|
|
|
@ -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."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue