0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 06:32:38 -05:00

🐛 Fixed problem with borders in images

This commit is contained in:
alonso.torres 2021-01-29 21:45:13 +01:00
parent b2bde8d97e
commit f4bbcdb382

View file

@ -30,11 +30,13 @@
(defn format-stroke [_ shape] (defn format-stroke [_ shape]
(let [width (:stroke-width shape) (let [width (:stroke-width shape)
style (name (:stroke-style shape)) style (let [style (:stroke-style shape)]
(when (keyword? style) (name style)))
color {:color (:stroke-color shape) color {:color (:stroke-color shape)
:opacity (:stroke-opacity shape) :opacity (:stroke-opacity shape)
:gradient (:stroke-color-gradient shape)}] :gradient (:stroke-color-gradient shape)}]
(str/format "%spx %s %s" width style (uc/color->background color)))) (if-not (= :none (:stroke-style shape))
(str/format "%spx %s %s" width style (uc/color->background color)))))
(def styles-data (def styles-data
{:layout {:props [:width :height :x :y :radius :rx] {:layout {:props [:width :height :x :y :radius :rx]
@ -43,9 +45,9 @@
:fill {:props [:fill-color :fill-color-gradient] :fill {:props [:fill-color :fill-color-gradient]
:to-prop {:fill-color "background" :fill-color-gradient "background"} :to-prop {:fill-color "background" :fill-color-gradient "background"}
:format {:fill-color format-fill-color :fill-color-gradient format-fill-color}} :format {:fill-color format-fill-color :fill-color-gradient format-fill-color}}
:stroke {:props [:stroke-color] :stroke {:props [:stroke-style]
:to-prop {:stroke-color "border"} :to-prop {:stroke-style "border"}
:format {:stroke-color format-stroke}} :format {:stroke-style format-stroke}}
:shadow {:props [:shadow] :shadow {:props [:shadow]
:to-prop {:shadow :box-shadow} :to-prop {:shadow :box-shadow}
:format {:shadow #(str/join ", " (map shadow->css %1))}} :format {:shadow #(str/join ", " (map shadow->css %1))}}
@ -95,15 +97,18 @@
default-format (fn [value] (str (mth/precision value 2) "px")) default-format (fn [value] (str (mth/precision value 2) "px"))
format-property (fn [prop] format-property (fn [prop]
(let [css-prop (or (prop to-prop) (name prop)) (let [css-prop (or (prop to-prop) (name prop))
format-fn (or (prop format) default-format)] format-fn (or (prop format) default-format)
(str css-val (format-fn (prop values) values)]
(str/repeat " " tab-size) (when css-val
(str/fmt "%s: %s;" css-prop (format-fn (prop values) values)))))] (str
(str/repeat " " tab-size)
(str/fmt "%s: %s;" css-prop css-val)))))]
(->> properties (->> properties
(remove #(let [value (get values %)] (remove #(let [value (get values %)]
(or (nil? value) (= value 0)))) (or (nil? value) (= value 0))))
(map format-property) (map format-property)
(filter (comp not nil?))
(str/join "\n"))))) (str/join "\n")))))
(defn shape->properties [shape] (defn shape->properties [shape]