Merge branch 'staging' into eva-bugfixing-5

This commit is contained in:
Aitor 2023-02-02 11:31:49 +01:00 committed by GitHub
commit f31bc7457f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 434 additions and 301 deletions

View file

@ -8,6 +8,7 @@
- Fix white space on small screens [Taiga #4774](https://tree.taiga.io/project/penpot/issue/4774) - Fix white space on small screens [Taiga #4774](https://tree.taiga.io/project/penpot/issue/4774)
- Fix button spacing on delete acount modal [Taiga #4762](https://tree.taiga.io/project/penpot/issue/4762) - Fix button spacing on delete acount modal [Taiga #4762](https://tree.taiga.io/project/penpot/issue/4762)
- Fix invitations input on team management and onboarding modal [Taiga #4760](https://tree.taiga.io/project/penpot/issue/4760) - Fix invitations input on team management and onboarding modal [Taiga #4760](https://tree.taiga.io/project/penpot/issue/4760)
- Fix weird numeration creating new elements in dashboard [Taiga #4755](https://tree.taiga.io/project/penpot/issue/4755)
## 1.17.0 ## 1.17.0

View file

@ -154,7 +154,7 @@
(t/is (th/success? out)) (t/is (th/success? out))
(let [[thread :as result] (:result out)] (let [[thread :as result] (:result out)]
(t/is (= 1 (count result))) (t/is (= 1 (count result)))
(t/is (= "Page-1" (:page-name thread))) (t/is (= "Page 1" (:page-name thread)))
(t/is (= "hello world" (:content thread))) (t/is (= "hello world" (:content thread)))
(t/is (= 2 (:count-comments thread))) (t/is (= 2 (:count-comments thread)))
(t/is (true? (:is-resolved thread)))))) (t/is (true? (:is-resolved thread))))))

View file

