mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 23:06:10 +02:00
✨ Filter variants on asset panel
This commit is contained in:
parent
e729e85c42
commit
a99198de48
3 changed files with 25 additions and 4 deletions
|
@ -30,6 +30,16 @@
|
|||
|
||||
(dm/export clv/find-related-components)
|
||||
|
||||
(defn is-secondary-variant?
|
||||
[component data]
|
||||
(if-let [variant-id (:variant-id component)]
|
||||
(let [page-id (:main-instance-page component)
|
||||
objects (-> (dsh/get-page data page-id)
|
||||
(get :objects))
|
||||
shapes (dm/get-in objects [variant-id :shapes])]
|
||||
(not= (:main-instance-id component) (last shapes)))
|
||||
false))
|
||||
|
||||
(defn update-property-name
|
||||
"Update the variant property name on the position pos
|
||||
in all the components with this variant-id"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.media :as cm]
|
||||
[app.common.types.component :as ctc]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.main.data.event :as ev]
|
||||
[app.main.data.modal :as modal]
|
||||
|
@ -312,6 +313,14 @@
|
|||
(seq (:colors selected))
|
||||
(seq (:typographies selected)))
|
||||
|
||||
any-variant? (mf/with-memo [selected components current-component-id]
|
||||
(let [selected-and-current (-> (d/nilv selected [])
|
||||
(conj current-component-id)
|
||||
set)]
|
||||
(->> components
|
||||
(filter #(contains? selected-and-current (:id %)))
|
||||
(some ctc/is-variant?))))
|
||||
|
||||
groups (mf/with-memo [components reverse-sort?]
|
||||
(grp/group-assets components reverse-sort?))
|
||||
|
||||
|
@ -544,7 +553,7 @@
|
|||
{:name (tr "workspace.assets.rename")
|
||||
:id "assets-rename-component"
|
||||
:handler on-rename})
|
||||
(when (and is-local (not (or multi-assets? read-only?)))
|
||||
(when (and is-local (not (or multi-assets? read-only? any-variant?)))
|
||||
{:name (if components-v2
|
||||
(tr "workspace.assets.duplicate-main")
|
||||
(tr "workspace.assets.duplicate"))
|
||||
|
@ -555,7 +564,7 @@
|
|||
{:name (tr "workspace.assets.delete")
|
||||
:id "assets-delete-component"
|
||||
:handler on-delete})
|
||||
(when (and is-local (not (or multi-assets? read-only?)))
|
||||
(when (and is-local (not (or multi-assets? read-only? any-variant?)))
|
||||
{:name (tr "workspace.assets.group")
|
||||
:id "assets-group-component"
|
||||
:handler on-group})
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
[app.main.data.workspace.variants :as dwv]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.router :as rt]
|
||||
[app.main.store :as st]
|
||||
|
@ -343,8 +344,9 @@
|
|||
|
||||
filtered-components
|
||||
(mf/with-memo [filters library]
|
||||
(-> (into [] (ctkl/components-seq library))
|
||||
(cmm/apply-filters filters)))
|
||||
(as-> (into [] (ctkl/components-seq library)) $
|
||||
(cmm/apply-filters $ filters)
|
||||
(remove #(dwv/is-secondary-variant? % library) $)))
|
||||
|
||||
filtered-media
|
||||
(mf/with-memo [filters media]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue