0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

Merge pull request #3963 from penpot/alotor-fix-empty-thumbnails

🐛 Fix problem with thumbnails for empty pages
This commit is contained in:
Alejandro 2024-01-04 09:55:03 +01:00 committed by GitHub
commit 7fc77f279b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,8 +67,15 @@
(defn- calculate-dimensions
[objects aspect-ratio]
(let [root-objects (ctst/get-root-objects objects)]
(if (empty? root-objects)
;; Empty page, we create an arbitrary rect for the thumbnail
(-> (grc/make-rect {:x 0 :y 0 :width 100 :height 100})
(grc/update-rect :position)
(grc/fix-aspect-ratio aspect-ratio))
(let [bounds
(->> (ctst/get-root-objects objects)
(->> root-objects
(map (partial gsb/get-object-bounds objects))
(grc/join-rects))]
(-> bounds
@ -77,7 +84,7 @@
(update :width mth/finite 100000)
(update :height mth/finite 100000)
(grc/update-rect :position)
(grc/fix-aspect-ratio aspect-ratio))))
(grc/fix-aspect-ratio aspect-ratio))))))
(declare shape-wrapper-factory)
@ -201,6 +208,7 @@
(let [objects (:objects data)
shapes (cfh/get-immediate-children objects)
dim (calculate-dimensions objects aspect-ratio)
_ (prn ">>DIM" dim)
vbox (format-viewbox dim)
bgcolor (dm/get-in data [:options :background] default-color)