mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🎉 Create multiple componentes
This commit is contained in:
parent
c5f37fadba
commit
e96bedc1c8
4 changed files with 34 additions and 3 deletions
|
@ -317,6 +317,26 @@
|
|||
components-v2 (features/active-feature? state :components-v2)]
|
||||
(rx/of (add-component2 selected components-v2))))))
|
||||
|
||||
|
||||
(defn add-multiple-components
|
||||
"Add several new components to current file library, from the currently selected shapes."
|
||||
[]
|
||||
(ptk/reify ::add-multiple-components
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [components-v2 (features/active-feature? state :components-v2)
|
||||
objects (wsh/lookup-page-objects state)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cph/clean-loops objects))
|
||||
added-components (map
|
||||
#(add-component2 [%] components-v2)
|
||||
selected)
|
||||
undo-id (js/Symbol)]
|
||||
(rx/concat
|
||||
(rx/of (dwu/start-undo-transaction undo-id))
|
||||
(rx/from added-components)
|
||||
(rx/of (dwu/commit-undo-transaction undo-id)))))))
|
||||
|
||||
(defn rename-component
|
||||
"Rename the component with the given id, in the current file library."
|
||||
[id new-name]
|
||||
|
|
|
@ -439,7 +439,8 @@
|
|||
|
||||
has-component? (some true? (map #(contains? % :component-id) shapes))
|
||||
is-component? (and single? (-> shapes first :component-id some?))
|
||||
is-non-root? (and single? (ctk/in-component-copy-not-root? (first shapes)))
|
||||
in-copy-not-root? (some true? (map #(ctk/in-component-copy-not-root? %) shapes))
|
||||
|
||||
objects (deref refs/workspace-page-objects)
|
||||
touched? (and single? (cph/component-touched? objects (:id (first shapes))))
|
||||
can-update-main? (or (not components-v2) touched?)
|
||||
|
@ -462,6 +463,7 @@
|
|||
(ctf/get-component workspace-libraries component-file component-id)))
|
||||
|
||||
do-add-component #(st/emit! (dwl/add-component))
|
||||
do-add-multiple-components #(st/emit! (dwl/add-multiple-components))
|
||||
do-detach-component #(st/emit! (dwl/detach-component id))
|
||||
do-detach-component-in-bulk #(st/emit! dwl/detach-selected-components)
|
||||
do-reset-component #(st/emit! (dwl/reset-component id))
|
||||
|
@ -504,12 +506,15 @@
|
|||
:on-accept do-update-component-in-bulk}))))]
|
||||
[:*
|
||||
[:*
|
||||
(when (or (not is-non-root?) (and has-component? (not single?)))
|
||||
(when (or (not in-copy-not-root?) (and has-component? (not single?)))
|
||||
[:& menu-separator])
|
||||
(when-not is-non-root?
|
||||
(when-not in-copy-not-root?
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-component")
|
||||
:shortcut (sc/get-tooltip :create-component)
|
||||
:on-click do-add-component}])
|
||||
(when-not (or single? in-copy-not-root?)
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.create-multiple-components")
|
||||
:on-click do-add-multiple-components}])
|
||||
(when (and has-component? (not single?))
|
||||
[:*
|
||||
[:& menu-entry {:title (tr "workspace.shape.menu.detach-instances-in-bulk")
|
||||
|
|
|
@ -4367,6 +4367,9 @@ msgstr "Selection to board"
|
|||
msgid "workspace.shape.menu.create-component"
|
||||
msgstr "Create component"
|
||||
|
||||
msgid "workspace.shape.menu.create-multiple-components"
|
||||
msgstr "Create multiple components"
|
||||
|
||||
#: src/app/main/ui/workspace/context_menu.cljs
|
||||
msgid "workspace.shape.menu.cut"
|
||||
msgstr "Cut"
|
||||
|
|
|
@ -4469,6 +4469,9 @@ msgstr "Tablero de selección"
|
|||
msgid "workspace.shape.menu.create-component"
|
||||
msgstr "Crear componente"
|
||||
|
||||
msgid "workspace.shape.menu.create-multiple-components"
|
||||
msgstr "Crear múltiples componentes"
|
||||
|
||||
#: src/app/main/ui/workspace/context_menu.cljs
|
||||
msgid "workspace.shape.menu.cut"
|
||||
msgstr "Cortar"
|
||||
|
|
Loading…
Add table
Reference in a new issue