mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Merge pull request #2724 from penpot/hiru-fix-component-board
Avoid extra group when creating a component from a board
This commit is contained in:
commit
e8d561ac7f
2 changed files with 32 additions and 30 deletions
|
@ -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))]
|
||||
|
|
|
@ -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)))
|
||||
|
|
Loading…
Reference in a new issue