@ -200,7 +200,7 @@
(assert (nil? (:current-component-id file))) (assert (nil? (:current-component-id file)))
(let [page-id (or (:id data) (uuid/next)) (let [page-id (or (:id data) (uuid/next))
page (-> (ctp/make-empty-page page-id "Page-1") page (-> (ctp/make-empty-page page-id "Page 1")
(d/deep-merge data))] (d/deep-merge data))]
(-> file (-> file
(commit-change (commit-change

View file

@ -43,13 +43,13 @@
(defn bounding-box (defn bounding-box
"Returns a rect that wraps the shape after all transformations applied." "Returns a rect that wraps the shape after all transformations applied."
[shape] [shape]
; TODO: perhaps we need to store this calculation in a shape attribute ;; TODO: perhaps we need to store this calculation in a shape attribute
(gpr/points->rect (:points shape))) (gpr/points->rect (:points shape)))
(defn left-bound (defn left-bound
"Returns the lowest x coord of the shape BEFORE applying transformations." "Returns the lowest x coord of the shape BEFORE applying transformations."
; TODO: perhaps some day we want after transformations, but for the ;; TODO: perhaps some day we want after transformations, but for the
; moment it's enough as is now. ;; moment it's enough as is now.
[shape] [shape]
(or (:x shape) (:x (:selrect shape)))) ; Paths don't have :x attribute (or (:x shape) (:x (:selrect shape)))) ; Paths don't have :x attribute

View file

@ -210,7 +210,7 @@
;; after-vec will contain the side length of the grown side ;; after-vec will contain the side length of the grown side
;; we scale the shape by the diference and translate it by the start ;; we scale the shape by the diference and translate it by the start
;; displacement (so its left+top position is constant) ;; displacement (so its left+top position is constant)
scale (/ (gpt/length after-vec) (gpt/length before-vec)) scale (/ (gpt/length after-vec) (max 0.01 (gpt/length before-vec)))
resize-origin (gpo/origin child-points-after) resize-origin (gpo/origin child-points-after)
@ -268,11 +268,11 @@
scale-x (if (= :scale constraints-h) scale-x (if (= :scale constraints-h)
1 1
(/ (gpo/width-points child-bb-before) (gpo/width-points child-bb-after))) (/ (gpo/width-points child-bb-before) (max 0.01 (gpo/width-points child-bb-after))))
scale-y (if (= :scale constraints-v) scale-y (if (= :scale constraints-v)
1 1
(/ (gpo/height-points child-bb-before) (gpo/height-points child-bb-after))) (/ (gpo/height-points child-bb-before) (max 0.01 (gpo/height-points child-bb-after))))
resize-vector (gpt/point scale-x scale-y) resize-vector (gpt/point scale-x scale-y)
resize-origin (gpo/origin transformed-child-bounds) resize-origin (gpo/origin transformed-child-bounds)

View file

@ -238,6 +238,30 @@
(and col? (< total-min-width rest-layout-width total-max-width) (not (ctl/auto-width? parent))) (and col? (< total-min-width rest-layout-width total-max-width) (not (ctl/auto-width? parent)))
(distribute-space :line-width :line-min-width :line-max-width total-min-width rest-layout-width)) (distribute-space :line-width :line-min-width :line-max-width total-min-width rest-layout-width))
;; Add information to limit the growth of width: 100% shapes to the bounds of the layout
layout-lines
(cond
row?
(->> layout-lines
(reduce
(fn [[result rest-layout-height] {:keys [line-height] :as line}]
[(conj result (assoc line :to-bound-height rest-layout-height))
(- rest-layout-height line-height layout-gap-row)])
[[] layout-height])
(first))
col?
(->> layout-lines
(reduce
(fn [[result rest-layout-width] {:keys [line-width] :as line}]
[(conj result (assoc line :to-bound-width rest-layout-width))
(- rest-layout-width line-width layout-gap-col)])
[[] layout-width])
(first))
:else
layout-lines)
[total-width total-height] (->> layout-lines (reduce add-lines [0 0])) [total-width total-height] (->> layout-lines (reduce add-lines [0 0]))
base-p (flp/get-base-line parent layout-bounds total-width total-height num-lines)] base-p (flp/get-base-line parent layout-bounds total-width total-height num-lines)]

View file

@ -20,7 +20,7 @@
transform-inverse transform-inverse
child child
child-origin child-width child-origin child-width
{:keys [children-data line-width] :as layout-data}] {:keys [children-data line-width to-bound-width] :as layout-data}]
(cond (cond
(ctl/row? parent) (ctl/row? parent)
@ -30,8 +30,9 @@
:modifiers (ctm/resize-modifiers (gpt/point fill-scale 1) child-origin transform transform-inverse)}) :modifiers (ctm/resize-modifiers (gpt/point fill-scale 1) child-origin transform transform-inverse)})
(ctl/col? parent) (ctl/col? parent)
(let [target-width (max (- line-width (ctl/child-width-margin child)) 0.01) (let [line-width (min line-width (or to-bound-width line-width))
max-width (ctl/child-max-width child) target-width (max (- line-width (ctl/child-width-margin child)) 0.01)
max-width (max (ctl/child-max-width child) 0.01)
target-width (min max-width target-width) target-width (min max-width target-width)
fill-scale (/ target-width child-width)] fill-scale (/ target-width child-width)]
{:width target-width {:width target-width
@ -43,7 +44,7 @@
transform transform-inverse transform transform-inverse
child child
child-origin child-height child-origin child-height
{:keys [children-data line-height] :as layout-data}] {:keys [children-data line-height to-bound-height] :as layout-data}]
(cond (cond
(ctl/col? parent) (ctl/col? parent)
@ -53,8 +54,9 @@
:modifiers (ctm/resize-modifiers (gpt/point 1 fill-scale) child-origin transform transform-inverse)}) :modifiers (ctm/resize-modifiers (gpt/point 1 fill-scale) child-origin transform transform-inverse)})
(ctl/row? parent) (ctl/row? parent)
(let [target-height (max (- line-height (ctl/child-height-margin child)) 0.01) (let [line-height (min line-height (or to-bound-height line-height))
max-height (ctl/child-max-height child) target-height (max (- line-height (ctl/child-height-margin child)) 0.01)
max-height (max (ctl/child-max-height child) 0.01)
target-height (min max-height target-height) target-height (min max-height target-height)
fill-scale (/ target-height child-height)] fill-scale (/ target-height child-height)]
{:height target-height {:height target-height
@ -71,8 +73,13 @@
(when (or (ctl/fill-width? child) (ctl/fill-height? child)) (when (or (ctl/fill-width? child) (ctl/fill-height? child))
(gtr/calculate-geometry @parent-bounds)) (gtr/calculate-geometry @parent-bounds))
fill-width (when (ctl/fill-width? child) (calc-fill-width-data parent transform transform-inverse child child-origin child-width layout-line)) fill-width
fill-height (when (ctl/fill-height? child) (calc-fill-height-data parent transform transform-inverse child child-origin child-height layout-line)) (when (ctl/fill-width? child)
(calc-fill-width-data parent transform transform-inverse child child-origin child-width layout-line))
fill-height
(when (ctl/fill-height? child)
(calc-fill-height-data parent transform transform-inverse child child-origin child-height layout-line))
child-width (or (:width fill-width) child-width) child-width (or (:width fill-width) child-width)
child-height (or (:height fill-height) child-height) child-height (or (:height fill-height) child-height)

View file

@ -34,7 +34,7 @@
(defn abs (defn abs
[v] [v]
#?(:cljs (js/Math.abs v) #?(:cljs (js/Math.abs v)
:clj (Math/abs v))) :clj (Math/abs (double v))))
(defn sin (defn sin
"Returns the sine of a number" "Returns the sine of a number"

View file

@ -19,6 +19,8 @@
(dm/export common/file-version) (dm/export common/file-version)
(dm/export common/default-color) (dm/export common/default-color)
(dm/export common/component-sync-attrs) (dm/export common/component-sync-attrs)
(dm/export common/retrieve-used-names)
(dm/export common/generate-unique-name)
;; Focus ;; Focus
(dm/export focus/focus-objects) (dm/export focus/focus-objects)

View file

@ -7,7 +7,10 @@
(ns app.common.pages.common (ns app.common.pages.common
(:require (:require
[app.common.colors :as clr] [app.common.colors :as clr]
[app.common.uuid :as uuid])) [app.common.data :as d]
[app.common.spec :as us]
[app.common.uuid :as uuid]
[clojure.spec.alpha :as s]))
(def file-version 20) (def file-version 20)
(def default-color clr/gray-20) (def default-color clr/gray-20)
@ -580,3 +583,31 @@
:layout-item-min-w :layout-item-min-w
:layout-item-align-self}}) :layout-item-align-self}})
(defn retrieve-used-names
"Return a set with the all unique names used in the
elements (any entity thas has a :name)"
[elements]
(into #{} (comp (map :name) (remove nil?)) (vals elements)))
(defn- extract-numeric-suffix
[basename]
(if-let [[_ p1 p2] (re-find #"(.*) ([0-9]+)$" basename)]
[p1 (+ 1 (d/parse-integer p2))]
[basename 1]))
(s/def ::set-of-strings
(s/every ::us/string :kind set?))
(defn generate-unique-name
"A unique name generator"
[used basename]
(us/assert! ::set-of-strings used)
(us/assert! ::us/string basename)
(if-not (contains? used basename)
basename
(let [[prefix initial] (extract-numeric-suffix basename)]
(loop [counter initial]
(let [candidate (str prefix " " counter)]
(if (contains? used candidate)
(recur (inc counter))
candidate))))))

View file

@ -109,6 +109,20 @@
(recur (conj result parent-id) parent-id) (recur (conj result parent-id) parent-id)
result)))) result))))
(defn get-parent-ids-with-index
"Returns a tuple with the list of parents and a map with the position within each parent"
[objects shape-id]
(loop [parent-list []
parent-indices {}
current shape-id]
(let [parent-id (dm/get-in objects [current :parent-id])
parent (get objects parent-id)]
(if (and (some? parent) (not= parent-id current))
(let [parent-list (conj parent-list parent-id)
parent-indices (assoc parent-indices parent-id (d/index-of (:shapes parent) current))]
(recur parent-list parent-indices parent-id))
[parent-list parent-indices]))))
(defn get-siblings-ids (defn get-siblings-ids
[objects id] [objects id]
(let [parent (get-parent objects id)] (let [parent (get-parent objects id)]

View file

@ -9,6 +9,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.common :as common]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.shape-tree :as ctst] [app.common.types.shape-tree :as ctst]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
@ -130,7 +131,7 @@
delta (gpt/subtract position orig-pos) delta (gpt/subtract position orig-pos)
objects (:objects container) objects (:objects container)
unames (volatile! (ctst/retrieve-used-names objects)) unames (volatile! (common/retrieve-used-names objects))
frame-id (ctst/frame-id-by-position objects (gpt/add orig-pos delta)) frame-id (ctst/frame-id-by-position objects (gpt/add orig-pos delta))
frame-ids-map (volatile! {}) frame-ids-map (volatile! {})

View file

@ -73,7 +73,7 @@
([file-id page-id] ([file-id page-id]
(let [page (when (some? page-id) (let [page (when (some? page-id)
(ctp/make-empty-page page-id "Page-1"))] (ctp/make-empty-page page-id "Page 1"))]
(cond-> (-> empty-file-data (cond-> (-> empty-file-data
(assoc :id file-id)) (assoc :id file-id))

View file

@ -132,43 +132,34 @@
(defn get-base (defn get-base
[objects id-a id-b] [objects id-a id-b]
(let [parents-a (reverse (cons id-a (cph/get-parent-ids objects id-a))) (let [[parents-a parents-a-index] (cph/get-parent-ids-with-index objects id-a)
parents-b (reverse (cons id-b (cph/get-parent-ids objects id-b))) [parents-b parents-b-index] (cph/get-parent-ids-with-index objects id-b)
[base base-child-a base-child-b] parents-a (cons id-a parents-a)
(loop [parents-a (rest parents-a) parents-b (into #{id-b} parents-b)
parents-b (rest parents-b)
base uuid/zero]
(cond
(not= (first parents-a) (first parents-b))
[base (first parents-a) (first parents-b)]
(or (empty? parents-a) (empty? parents-b)) ;; Search for the common frame in order
[uuid/zero (first parents-a) (first parents-b)] base (or (d/seek parents-b parents-a) uuid/zero)
:else idx-a (get parents-a-index base)
(recur (rest parents-a) (rest parents-b) (first parents-a)))) idx-b (get parents-b-index base)]
index-base-a (when base-child-a (cph/get-position-on-parent objects base-child-a)) [base idx-a idx-b]))
index-base-b (when base-child-b (cph/get-position-on-parent objects base-child-b))]
[base index-base-a index-base-b]))
(defn is-shape-over-shape? (defn is-shape-over-shape?
[objects base-shape-id over-shape-id] [objects base-shape-id over-shape-id]
(let [[base index-a index-b] (get-base objects base-shape-id over-shape-id)] (let [[base index-a index-b] (get-base objects base-shape-id over-shape-id)]
(cond (cond
;; The base the base shape, so the other item is bellow
(= base base-shape-id) (= base base-shape-id)
(let [object (get objects base-shape-id)] false
(or (cph/frame-shape? object)
(cph/root-frame? object)))
;; The base is the testing over, so it's over
(= base over-shape-id) (= base over-shape-id)
(let [object (get objects over-shape-id)] true
(or (not (cph/frame-shape? object))
(not (cph/root-frame? object))))
;; Check which index is lower
:else :else
(< index-a index-b)))) (< index-a index-b))))
@ -284,35 +275,6 @@
[frame] [frame]
(not (mth/almost-zero? (:rotation frame 0)))) (not (mth/almost-zero? (:rotation frame 0))))
(defn retrieve-used-names
[objects]
(into #{} (comp (map :name) (remove nil?)) (vals objects)))
(defn- extract-numeric-suffix
[basename]
(if-let [[_ p1 p2] (re-find #"(.*)-([0-9]+)$" basename)]
[p1 (+ 1 (d/parse-integer p2))]
[basename 1]))
(s/def ::set-of-strings
(s/every ::us/string :kind set?))
(defn generate-unique-name
"A unique name generator"
[used basename]
(us/assert! ::set-of-strings used)
(us/assert! ::us/string basename)
;; We have add a condition because UX doesn't want numbers on
;; layer names.
(if-not (contains? used basename)
basename
(let [[prefix initial] (extract-numeric-suffix basename)]
(loop [counter initial]
(let [candidate (str prefix "-" counter)]
(if (contains? used candidate)
(recur (inc counter))
candidate))))))
(defn clone-object (defn clone-object
"Gets a copy of the object and all its children, with new ids "Gets a copy of the object and all its children, with new ids
and with the parent-children links correctly set. Admits functions and with the parent-children links correctly set. Admits functions

View file

@ -126,7 +126,7 @@
(fn [file-data] (fn [file-data]
(let [id (uuid/next) (let [id (uuid/next)
props (merge {:id id props (merge {:id id
:name "Color-1" :name "Color 1"
:color "#000000" :color "#000000"
:opacity 1} :opacity 1}
props)] props)]
@ -140,7 +140,7 @@
(fn [file-data] (fn [file-data]
(let [id (uuid/next) (let [id (uuid/next)
props (merge {:id id props (merge {:id id
:name "Typography-1" :name "Typography 1"
:font-id "sourcesanspro" :font-id "sourcesanspro"
:font-family "sourcesanspro" :font-family "sourcesanspro"
:font-size "14" :font-size "14"

View file

@ -101,7 +101,7 @@
;; false) ;; false)
(t/is (= (count pages) 2)) (t/is (= (count pages) 2))
(t/is (= (:name (first pages)) "Page-1")) (t/is (= (:name (first pages)) "Page 1"))
(t/is (= (:name (second pages)) "Library backup")) (t/is (= (:name (second pages)) "Library backup"))
(t/is (= (count components) 1)) (t/is (= (count components) 1))

View file

@ -7,6 +7,7 @@
(ns app.main.data.dashboard (ns app.main.data.dashboard
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.pages :as cp]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
@ -664,7 +665,9 @@
(ptk/reify ::create-project (ptk/reify ::create-project
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [name (name (gensym (str (tr "dashboard.new-project-prefix") " "))) (let [projects (get state :dashboard-projects)
unames (cp/retrieve-used-names projects)
name (cp/generate-unique-name unames (str (tr "dashboard.new-project-prefix") " 1"))
team-id (:current-team-id state) team-id (:current-team-id state)
params {:name name params {:name name
:team-id team-id} :team-id team-id}
@ -875,7 +878,9 @@
:or {on-success identity :or {on-success identity
on-error rx/throw}} (meta params) on-error rx/throw}} (meta params)
name (name (gensym (str (tr "dashboard.new-file-prefix") " "))) files (get state :dashboard-files)
unames (cp/retrieve-used-names files)
name (cp/generate-unique-name unames (str (tr "dashboard.new-file-prefix") " 1"))
features (cond-> #{} features (cond-> #{}
(features/active-feature? state :components-v2) (features/active-feature? state :components-v2)
(conj "components/v2")) (conj "components/v2"))
@ -1067,8 +1072,12 @@
pparams (:path-params route) pparams (:path-params route)
in-project? (contains? pparams :project-id) in-project? (contains? pparams :project-id)
name (if in-project? name (if in-project?
(name (gensym (str (tr "dashboard.new-file-prefix") " "))) (let [files (get state :dashboard-files)
(name (gensym (str (tr "dashboard.new-project-prefix") " ")))) unames (cp/retrieve-used-names files)]
(cp/generate-unique-name unames (str (tr "dashboard.new-file-prefix") " 1")))
(let [projects (get state :dashboard-projects)
unames (cp/retrieve-used-names projects)]
(cp/generate-unique-name unames (str (tr "dashboard.new-project-prefix") " 1"))))
params (if in-project? params (if in-project?
{:project-id (:project-id pparams) {:project-id (:project-id pparams)
:name name} :name name}

View file

@ -15,6 +15,7 @@
[app.common.geom.proportions :as gpp] [app.common.geom.proportions :as gpp]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.pages :as cp]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
@ -408,8 +409,8 @@
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(let [pages (get-in state [:workspace-data :pages-index]) (let [pages (get-in state [:workspace-data :pages-index])
unames (ctst/retrieve-used-names pages) unames (cp/retrieve-used-names pages)
name (ctst/generate-unique-name unames "Page-1") name (cp/generate-unique-name unames "Page 1")
changes (-> (pcb/empty-changes it) changes (-> (pcb/empty-changes it)
(pcb/add-empty-page id name))] (pcb/add-empty-page id name))]
@ -423,9 +424,9 @@
(watch [it state _] (watch [it state _]
(let [id (uuid/next) (let [id (uuid/next)
pages (get-in state [:workspace-data :pages-index]) pages (get-in state [:workspace-data :pages-index])
unames (ctst/retrieve-used-names pages) unames (cp/retrieve-used-names pages)
page (get-in state [:workspace-data :pages-index page-id]) page (get-in state [:workspace-data :pages-index page-id])
name (ctst/generate-unique-name unames (:name page)) name (cp/generate-unique-name unames (:name page))
no_thumbnails_objects (->> (:objects page) no_thumbnails_objects (->> (:objects page)
(d/mapm (fn [_ val] (dissoc val :use-for-thumbnail?)))) (d/mapm (fn [_ val] (dissoc val :use-for-thumbnail?))))

View file

@ -8,6 +8,7 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.pages :as cp]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
@ -33,7 +34,7 @@
flows (get-in page [:options :flows] []) flows (get-in page [:options :flows] [])
unames (into #{} (map :name flows)) unames (into #{} (map :name flows))
name (ctst/generate-unique-name unames "Flow-1") name (cp/generate-unique-name unames "Flow 1")
new-flow {:id (uuid/next) new-flow {:id (uuid/next)
:name name :name name

View file

@ -73,7 +73,7 @@
(pcb/with-objects objects))] (pcb/with-objects objects))]
(let [group-name (if (= 1 (count shapes)) (let [group-name (if (= 1 (count shapes))
(:name (first shapes)) (:name (first shapes))
"Component-1")] "Component 1")]
(dwg/prepare-create-group it (dwg/prepare-create-group it
objects objects
page-id page-id

View file

@ -15,7 +15,6 @@
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.types.page :as ctp] [app.common.types.page :as ctp]
[app.common.types.shape-tree :as ctt]
[app.common.types.shape.interactions :as ctsi] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.modal :as md] [app.main.data.modal :as md]
@ -290,7 +289,7 @@
move to the desired position, and recalculate parents and frames as needed." move to the desired position, and recalculate parents and frames as needed."
[all-objects page ids delta it] [all-objects page ids delta it]
(let [shapes (map (d/getf all-objects) ids) (let [shapes (map (d/getf all-objects) ids)
unames (volatile! (ctt/retrieve-used-names (:objects page))) unames (volatile! (cp/retrieve-used-names (:objects page)))
update-unames! (fn [new-name] (vswap! unames conj new-name)) update-unames! (fn [new-name] (vswap! unames conj new-name))
all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) (d/ordered-set) ids) all-ids (reduce #(into %1 (cons %2 (cph/get-children-ids all-objects %2))) (d/ordered-set) ids)
ids-map (into {} (map #(vector % (uuid/next))) all-ids) ids-map (into {} (map #(vector % (uuid/next))) all-ids)
@ -367,7 +366,7 @@
(let [update-flows (fn [flows] (let [update-flows (fn [flows]
(reduce (reduce
(fn [flows frame] (fn [flows frame]
(let [name (ctt/generate-unique-name @unames "Flow-1") (let [name (cp/generate-unique-name @unames "Flow 1")
_ (vswap! unames conj name) _ (vswap! unames conj name)
new-flow {:id (uuid/next) new-flow {:id (uuid/next)
:name name :name name

View file

@ -271,16 +271,89 @@
(ptk/data-event :layout/update ids) (ptk/data-event :layout/update ids)
(dwu/commit-undo-transaction undo-id)))))) (dwu/commit-undo-transaction undo-id))))))
(defn fix-child-sizing
[objects parent-changes shape]
(let [parent (-> (cph/get-parent objects (:id shape))
(d/deep-merge parent-changes))
auto-width? (ctl/auto-width? parent)
auto-height? (ctl/auto-height? parent)
col? (ctl/col? parent)
row? (ctl/row? parent)
all-children (->> parent :shapes (map (d/getf objects)))]
(cond-> shape
;; If the parent is hug width and the direction column
;; change to fixed when ALL children are fill
(and col? auto-width? (every? ctl/fill-width? all-children))
(assoc :layout-item-h-sizing :fix)
;; If the parent is hug height and the direction is column
;; change to fixed when ANY children is fill
(and col? auto-height? (ctl/fill-height? shape))
(assoc :layout-item-v-sizing :fix)
;; If the parent is hug width and the direction row
;; change to fixed when ANY children is fill
(and row? auto-width? (ctl/fill-width? shape))
(assoc :layout-item-h-sizing :fix)
;; If the parent is hug height and the direction row
;; change to fixed when ALL children are fill
(and row? auto-height? (every? ctl/fill-height? all-children))
(assoc :layout-item-v-sizing :fix))))
(defn fix-parent-sizing
[objects ids-set changes parent]
(let [auto-width? (ctl/auto-width? parent)
auto-height? (ctl/auto-height? parent)
col? (ctl/col? parent)
row? (ctl/row? parent)
all-children
(->> parent :shapes
(map (d/getf objects))
(map (fn [shape]
(if (contains? ids-set (:id shape))
(d/deep-merge shape changes)
shape))))]
(cond-> parent
;; Col layout and parent is hug-width if all children are fill-width
;; change parent to fixed
(and col? auto-width? (every? ctl/fill-width? all-children))
(assoc :layout-item-h-sizing :fix)
;; Col layout and parent is hug-height if any children is fill-height
;; change parent to fixed
(and col? auto-height? (some ctl/fill-height? all-children))
(assoc :layout-item-v-sizing :fix)
;; Row layout and parent is hug-width if any children is fill-width
;; change parent to fixed
(and row? auto-width? (some ctl/fill-width? all-children))
(assoc :layout-item-h-sizing :fix)
;; Row layout and parent is hug-height if all children are fill-height
;; change parent to fixed
(and row? auto-height? (every? ctl/fill-height? all-children))
(assoc :layout-item-v-sizing :fix))))
(defn update-layout-child (defn update-layout-child
[ids changes] [ids changes]
(ptk/reify ::update-layout-child (ptk/reify ::update-layout-child
ptk/WatchEvent ptk/WatchEvent
(watch [_ state _] (watch [_ state _]
(let [objects (wsh/lookup-page-objects state) (let [objects (wsh/lookup-page-objects state)
children-ids (->> ids (mapcat #(cph/get-children-ids objects %)))
parent-ids (->> ids (map #(cph/get-parent-id objects %))) parent-ids (->> ids (map #(cph/get-parent-id objects %)))
layout-ids (->> ids (filter (comp ctl/layout? (d/getf objects))))
undo-id (js/Symbol)] undo-id (js/Symbol)]
(rx/of (dwu/start-undo-transaction undo-id) (rx/of (dwu/start-undo-transaction undo-id)
(dwc/update-shapes ids #(d/deep-merge (or % {}) changes)) (dwc/update-shapes ids #(d/deep-merge (or % {}) changes))
(ptk/data-event :layout/update (d/concat-vec layout-ids parent-ids)) (dwc/update-shapes children-ids (partial fix-child-sizing objects changes))
(dwc/update-shapes parent-ids (partial fix-parent-sizing objects (set ids) changes))
(ptk/data-event :layout/update ids)
(dwu/commit-undo-transaction undo-id)))))) (dwu/commit-undo-transaction undo-id))))))

View file

@ -12,6 +12,7 @@
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.math :as mth] [app.common.math :as mth]
[app.common.pages :as cp]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us :refer [max-safe-int min-safe-int]] [app.common.spec :as us :refer [max-safe-int min-safe-int]]
@ -493,7 +494,7 @@
(- y vb-y (/ vb-height 2)) (- y vb-y (/ vb-height 2))
y)) y))
unames (ctst/retrieve-used-names objects) unames (cp/retrieve-used-names objects)
svg-name (str/replace (:name svg-data) ".svg" "") svg-name (str/replace (:name svg-data) ".svg" "")

View file

@ -77,6 +77,11 @@
;; Delete the thumbnail first so if we interrupt we can regenerate after ;; Delete the thumbnail first so if we interrupt we can regenerate after
(->> (rp/cmd! :upsert-file-object-thumbnail params) (->> (rp/cmd! :upsert-file-object-thumbnail params)
(rx/catch #(rx/empty))) (rx/catch #(rx/empty)))
;; Remove the thumbnail temporary. If the user changes pages the thumbnail is regenerated
(rx/of #(update % :workspace-thumbnails assoc object-id nil))
;; Send the update to the back-end
(->> blob-result (->> blob-result
(rx/merge-map (rx/merge-map
(fn [blob] (fn [blob]

View file

@ -27,8 +27,6 @@
(defn- draw-thumbnail-canvas! (defn- draw-thumbnail-canvas!
[canvas-node img-node] [canvas-node img-node]
(ts/raf
(fn []
(try (try
(when (and (some? canvas-node) (some? img-node)) (when (and (some? canvas-node) (some? img-node))
(let [canvas-context (.getContext canvas-node "2d") (let [canvas-context (.getContext canvas-node "2d")
@ -43,7 +41,7 @@
true)) true))
(catch :default err (catch :default err
(.error js/console err) (.error js/console err)
false))))) false)))
(defn- remove-image-loading (defn- remove-image-loading
"Remove the changes related to change a url for its embed value. This is necessary "Remove the changes related to change a url for its embed value. This is necessary
@ -78,8 +76,12 @@
(gsh/selection-rect (concat [shape] all-children)) (gsh/selection-rect (concat [shape] all-children))
(-> shape :points gsh/points->selrect)) (-> shape :points gsh/points->selrect))
fixed-width (mth/clamp width 250 2000) [fixed-width fixed-height]
fixed-height (/ (* height fixed-width) width) (if (> width height)
[(mth/clamp width 250 2000)
(/ (* height (mth/clamp width 250 2000)) width)]
[(/ (* width (mth/clamp height 250 2000)) height)
(mth/clamp height 250 2000)])
image-url (mf/use-state nil) image-url (mf/use-state nil)
observer-ref (mf/use-var nil) observer-ref (mf/use-var nil)
@ -289,6 +291,6 @@
:height height} :height height}
[:img {:ref frame-image-ref [:img {:ref frame-image-ref
:src @image-url :src @image-url
:width width :width fixed-width
:height height :height fixed-height
:on-load on-image-load}]])])])) :on-load on-image-load}]])])]))

View file

@ -166,12 +166,12 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1* #--> Component-1 ; Component 1* #--> Component 1
; #{:shapes-group} ; #{:shapes-group}
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 1 ; Rect 1
; Rect 2 ; Rect 2
; ;
@ -180,14 +180,14 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) #{:shapes-group})) (t/is (= (:touched group) #{:shapes-group}))
(t/is (not= (:shape-ref group) nil)) (t/is (not= (:shape-ref group) nil))
(t/is (= (:name shape2) "Rect 2")) (t/is (= (:name shape2) "Rect 2"))
(t/is (= (:touched shape2) nil)) (t/is (= (:touched shape2) nil))
(t/is (not= (:shape-ref shape2) nil)) (t/is (not= (:shape-ref shape2) nil))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape2) "Rect 1")) (t/is (= (:name c-shape2) "Rect 1"))
@ -227,14 +227,14 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1* #--> Component-1 ; Component 1* #--> Component 1
; #{:shapes-group} ; #{:shapes-group}
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; Rect 1 ---> Rect 1 ; Rect 1 ---> Rect 1
; Rect 3 ---> Rect 3 ; Rect 3 ---> Rect 3
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 1 ; Rect 1
; Rect 2 ; Rect 2
; Rect 3 ; Rect 3
@ -245,7 +245,7 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) #{:shapes-group})) (t/is (= (:touched group) #{:shapes-group}))
(t/is (= (:name shape1) "Rect 2")) (t/is (= (:name shape1) "Rect 2"))
(t/is (= (:touched shape1) nil)) (t/is (= (:touched shape1) nil))
@ -257,7 +257,7 @@
(t/is (= (:touched shape3) nil)) (t/is (= (:touched shape3) nil))
(t/is (not= (:shape-ref shape3) nil)) (t/is (not= (:shape-ref shape3) nil))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:name c-shape1) "Rect 1"))
@ -389,7 +389,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -478,7 +478,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -567,7 +567,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -737,12 +737,12 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1 #--> Component-1 ; Component 1 #--> Component 1
; Rect 1 ---> Rect 1 ; Rect 1 ---> Rect 1
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 1 ; Rect 1
; Rect 2 ; Rect 2
; ;
@ -752,7 +752,7 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) nil)) (t/is (= (:touched group) nil))
(t/is (not= (:shape-ref group) nil)) (t/is (not= (:shape-ref group) nil))
(t/is (= (:name shape1) "Rect 1")) (t/is (= (:name shape1) "Rect 1"))
@ -762,7 +762,7 @@
(t/is (= (:touched shape2) nil)) (t/is (= (:touched shape2) nil))
(t/is (not= (:shape-ref shape2) nil)) (t/is (not= (:shape-ref shape2) nil))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:name c-shape1) "Rect 1"))
@ -803,13 +803,13 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1 #--> Component-1 ; Component 1 #--> Component 1
; Rect 1 ---> Rect 1 ; Rect 1 ---> Rect 1
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; Rect 3 ---> Rect 3 ; Rect 3 ---> Rect 3
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 1 ; Rect 1
; Rect 2 ; Rect 2
; Rect 3 ; Rect 3
@ -819,7 +819,7 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) nil)) (t/is (= (:touched group) nil))
(t/is (not= (:shape-ref group) nil)) (t/is (not= (:shape-ref group) nil))
(t/is (= (:name shape1) "Rect 1")) (t/is (= (:name shape1) "Rect 1"))
@ -832,7 +832,7 @@
(t/is (= (:touched shape3) nil)) (t/is (= (:touched shape3) nil))
(t/is (not= (:shape-ref shape3) nil)) (t/is (not= (:shape-ref shape3) nil))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape1) "Rect 1")) (t/is (= (:name c-shape1) "Rect 1"))
@ -1144,7 +1144,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -1517,11 +1517,11 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1 #--> Component-1 ; Component 1 #--> Component 1
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 2 ; Rect 2
; ;
(let [[[group shape2] [c-group c-shape2] component] (let [[[group shape2] [c-group c-shape2] component]
@ -1529,14 +1529,14 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) nil)) (t/is (= (:touched group) nil))
(t/is (not= (:shape-ref group) nil)) (t/is (not= (:shape-ref group) nil))
(t/is (= (:name shape2) "Rect 2")) (t/is (= (:name shape2) "Rect 2"))
(t/is (= (:touched shape2) nil)) (t/is (= (:touched shape2) nil))
(t/is (not= (:shape-ref shape2) nil)) (t/is (not= (:shape-ref shape2) nil))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape2) "Rect 2")) (t/is (= (:name c-shape2) "Rect 2"))
@ -1576,13 +1576,13 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1 #--> Component-1 ; Component 1 #--> Component 1
; Rect 2 ---> Rect 2 ; Rect 2 ---> Rect 2
; Rect 1 ---> Rect 1 ; Rect 1 ---> Rect 1
; Rect 3 ---> Rect 3 ; Rect 3 ---> Rect 3
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect 2 ; Rect 2
; Rect 1 ; Rect 1
; Rect 3 ; Rect 3
@ -1592,7 +1592,7 @@
new-state new-state
(thp/id :instance1))] (thp/id :instance1))]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:touched group) nil)) (t/is (= (:touched group) nil))
(t/is (not= (:shape-ref group) nil)) (t/is (not= (:shape-ref group) nil))
(t/is (= (:touched shape1) nil)) (t/is (= (:touched shape1) nil))
@ -1605,7 +1605,7 @@
(t/is (not= (:shape-ref shape3) nil)) (t/is (not= (:shape-ref shape3) nil))
(t/is (= (:name shape3) "Rect 3")) (t/is (= (:name shape3) "Rect 3"))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:touched c-group) nil)) (t/is (= (:touched c-group) nil))
(t/is (= (:shape-ref c-group) nil)) (t/is (= (:shape-ref c-group) nil))
(t/is (= (:name c-shape1) "Rect 2")) (t/is (= (:name c-shape1) "Rect 2"))
@ -1737,7 +1737,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -1826,7 +1826,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))
@ -1916,7 +1916,7 @@
new-state new-state
(thp/id :instance2))] (thp/id :instance2))]
; TODO: get and check the instance inside component [Group-1] ; TODO: get and check the instance inside component [Group 1]
(t/is (= (:name instance2) "Group")) (t/is (= (:name instance2) "Group"))
(t/is (= (:touched instance2) nil)) (t/is (= (:touched instance2) nil))

View file

@ -30,7 +30,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"})) {:name "Rect 1"}))
store (the/prepare-store state done store (the/prepare-store state done
(fn [new-state] (fn [new-state]
@ -43,12 +43,12 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
(let [shape1 (thp/get-shape new-state :shape1) (let [shape1 (thp/get-shape new-state :shape1)
@ -59,11 +59,11 @@
file (wsh/get-local-file new-state)] file (wsh/get-local-file new-state)]
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name group) "Rect-1")) (t/is (= (:name group) "Rect 1"))
(t/is (= (:name component) "Rect-1")) (t/is (= (:name component) "Rect 1"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-group) "Rect-1")) (t/is (= (:name c-group) "Rect 1"))
(thl/is-from-file group file))))] (thl/is-from-file group file))))]
@ -81,7 +81,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}))] {:name "Rect 1"}))]
(->> state (->> state
(the/do-update (dw/select-shape (thp/id :shape1))) (the/do-update (dw/select-shape (thp/id :shape1)))
@ -97,11 +97,11 @@
file (wsh/get-local-file new-state)] file (wsh/get-local-file new-state)]
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:name component) "Component-1")) (t/is (= (:name component) "Component 1"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(thl/is-from-file group file)))) (thl/is-from-file group file))))
@ -113,7 +113,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/sample-shape :shape2 :rect (thp/sample-shape :shape2 :rect
{:name "Rect-2"})) {:name "Rect-2"}))
@ -123,13 +123,13 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Component-1 #--> Component-1 ; Component 1 #--> Component 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; Rect-2 ---> Rect-2 ; Rect-2 ---> Rect-2
; ;
; [Component-1] ; [Component 1]
; Component-1 ; Component 1
; Rect-1 ; Rect 1
; Rect-2 ; Rect-2
; ;
(let [shape1 (thp/get-shape new-state :shape1) (let [shape1 (thp/get-shape new-state :shape1)
@ -143,12 +143,12 @@
file (wsh/get-local-file new-state)] file (wsh/get-local-file new-state)]
(t/is (= (:name group) "Component-1")) (t/is (= (:name group) "Component 1"))
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name shape2) "Rect-2")) (t/is (= (:name shape2) "Rect-2"))
(t/is (= (:name component) "Component-1")) (t/is (= (:name component) "Component 1"))
(t/is (= (:name c-group) "Component-1")) (t/is (= (:name c-group) "Component 1"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-2")) (t/is (= (:name c-shape2) "Rect-2"))
(thl/is-from-file group file))))] (thl/is-from-file group file))))]
@ -166,7 +166,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/sample-shape :shape2 :rect (thp/sample-shape :shape2 :rect
{:name "Rect-2"}) {:name "Rect-2"})
(thp/group-shapes :group1 (thp/group-shapes :group1
@ -180,12 +180,12 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Group #--> Group ; Group #--> Group
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; Rect-2 ---> Rect-2 ; Rect-2 ---> Rect-2
; ;
; [Group] ; [Group]
; Group ; Group
; Rect-1 ; Rect 1
; Rect-2 ; Rect-2
; ;
(let [[[group shape1 shape2] (let [[[group shape1 shape2]
@ -197,11 +197,11 @@
file (wsh/get-local-file new-state)] file (wsh/get-local-file new-state)]
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name shape2) "Rect-2")) (t/is (= (:name shape2) "Rect-2"))
(t/is (= (:name group) "Group")) (t/is (= (:name group) "Group"))
(t/is (= (:name component) "Group")) (t/is (= (:name component) "Group"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-2")) (t/is (= (:name c-shape2) "Rect-2"))
(t/is (= (:name c-group) "Group")) (t/is (= (:name c-group) "Group"))
@ -219,7 +219,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component1 (thp/make-component :instance1 :component1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -229,18 +229,18 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
(let [[[instance1 shape1] (let [[[instance1 shape1]
[c-instance1 c-shape1] [c-instance1 c-shape1]
@ -257,19 +257,19 @@
new-state new-state
(:parent-id instance1))] (:parent-id instance1))]
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name instance1) "Rect-1")) (t/is (= (:name instance1) "Rect 1"))
(t/is (= (:name component1) "Rect-1")) (t/is (= (:name component1) "Rect 1"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-instance1) "Rect-1")) (t/is (= (:name c-instance1) "Rect 1"))
(t/is (= (:name shape1') "Rect-1")) (t/is (= (:name shape1') "Rect 1"))
(t/is (= (:name instance1') "Rect-1")) (t/is (= (:name instance1') "Rect 1"))
(t/is (= (:name instance2) "Rect-1")) (t/is (= (:name instance2) "Rect 1"))
(t/is (= (:name component2) "Rect-1")) (t/is (= (:name component2) "Rect 1"))
(t/is (= (:name c-shape1') "Rect-1")) (t/is (= (:name c-shape1') "Rect 1"))
(t/is (= (:name c-instance1') "Rect-1")) (t/is (= (:name c-instance1') "Rect 1"))
(t/is (= (:name c-instance2) "Rect-1")))))] (t/is (= (:name c-instance2) "Rect 1")))))]
(ptk/emit! (ptk/emit!
store store
@ -283,7 +283,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -296,11 +296,11 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-2 #--> Renamed component ; Rect-2 #--> Renamed component
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Renamed] ; [Renamed]
; Renamed component ; Renamed component
; Rect-1 ; Rect 1
(let [libs (wsh/get-libraries new-state) (let [libs (wsh/get-libraries new-state)
component (cph/get-component libs component (cph/get-component libs
(:component-file instance1) (:component-file instance1)
@ -319,7 +319,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -332,16 +332,16 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
(let [new-component-id (->> (get-in new-state (let [new-component-id (->> (get-in new-state
[:workspace-data [:workspace-data
@ -363,7 +363,7 @@
new-state new-state
new-component-id)] new-component-id)]
(t/is (= (:name component2) "Rect-1")))))] (t/is (= (:name component2) "Rect 1")))))]
(ptk/emit! (ptk/emit!
store store
@ -376,7 +376,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -392,7 +392,7 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-2 ; Rect-2
; Rect-1 ; Rect 1
; ;
(let [[instance1 shape1] (let [[instance1 shape1]
(thl/resolve-noninstance (thl/resolve-noninstance
@ -420,7 +420,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -434,14 +434,14 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
(let [new-instance-id (-> new-state (let [new-instance-id (-> new-state
wsh/lookup-selected wsh/lookup-selected
@ -456,10 +456,10 @@
(t/is (not= (:id instance1) (:id instance2))) (t/is (not= (:id instance1) (:id instance2)))
(t/is (= (:id component) component-id)) (t/is (= (:id component) component-id))
(t/is (= (:name instance2) "Rect-1")) (t/is (= (:name instance2) "Rect 1"))
(t/is (= (:name shape2) "Rect-1")) (t/is (= (:name shape2) "Rect 1"))
(t/is (= (:name c-instance2) "Rect-1")) (t/is (= (:name c-instance2) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-1")) (t/is (= (:name c-shape2) "Rect 1"))
(t/is (= (:component-file instance2) (t/is (= (:component-file instance2)
thp/current-file-id)))))] thp/current-file-id)))))]
@ -476,7 +476,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)]) [(thp/id :shape1)])
(thp/move-to-library :lib1 "Library 1") (thp/move-to-library :lib1 "Library 1")
@ -491,8 +491,8 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> <Library 1> Rect-1 ; Rect 1 #--> <Library 1> Rect 1
; Rect-1 ---> <Library 1> Rect-1 ; Rect 1 ---> <Library 1> Rect 1
; ;
(let [new-instance-id (-> new-state (let [new-instance-id (-> new-state
wsh/lookup-selected wsh/lookup-selected
@ -506,10 +506,10 @@
new-instance-id)] new-instance-id)]
(t/is (= (:id component) component-id)) (t/is (= (:id component) component-id))
(t/is (= (:name instance2) "Rect-1")) (t/is (= (:name instance2) "Rect 1"))
(t/is (= (:name shape2) "Rect-1")) (t/is (= (:name shape2) "Rect 1"))
(t/is (= (:name c-instance2) "Rect-1")) (t/is (= (:name c-instance2) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-1")) (t/is (= (:name c-shape2) "Rect 1"))
(t/is (= (:component-file instance2) library-id)))))] (t/is (= (:component-file instance2) library-id)))))]
(ptk/emit! (ptk/emit!
@ -525,7 +525,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)])) [(thp/id :shape1)]))
@ -539,11 +539,11 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-2 ; Rect-2
; Rect-1 ; Rect 1
; ;
; [Rect-2] ; [Rect-2]
; Rect-2 ; Rect-2
; Rect-1 ; Rect 1
; ;
(let [[instance1 shape1] (let [[instance1 shape1]
(thl/resolve-noninstance (thl/resolve-noninstance
@ -564,7 +564,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"})) {:name "Rect 1"}))
file (wsh/get-local-file state) file (wsh/get-local-file state)
instance1 (thp/get-shape state :instance1) instance1 (thp/get-shape state :instance1)
@ -577,17 +577,17 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Group #--> Group ; Group #--> Group
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
; [Group] ; [Group]
; Group ; Group
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
(let [page (thp/current-page new-state) (let [page (thp/current-page new-state)
shape1 (thp/get-shape new-state :shape1) shape1 (thp/get-shape new-state :shape1)
@ -601,12 +601,12 @@
(:parent-id parent1))] (:parent-id parent1))]
(t/is (= (:name group) "Group")) (t/is (= (:name group) "Group"))
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name shape2) "Rect-1")) (t/is (= (:name shape2) "Rect 1"))
(t/is (= (:name component) "Group")) (t/is (= (:name component) "Group"))
(t/is (= (:name c-group) "Group")) (t/is (= (:name c-group) "Group"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-1")))))] (t/is (= (:name c-shape2) "Rect 1")))))]
(ptk/emit! (ptk/emit!
store store
@ -622,7 +622,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)]) [(thp/id :shape1)])
(thp/group-shapes :group1 (thp/group-shapes :group1
@ -641,21 +641,21 @@
; ;
; [Page] ; [Page]
; Root Frame ; Root Frame
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; Rect-1 #--> Rect-1 ; Rect 1 #--> Rect 1
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 ; Rect 1
; ;
; [Rect-1] ; [Rect 1]
; Rect-1 ; Rect 1
; Rect-1 @--> Rect-1 ; Rect 1 @--> Rect 1
; Rect-1 ---> Rect-1 ; Rect 1 ---> Rect 1
; ;
(let [new-instance-id (-> new-state (let [new-instance-id (-> new-state
wsh/lookup-selected wsh/lookup-selected
@ -672,12 +672,12 @@
(t/is (not= (:id instance1) (:id instance3))) (t/is (not= (:id instance1) (:id instance3)))
(t/is (= (:id component) component-id)) (t/is (= (:id component) component-id))
(t/is (= (:name instance3) "Rect-1")) (t/is (= (:name instance3) "Rect 1"))
(t/is (= (:name shape3) "Rect-1")) (t/is (= (:name shape3) "Rect 1"))
(t/is (= (:name shape4) "Rect-1")) (t/is (= (:name shape4) "Rect 1"))
(t/is (= (:name c-instance3) "Rect-1")) (t/is (= (:name c-instance3) "Rect 1"))
(t/is (= (:name c-shape3) "Rect-1")) (t/is (= (:name c-shape3) "Rect 1"))
(t/is (= (:name c-shape4) "Rect-1")))))] (t/is (= (:name c-shape4) "Rect 1")))))]
(ptk/emit! (ptk/emit!
store store
@ -692,7 +692,7 @@
(let [state (-> thp/initial-state (let [state (-> thp/initial-state
(thp/sample-page) (thp/sample-page)
(thp/sample-shape :shape1 :rect (thp/sample-shape :shape1 :rect
{:name "Rect-1"}) {:name "Rect 1"})
(thp/make-component :instance1 :component-1 (thp/make-component :instance1 :component-1
[(thp/id :shape1)]) [(thp/id :shape1)])
(thp/move-to-library :lib1 "Library 1") (thp/move-to-library :lib1 "Library 1")
@ -711,13 +711,13 @@
; [Page] ; [Page]
; Root Frame ; Root Frame
; Group #--> Group ; Group #--> Group
; Rect-1 @--> <Library 1> Rect-1 ; Rect 1 @--> <Library 1> Rect 1
; Rect-1 ---> <Library 1> Rect-1 ; Rect 1 ---> <Library 1> Rect 1
; ;
; [Group] ; [Group]
; Group ; Group
; Rect-1 @--> <Library 1> Rect-1 ; Rect 1 @--> <Library 1> Rect 1
; Rect-1 ---> <Library 1> Rect-1 ; Rect 1 ---> <Library 1> Rect 1
; ;
(let [instance2 (thp/get-shape new-state :instance2) (let [instance2 (thp/get-shape new-state :instance2)
@ -727,11 +727,11 @@
(:parent-id instance2))] (:parent-id instance2))]
(t/is (= (:name group1) "Group")) (t/is (= (:name group1) "Group"))
(t/is (= (:name shape1) "Rect-1")) (t/is (= (:name shape1) "Rect 1"))
(t/is (= (:name shape2) "Rect-1")) (t/is (= (:name shape2) "Rect 1"))
(t/is (= (:name c-group1) "Group")) (t/is (= (:name c-group1) "Group"))
(t/is (= (:name c-shape1) "Rect-1")) (t/is (= (:name c-shape1) "Rect 1"))
(t/is (= (:name c-shape2) "Rect-1")) (t/is (= (:name c-shape2) "Rect 1"))
(t/is (= (:component-file group1) thp/current-file-id)) (t/is (= (:component-file group1) thp/current-file-id))
(t/is (= (:component-file shape1) library-id)) (t/is (= (:component-file shape1) library-id))
(t/is (= (:component-file shape2) nil)) (t/is (= (:component-file shape2) nil))

View file

@ -19,7 +19,7 @@
(t/testing "Add empty page (only root-frame)" (t/testing "Add empty page (only root-frame)"
(let [page (-> (fb/create-file "Test") (let [page (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/get-current-page)) (fb/get-current-page))
data (-> (sd/make-snap-data) data (-> (sd/make-snap-data)
@ -28,7 +28,7 @@
(t/testing "Create simple shape on root" (t/testing "Create simple shape on root"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/create-rect (fb/create-rect
{:x 0 {:x 0
:y 0 :y 0
@ -57,7 +57,7 @@
(t/testing "Add page with single empty frame" (t/testing "Add page with single empty frame"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard (fb/add-artboard
{:x 0 {:x 0
:y 0 :y 0
@ -81,7 +81,7 @@
(t/testing "Add page with some shapes inside frames" (t/testing "Add page with some shapes inside frames"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard (fb/add-artboard
{:x 0 {:x 0
:y 0 :y 0
@ -112,7 +112,7 @@
(t/testing "Add a global guide" (t/testing "Add a global guide"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-guide {:position 50 :axis :x}) (fb/add-guide {:position 50 :axis :x})
(fb/add-artboard {:x 200 :y 200 :width 100 :height 100}) (fb/add-artboard {:x 200 :y 200 :width 100 :height 100})
(fb/close-artboard)) (fb/close-artboard))
@ -140,7 +140,7 @@
(t/testing "Add a frame guide" (t/testing "Add a frame guide"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard {:x 200 :y 200 :width 100 :height 100}) (fb/add-artboard {:x 200 :y 200 :width 100 :height 100})
(fb/close-artboard)) (fb/close-artboard))
@ -171,7 +171,7 @@
(t/deftest test-update-index (t/deftest test-update-index
(t/testing "Create frame on root and then remove it." (t/testing "Create frame on root and then remove it."
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard (fb/add-artboard
{:x 0 {:x 0
:y 0 :y 0
@ -201,7 +201,7 @@
(t/testing "Create simple shape on root. Then remove it" (t/testing "Create simple shape on root. Then remove it"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/create-rect (fb/create-rect
{:x 0 {:x 0
:y 0 :y 0
@ -229,7 +229,7 @@
(t/testing "Create shape inside frame, then remove it" (t/testing "Create shape inside frame, then remove it"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard (fb/add-artboard
{:x 0 {:x 0
:y 0 :y 0
@ -260,7 +260,7 @@
(t/testing "Create global guide then remove it" (t/testing "Create global guide then remove it"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-guide {:position 50 :axis :x})) (fb/add-guide {:position 50 :axis :x}))
guide-id (:last-id file) guide-id (:last-id file)
@ -293,7 +293,7 @@
(t/testing "Create frame guide then remove it" (t/testing "Create frame guide then remove it"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard {:x 200 :y 200 :width 100 :height 100}) (fb/add-artboard {:x 200 :y 200 :width 100 :height 100})
(fb/close-artboard)) (fb/close-artboard))
@ -324,7 +324,7 @@
(t/testing "Update frame coordinates" (t/testing "Update frame coordinates"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-artboard (fb/add-artboard
{:x 0 {:x 0
:y 0 :y 0
@ -358,7 +358,7 @@
(t/testing "Update shape coordinates" (t/testing "Update shape coordinates"
(let [file (-> (fb/create-file "Test") (let [file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/create-rect (fb/create-rect
{:x 0 {:x 0
:y 0 :y 0
@ -388,7 +388,7 @@
(t/testing "Update global guide" (t/testing "Update global guide"
(let [guide {:position 50 :axis :x} (let [guide {:position 50 :axis :x}
file (-> (fb/create-file "Test") file (-> (fb/create-file "Test")
(fb/add-page {:name "Page-1"}) (fb/add-page {:name "Page 1"})
(fb/add-guide guide)) (fb/add-guide guide))
guide-id (:last-id file) guide-id (:last-id file)