mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -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 ----
|
;; ---- Components and instances creation ----
|
||||||
|
|
||||||
(defn generate-add-component
|
(defn generate-add-component
|
||||||
"If there is exactly one id, and it's a group, and not already a component, use
|
"If there is exactly one id, and it's a group or a frame, and not already a component,
|
||||||
it as root. Otherwise, create a group that contains all ids. Then, make a
|
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."
|
component with it, and link all shapes to their corresponding one in the component."
|
||||||
[it shapes objects page-id file-id components-v2]
|
[it shapes objects page-id file-id components-v2]
|
||||||
(let [[group changes]
|
(let [[group changes]
|
||||||
(if (and (= (count shapes) 1)
|
(if (and (= (count shapes) 1)
|
||||||
(= (:type (first shapes)) :group)
|
(or (= (:type (first shapes)) :group)
|
||||||
|
(= (:type (first shapes)) :frame))
|
||||||
(not (ctk/instance-root? (first shapes))))
|
(not (ctk/instance-root? (first shapes))))
|
||||||
[(first shapes) (-> (pcb/empty-changes it page-id)
|
[(first shapes) (-> (pcb/empty-changes it page-id)
|
||||||
(pcb/with-objects objects))]
|
(pcb/with-objects objects))]
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.ui.components.shape-icon
|
(ns app.main.ui.components.shape-icon
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
@ -13,33 +14,33 @@
|
||||||
|
|
||||||
(mf/defc element-icon
|
(mf/defc element-icon
|
||||||
[{:keys [shape main-instance?] :as props}]
|
[{:keys [shape main-instance?] :as props}]
|
||||||
(case (:type shape)
|
(if (ctk/instance-root? shape)
|
||||||
:frame (cond
|
(if main-instance?
|
||||||
(and (ctl/layout? shape) (ctl/col? shape))
|
i/component
|
||||||
i/layout-columns
|
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))
|
(and (ctl/layout? shape) (ctl/row? shape))
|
||||||
i/layout-rows
|
i/layout-rows
|
||||||
|
|
||||||
:else
|
:else
|
||||||
i/artboard)
|
i/artboard)
|
||||||
:image i/image
|
:image i/image
|
||||||
:line i/line
|
:line i/line
|
||||||
:circle i/circle
|
:circle i/circle
|
||||||
:path i/curve
|
:path i/curve
|
||||||
:rect i/box
|
:rect i/box
|
||||||
:text i/text
|
:text i/text
|
||||||
:group (if (some? (:component-id shape))
|
:group (if (:masked-group? shape)
|
||||||
(if main-instance?
|
|
||||||
i/component
|
|
||||||
i/component-copy)
|
|
||||||
(if (:masked-group? shape)
|
|
||||||
i/mask
|
i/mask
|
||||||
i/folder))
|
i/folder)
|
||||||
:bool (case (:bool-type shape)
|
:bool (case (:bool-type shape)
|
||||||
:difference i/bool-difference
|
:difference i/bool-difference
|
||||||
:exclude i/bool-exclude
|
:exclude i/bool-exclude
|
||||||
:intersection i/bool-intersection
|
:intersection i/bool-intersection
|
||||||
#_:default i/bool-union)
|
#_:default i/bool-union)
|
||||||
:svg-raw i/file-svg
|
:svg-raw i/file-svg
|
||||||
nil))
|
nil)))
|
||||||
|
|
Loading…
Reference in a new issue