mirror of
https://github.com/penpot/penpot.git
synced 2025-07-17 03:35:17 +02:00
🐛 Fix variant from a shared lib doesnt't show props
This commit is contained in:
parent
18dea6c3a3
commit
db9e397531
2 changed files with 10 additions and 10 deletions
|
@ -15,6 +15,7 @@
|
||||||
(defn find-variant-components
|
(defn find-variant-components
|
||||||
"Find a list of the components thet belongs to this variant-id"
|
"Find a list of the components thet belongs to this variant-id"
|
||||||
[data objects variant-id]
|
[data objects variant-id]
|
||||||
|
;; We can't simply filter components, because we need to maintain the order
|
||||||
(->> (dm/get-in objects [variant-id :shapes])
|
(->> (dm/get-in objects [variant-id :shapes])
|
||||||
(map #(dm/get-in objects [% :component-id]))
|
(map #(dm/get-in objects [% :component-id]))
|
||||||
(map #(ctcl/get-component data % true))
|
(map #(ctcl/get-component data % true))
|
||||||
|
|
|
@ -234,27 +234,27 @@
|
||||||
|
|
||||||
|
|
||||||
(mf/defc component-variant*
|
(mf/defc component-variant*
|
||||||
[{:keys [component shape data page-id]}]
|
[{:keys [component shape data]}]
|
||||||
(let [id-component (:id component)
|
(let [id-component (:id component)
|
||||||
properties (:variant-properties component)
|
properties (:variant-properties component)
|
||||||
variant-id (:variant-id component)
|
variant-id (:variant-id component)
|
||||||
objects (-> (dsh/get-page data page-id)
|
objects (-> (dsh/get-page data (:main-instance-page component))
|
||||||
(get :objects))
|
(get :objects))
|
||||||
|
|
||||||
related-components (cfv/find-variant-components data objects variant-id)
|
variant-components (cfv/find-variant-components data objects variant-id)
|
||||||
|
|
||||||
flat-comps ;; Get a list like [{:id 0 :prop1 "v1" :prop2 "v2"} {:id 1, :prop1 "v3" :prop2 "v4"}]
|
flat-comps ;; Get a list like [{:id 0 :prop1 "v1" :prop2 "v2"} {:id 1, :prop1 "v3" :prop2 "v4"}]
|
||||||
(map (fn [{:keys [id variant-properties]}]
|
(map (fn [{:keys [id variant-properties]}]
|
||||||
(into {:id id}
|
(into {:id id}
|
||||||
(map (fn [{:keys [name value]}] [(keyword name) value])
|
(map (fn [{:keys [name value]}] [(keyword name) value])
|
||||||
variant-properties)))
|
variant-properties)))
|
||||||
related-components)
|
variant-components)
|
||||||
|
|
||||||
get-options
|
get-options
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps related-components)
|
(mf/deps variant-components)
|
||||||
(fn [prop-name]
|
(fn [prop-name]
|
||||||
(->> related-components
|
(->> variant-components
|
||||||
(mapcat (fn [component]
|
(mapcat (fn [component]
|
||||||
(map :value (filter #(= (:name %) prop-name)
|
(map :value (filter #(= (:name %) prop-name)
|
||||||
(:variant-properties component)))))
|
(:variant-properties component)))))
|
||||||
|
@ -610,11 +610,10 @@
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[{:keys [shapes swap-opened?]}]
|
[{:keys [shapes swap-opened?]}]
|
||||||
(let [current-file-id (mf/use-ctx ctx/current-file-id)
|
(let [current-file-id (mf/use-ctx ctx/current-file-id)
|
||||||
current-page-id (mf/use-ctx ctx/current-page-id)
|
|
||||||
|
|
||||||
libraries (deref refs/files)
|
libraries (deref refs/files)
|
||||||
current-file (get libraries current-file-id)
|
current-file (get libraries current-file-id)
|
||||||
data (get current-file :data)
|
|
||||||
|
|
||||||
state* (mf/use-state
|
state* (mf/use-state
|
||||||
#(do {:show-content true
|
#(do {:show-content true
|
||||||
|
@ -637,7 +636,7 @@
|
||||||
current-file
|
current-file
|
||||||
libraries
|
libraries
|
||||||
{:include-deleted? true})
|
{:include-deleted? true})
|
||||||
|
data (dm/get-in libraries [(:component-file shape) :data])
|
||||||
variants? (features/use-feature "variants/v1")
|
variants? (features/use-feature "variants/v1")
|
||||||
is-variant? (when variants? (ctk/is-variant? component))
|
is-variant? (when variants? (ctk/is-variant? component))
|
||||||
main-instance? (ctk/main-instance? shape)
|
main-instance? (ctk/main-instance? shape)
|
||||||
|
@ -750,7 +749,7 @@
|
||||||
[:& component-annotation {:id id :shape shape :component component :rerender-fn rerender-fn}])
|
[:& component-annotation {:id id :shape shape :component component :rerender-fn rerender-fn}])
|
||||||
|
|
||||||
(when (and is-variant? (not swap-opened?) (not multi))
|
(when (and is-variant? (not swap-opened?) (not multi))
|
||||||
[:> component-variant* {:component component :shape shape :data data :page-id current-page-id}])
|
[:> component-variant* {:component component :shape shape :data data}])
|
||||||
|
|
||||||
(when (dbg/enabled? :display-touched)
|
(when (dbg/enabled? :display-touched)
|
||||||
[:div ":touched " (str (:touched shape))])])])))
|
[:div ":touched " (str (:touched shape))])])])))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue