diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 681ec9c34..5c803f564 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -60,13 +60,14 @@ ;; ---- Components and instances creation ---- (defn generate-add-component - "If there is exactly one id, and it's a group, and not already a component, use - it as root. Otherwise, create a group that contains all ids. Then, make a + "If there is exactly one id, and it's a group or a frame, and not already a component, + use it as root. Otherwise, create a group that contains all ids. Then, make a component with it, and link all shapes to their corresponding one in the component." [it shapes objects page-id file-id components-v2] (let [[group changes] (if (and (= (count shapes) 1) - (= (:type (first shapes)) :group) + (or (= (:type (first shapes)) :group) + (= (:type (first shapes)) :frame)) (not (ctk/instance-root? (first shapes)))) [(first shapes) (-> (pcb/empty-changes it page-id) (pcb/with-objects objects))] diff --git a/frontend/src/app/main/ui/components/shape_icon.cljs b/frontend/src/app/main/ui/components/shape_icon.cljs index ab42a2e4c..9eca7fa5b 100644 --- a/frontend/src/app/main/ui/components/shape_icon.cljs +++ b/frontend/src/app/main/ui/components/shape_icon.cljs @@ -6,6 +6,7 @@ (ns app.main.ui.components.shape-icon (:require + [app.common.types.component :as ctk] [app.common.types.shape.layout :as ctl] [app.main.ui.icons :as i] [rumext.v2 :as mf])) @@ -13,33 +14,33 @@ (mf/defc element-icon [{:keys [shape main-instance?] :as props}] - (case (:type shape) - :frame (cond - (and (ctl/layout? shape) (ctl/col? shape)) - i/layout-columns + (if (ctk/instance-root? shape) + (if main-instance? + i/component + i/component-copy) + (case (:type shape) + :frame (cond + (and (ctl/layout? shape) (ctl/col? shape)) + i/layout-columns - (and (ctl/layout? shape) (ctl/row? shape)) - i/layout-rows + (and (ctl/layout? shape) (ctl/row? shape)) + i/layout-rows - :else - i/artboard) - :image i/image - :line i/line - :circle i/circle - :path i/curve - :rect i/box - :text i/text - :group (if (some? (:component-id shape)) - (if main-instance? - i/component - i/component-copy) - (if (:masked-group? shape) + :else + i/artboard) + :image i/image + :line i/line + :circle i/circle + :path i/curve + :rect i/box + :text i/text + :group (if (:masked-group? shape) i/mask - i/folder)) - :bool (case (:bool-type shape) - :difference i/bool-difference - :exclude i/bool-exclude - :intersection i/bool-intersection - #_:default i/bool-union) - :svg-raw i/file-svg - nil)) + i/folder) + :bool (case (:bool-type shape) + :difference i/bool-difference + :exclude i/bool-exclude + :intersection i/bool-intersection + #_:default i/bool-union) + :svg-raw i/file-svg + nil)))