From 52545692dfe76d17723fc6396b445b33d910a9d9 Mon Sep 17 00:00:00 2001 From: Eva Date: Tue, 11 Jul 2023 11:26:31 +0200 Subject: [PATCH] :bug: Fix border radius values with decimals --- CHANGES.md | 3 ++- frontend/src/app/util/code_gen.cljs | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index df879824b..4ebb767d4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -61,7 +61,8 @@ - Fix text decoration on button [Taiga #5301](https://tree.taiga.io/project/penpot/issue/5301) - Fix menu order on design tab [Taiga #5195](https://tree.taiga.io/project/penpot/issue/5195) - Fix search bar width on layer tab [Taiga #5445](https://tree.taiga.io/project/penpot/issue/5445) - +- Fix border radius values with decimals [Taiga #5283](https://tree.taiga.io/project/penpot/issue/5283) + ### :arrow_up: Deps updates - Update google fonts catalog (at 2023/07/06) [Taiga #5592](https://tree.taiga.io/project/penpot/issue/5592) diff --git a/frontend/src/app/util/code_gen.cljs b/frontend/src/app/util/code_gen.cljs index f3cf5eea4..f50247b56 100644 --- a/frontend/src/app/util/code_gen.cljs +++ b/frontend/src/app/util/code_gen.cljs @@ -75,6 +75,14 @@ (fmt/format-size :width value values) (fmt/format-size :heigth value values)))) +(defn format-border-radius + [values] + + (and (coll? values) (d/not-empty? values)) + (->> values + (map fmt/format-pixels) + (str/join " "))) + (defn styles-data [shape] {:position {:props [:type] @@ -90,7 +98,7 @@ :rx "border-radius" :r1 "border-radius"} :format {:rotation #(str/fmt "rotate(%sdeg)" %) - :r1 #(apply str/fmt "%spx %spx %spx %spx" %) + :r1 format-border-radius :width #(get-size :width %) :height #(get-size :height %)} :multi {:r1 [:r1 :r2 :r3 :r4]}} @@ -236,9 +244,9 @@ (str/join "\n"))))) (defn shape->properties [shape] - (let [;; This property is added in an earlier step (code.cljs), + (let [;; This property is added in an earlier step (code.cljs), ;; it will come with a vector of flex-items if any. - ;; If there are none it will continue as usual. + ;; If there are none it will continue as usual. flex-items (:flex-items shape) props (->> (styles-data shape) vals (mapcat :props)) to-prop (->> (styles-data shape) vals (map :to-prop) (reduce merge))