mirror of
https://github.com/penpot/penpot.git
synced 2026-09-12 15:09:38 +00:00
🎉 Activate variants for everyone
This commit is contained in:
parent
9f24e76c27
commit
307e06372b
@ -36,11 +36,6 @@
|
|||||||
"fdata/shape-data-type"
|
"fdata/shape-data-type"
|
||||||
nil
|
nil
|
||||||
|
|
||||||
;; There is no migration needed, but we don't want to allow
|
|
||||||
;; copy paste nor import of variant files into no-variant teams
|
|
||||||
"variants/v1"
|
|
||||||
nil
|
|
||||||
|
|
||||||
(ex/raise :type :internal
|
(ex/raise :type :internal
|
||||||
:code :no-migration-defined
|
:code :no-migration-defined
|
||||||
:hint (str/ffmt "no migation for feature '%' on file importation" feature)
|
:hint (str/ffmt "no migation for feature '%' on file importation" feature)
|
||||||
|
|||||||
@ -64,7 +64,8 @@
|
|||||||
"layout/grid"
|
"layout/grid"
|
||||||
"components/v2"
|
"components/v2"
|
||||||
"plugins/runtime"
|
"plugins/runtime"
|
||||||
"design-tokens/v1"})
|
"design-tokens/v1"
|
||||||
|
"variants/v1"})
|
||||||
|
|
||||||
;; A set of features that should not be propagated to team on creating
|
;; A set of features that should not be propagated to team on creating
|
||||||
;; or modifying a file
|
;; or modifying a file
|
||||||
@ -95,7 +96,8 @@
|
|||||||
(-> #{"layout/grid"
|
(-> #{"layout/grid"
|
||||||
"design-tokens/v1"
|
"design-tokens/v1"
|
||||||
"fdata/shape-data-type"
|
"fdata/shape-data-type"
|
||||||
"fdata/path-data"}
|
"fdata/path-data"
|
||||||
|
"variants/v1"}
|
||||||
(into frontend-only-features)
|
(into frontend-only-features)
|
||||||
(into backend-only-features)))
|
(into backend-only-features)))
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,6 @@
|
|||||||
[app.main.data.workspace.shapes :as dwsh]
|
[app.main.data.workspace.shapes :as dwsh]
|
||||||
[app.main.data.workspace.transforms :as dwt]
|
[app.main.data.workspace.transforms :as dwt]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
@ -446,19 +445,16 @@
|
|||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [variants? (features/active-feature? state "variants/v1")
|
(let [objects (dsh/lookup-page-objects state)
|
||||||
objects (dsh/lookup-page-objects state)
|
|
||||||
selected-ids (dsh/lookup-selected state)
|
selected-ids (dsh/lookup-selected state)
|
||||||
selected-shapes (map (d/getf objects) selected-ids)
|
selected-shapes (map (d/getf objects) selected-ids)
|
||||||
single? (= 1 (count selected-ids))
|
single? (= 1 (count selected-ids))
|
||||||
first-shape (first selected-shapes)
|
first-shape (first selected-shapes)
|
||||||
|
|
||||||
transform-in-variant? (and variants?
|
transform-in-variant? (and single?
|
||||||
single?
|
|
||||||
(not (ctc/is-variant? first-shape))
|
(not (ctc/is-variant? first-shape))
|
||||||
(ctc/main-instance? first-shape))
|
(ctc/main-instance? first-shape))
|
||||||
add-new-variant? (and variants?
|
add-new-variant? (every? ctc/is-variant? selected-shapes)
|
||||||
(every? ctc/is-variant? selected-shapes))
|
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(cond
|
(cond
|
||||||
transform-in-variant?
|
transform-in-variant?
|
||||||
@ -479,12 +475,10 @@
|
|||||||
(ptk/reify ::duplicate-or-add-variant
|
(ptk/reify ::duplicate-or-add-variant
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [variants? (features/active-feature? state "variants/v1")
|
(let [objects (dsh/lookup-page-objects state)
|
||||||
objects (dsh/lookup-page-objects state)
|
|
||||||
selected-ids (dsh/lookup-selected state)
|
selected-ids (dsh/lookup-selected state)
|
||||||
selected-shapes (map (d/getf objects) selected-ids)
|
selected-shapes (map (d/getf objects) selected-ids)
|
||||||
add-new-variant? (and variants?
|
add-new-variant? (every? ctc/is-variant? selected-shapes)
|
||||||
(every? ctc/is-variant? selected-shapes))
|
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(if add-new-variant?
|
(if add-new-variant?
|
||||||
(rx/concat
|
(rx/concat
|
||||||
|
|||||||
@ -23,7 +23,6 @@
|
|||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
[app.main.data.workspace.variants :as dwv]
|
[app.main.data.workspace.variants :as dwv]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.render :refer [component-svg component-svg-thumbnail]]
|
[app.main.render :refer [component-svg component-svg-thumbnail]]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
@ -382,8 +381,6 @@
|
|||||||
can-detach? (and (seq copies)
|
can-detach? (and (seq copies)
|
||||||
(every? #(not (ctn/has-any-copy-parent? objects %)) copies))
|
(every? #(not (ctn/has-any-copy-parent? objects %)) copies))
|
||||||
|
|
||||||
variants? (features/use-feature "variants/v1")
|
|
||||||
|
|
||||||
same-variant? (ctv/same-variant? shapes)
|
same-variant? (ctv/same-variant? shapes)
|
||||||
|
|
||||||
is-restorable-variant?
|
is-restorable-variant?
|
||||||
@ -401,8 +398,7 @@
|
|||||||
parent (get objects (:parent-id main))]
|
parent (get objects (:parent-id main))]
|
||||||
(and (:deleted component) (ctk/is-variant? component) parent)))
|
(and (:deleted component) (ctk/is-variant? component) parent)))
|
||||||
|
|
||||||
restorable-variants? (and variants?
|
restorable-variants? (every? is-restorable-variant? restorable-copies)
|
||||||
(every? is-restorable-variant? restorable-copies))
|
|
||||||
|
|
||||||
do-detach-component
|
do-detach-component
|
||||||
#(st/emit! (dwl/detach-components (map :id copies)))
|
#(st/emit! (dwl/detach-components (map :id copies)))
|
||||||
@ -437,10 +433,9 @@
|
|||||||
#(st/emit! (dw/set-annotations-id-for-create id))
|
#(st/emit! (dw/set-annotations-id-for-create id))
|
||||||
|
|
||||||
do-add-variant
|
do-add-variant
|
||||||
#(when variants?
|
#(if (ctk/is-variant? shape)
|
||||||
(if (ctk/is-variant? shape)
|
(st/emit! (dwv/add-new-variant id))
|
||||||
(st/emit! (dwv/add-new-variant id))
|
(st/emit! (dwv/transform-in-variant id)))
|
||||||
(st/emit! (dwv/transform-in-variant id))))
|
|
||||||
|
|
||||||
do-add-new-property
|
do-add-new-property
|
||||||
#(st/emit! (dwv/add-new-property variant-id {:property-value "Value 1"
|
#(st/emit! (dwv/add-new-property variant-id {:property-value "Value 1"
|
||||||
@ -501,11 +496,11 @@
|
|||||||
(when can-update-main?
|
(when can-update-main?
|
||||||
{:title (tr "workspace.shape.menu.update-main")
|
{:title (tr "workspace.shape.menu.update-main")
|
||||||
:action do-update-component})
|
:action do-update-component})
|
||||||
(when (and variants? (or (not multi) same-variant?) main-instance?)
|
(when (and (or (not multi) same-variant?) main-instance?)
|
||||||
{:title (tr "workspace.shape.menu.add-variant")
|
{:title (tr "workspace.shape.menu.add-variant")
|
||||||
:shortcut :create-component
|
:shortcut :create-component
|
||||||
:action do-add-variant})
|
:action do-add-variant})
|
||||||
(when (and variants? same-variant? main-instance? variant-id)
|
(when (and same-variant? main-instance? variant-id)
|
||||||
{:title (tr "workspace.shape.menu.add-variant-property")
|
{:title (tr "workspace.shape.menu.add-variant-property")
|
||||||
:action do-add-new-property})]]
|
:action do-add-new-property})]]
|
||||||
(filter (complement nil?) menu-entries)))
|
(filter (complement nil?) menu-entries)))
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.collapse :as dwc]
|
[app.main.data.workspace.collapse :as dwc]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
@ -53,10 +52,8 @@
|
|||||||
parent-board? (and (cfh/frame-shape? item)
|
parent-board? (and (cfh/frame-shape? item)
|
||||||
(= uuid/zero (:parent-id item)))
|
(= uuid/zero (:parent-id item)))
|
||||||
absolute? (ctl/item-absolute? item)
|
absolute? (ctl/item-absolute? item)
|
||||||
|
is-variant? (ctk/is-variant? item)
|
||||||
variants? (features/use-feature "variants/v1")
|
is-variant-container? (ctk/is-variant-container? item)
|
||||||
is-variant? (when variants? (ctk/is-variant? item))
|
|
||||||
is-variant-container? (when variants? (ctk/is-variant-container? item))
|
|
||||||
variant-id (when is-variant? (:variant-id item))
|
variant-id (when is-variant? (:variant-id item))
|
||||||
variant-name (when is-variant? (:variant-name item))
|
variant-name (when is-variant? (:variant-name item))
|
||||||
variant-error (when is-variant? (:variant-error item))
|
variant-error (when is-variant? (:variant-error item))
|
||||||
|
|||||||
@ -21,7 +21,6 @@
|
|||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[app.main.data.workspace.specialized-panel :as dwsp]
|
[app.main.data.workspace.specialized-panel :as dwsp]
|
||||||
[app.main.data.workspace.variants :as dwv]
|
[app.main.data.workspace.variants :as dwv]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.dropdown :refer [dropdown]]
|
[app.main.ui.components.dropdown :refer [dropdown]]
|
||||||
@ -833,8 +832,7 @@
|
|||||||
libraries
|
libraries
|
||||||
{:include-deleted? true})
|
{:include-deleted? true})
|
||||||
data (dm/get-in libraries [(:component-file shape) :data])
|
data (dm/get-in libraries [(:component-file shape) :data])
|
||||||
variants? (features/use-feature "variants/v1")
|
is-variant? (ctk/is-variant? component)
|
||||||
is-variant? (when variants? (ctk/is-variant? component))
|
|
||||||
|
|
||||||
main-instance? (ctk/main-instance? shape)
|
main-instance? (ctk/main-instance? shape)
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]]
|
[app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]]
|
||||||
[app.main.ui.workspace.sidebar.options.menus.color-selection :refer [color-selection-menu*]]
|
[app.main.ui.workspace.sidebar.options.menus.color-selection :refer [color-selection-menu*]]
|
||||||
@ -92,11 +91,8 @@
|
|||||||
is-layout-child-absolute?
|
is-layout-child-absolute?
|
||||||
(ctl/item-absolute? shape)
|
(ctl/item-absolute? shape)
|
||||||
|
|
||||||
variants?
|
|
||||||
(features/use-feature "variants/v1")
|
|
||||||
|
|
||||||
is-variant?
|
is-variant?
|
||||||
(when variants? (ctk/is-variant-container? shape))]
|
(ctk/is-variant-container? shape)]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:> layer-menu* {:ids ids
|
[:> layer-menu* {:ids ids
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
[app.main.data.common :as dcm]
|
[app.main.data.common :as dcm]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.interactions :as dwi]
|
[app.main.data.workspace.interactions :as dwi]
|
||||||
[app.main.features :as features]
|
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
@ -132,8 +131,7 @@
|
|||||||
(on-frame-leave (:id frame))))
|
(on-frame-leave (:id frame))))
|
||||||
|
|
||||||
main-instance? (ctk/main-instance? frame)
|
main-instance? (ctk/main-instance? frame)
|
||||||
variants? (features/use-feature "variants/v1")
|
is-variant? (:is-variant-container frame)
|
||||||
is-variant? (when variants? (:is-variant-container frame))
|
|
||||||
|
|
||||||
text-width (* (:width frame) zoom)
|
text-width (* (:width frame) zoom)
|
||||||
show-icon? (and (or (:use-for-thumbnail frame) grid-edition? main-instance? is-variant?)
|
show-icon? (and (or (:use-for-thumbnail frame) grid-edition? main-instance? is-variant?)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user