diff --git a/CHANGES.md b/CHANGES.md index 750b9862dc..f0c72352fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -106,6 +106,7 @@ - Fix conflicting shortcuts (remove dec/inc line height and letter spacing) [Taiga #12102](https://tree.taiga.io/project/penpot/issue/12102) - Fix conflicting shortcuts (remove text-align shortcuts) [Taiga #12047](https://tree.taiga.io/project/penpot/issue/12047) - Fix export file with empty tokens library [Taiga #12137](https://tree.taiga.io/project/penpot/issue/12137) +- Fix context menu on spacing tokens [Taiga #12141](https://tree.taiga.io/project/penpot/issue/12141) ## 2.9.0 diff --git a/common/src/app/common/flags.cljc b/common/src/app/common/flags.cljc index 6b307baab7..7b96d63c22 100644 --- a/common/src/app/common/flags.cljc +++ b/common/src/app/common/flags.cljc @@ -157,7 +157,9 @@ :enable-dashboard-templates-section :enable-google-fonts-provider :enable-component-thumbnails - :enable-render-wasm-dpr]) + :enable-render-wasm-dpr + :enable-token-units + :enable-token-typography-types]) (defn parse [& flags] diff --git a/common/src/app/common/types/token.cljc b/common/src/app/common/types/token.cljc index 82fc167793..a83d5b919a 100644 --- a/common/src/app/common/types/token.cljc +++ b/common/src/app/common/types/token.cljc @@ -177,6 +177,13 @@ (def spacing-keys (schema-keys schema:spacing)) +(def ^:private schema:spacing-gap-padding + (-> (reduce mu/union [schema:spacing-gap + schema:spacing-padding]) + (mu/update-properties assoc :title "SpacingGapPaddingTokenAttrs"))) + +(def spacing-gap-padding-keys (schema-keys schema:spacing-gap-padding)) + (def ^:private schema:dimensions (-> (reduce mu/union [schema:sizing schema:spacing @@ -360,9 +367,9 @@ (set/union generic-attributes border-radius-keys)) -(def frame-attributes +(def frame-with-layout-attributes (set/union rect-attributes - spacing-keys)) + spacing-gap-padding-keys)) (def text-attributes (set/union generic-attributes @@ -370,12 +377,14 @@ number-keys)) (defn shape-type->attributes - [type] + [type is-layout] (case type :bool generic-attributes :circle generic-attributes :rect rect-attributes - :frame frame-attributes + :frame (if is-layout + frame-with-layout-attributes + rect-attributes) :image rect-attributes :path generic-attributes :svg-raw generic-attributes @@ -383,14 +392,14 @@ nil)) (defn appliable-attrs - "Returns intersection of shape `attributes` for `token-type`." - [attributes token-type] - (set/intersection attributes (shape-type->attributes token-type))) + "Returns intersection of shape `attributes` for `shape-type`." + [attributes shape-type is-layout] + (set/intersection attributes (shape-type->attributes shape-type is-layout))) (defn any-appliable-attr? "Checks if `token-type` supports given shape `attributes`." - [attributes token-type] - (seq (appliable-attrs attributes token-type))) + [attributes token-type is-layout] + (seq (appliable-attrs attributes token-type is-layout))) ;; Token attrs that are set inside content blocks of text shapes, instead ;; at the shape level. diff --git a/frontend/src/app/main/data/workspace/tokens/application.cljs b/frontend/src/app/main/data/workspace/tokens/application.cljs index 3dc3a8930c..bc47fb8c21 100644 --- a/frontend/src/app/main/data/workspace/tokens/application.cljs +++ b/frontend/src/app/main/data/workspace/tokens/application.cljs @@ -489,7 +489,7 @@ (or (and (ctsl/any-layout-immediate-child? objects shape) (some ctt/spacing-margin-keys attributes)) - (ctt/any-appliable-attr? attributes (:type shape)))))) + (ctt/any-appliable-attr? attributes (:type shape) (:layout shape)))))) shape-ids (d/nilv (keys shapes) []) any-variant? (->> shapes vals (some ctk/is-variant?) boolean) diff --git a/frontend/src/app/main/ui/workspace/tokens/management/context_menu.cljs b/frontend/src/app/main/ui/workspace/tokens/management/context_menu.cljs index b4e393c8ec..a16617b0fb 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/context_menu.cljs @@ -342,7 +342,7 @@ (:id token)))}])) (defn- allowed-shape-attributes [shapes] - (reduce into #{} (map #(ctt/shape-type->attributes (:type %)) shapes))) + (reduce into #{} (map #(ctt/shape-type->attributes (:type %) (:layout %)) shapes))) (defn menu-actions [{:keys [type token selected-shapes] :as context-data}] (let [context-data (assoc context-data :allowed-shape-attributes (allowed-shape-attributes selected-shapes)) @@ -446,7 +446,8 @@ (if (some? type) (submenu-actions-selection-actions context-data) (selection-actions context-data)) - (default-actions context-data))] + (default-actions context-data)) + entries (clean-separators entries)] (for [[index {:keys [title action selected? hint submenu no-selectable] :as entry}] (d/enumerate entries)] [:* {:key (dm/str title " " index)} (cond diff --git a/frontend/src/app/main/ui/workspace/tokens/management/token_pill.cljs b/frontend/src/app/main/ui/workspace/tokens/management/token_pill.cljs index 91e5da6753..7af9d29ae5 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/token_pill.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/token_pill.cljs @@ -166,7 +166,7 @@ ;; Edge-case for allowing margin attribute on shapes inside layout parent (and selected-inside-layout? (set/subset? ctt/spacing-margin-keys attrs)) (some (fn [shape] - (ctt/any-appliable-attr? attrs (:type shape))) + (ctt/any-appliable-attr? attrs (:type shape) (:layout shape))) selected-shapes))) (def token-types-with-status-icon diff --git a/frontend/test/frontend_tests/tokens/logic/token_actions_test.cljs b/frontend/test/frontend_tests/tokens/logic/token_actions_test.cljs index 4b45dd89df..3f7c83007d 100644 --- a/frontend/test/frontend_tests/tokens/logic/token_actions_test.cljs +++ b/frontend/test/frontend_tests/tokens/logic/token_actions_test.cljs @@ -303,10 +303,10 @@ frame-1' (cths/get-shape file' :frame-1) frame-2' (cths/get-shape file' :frame-2)] (t/testing "shape `:applied-tokens` got updated" - (t/is (= (:p1 (:applied-tokens frame-1')) (:name token-target'))) - (t/is (= (:p2 (:applied-tokens frame-1')) (:name token-target'))) - (t/is (= (:p3 (:applied-tokens frame-1')) (:name token-target'))) - (t/is (= (:p4 (:applied-tokens frame-1')) (:name token-target'))) + (t/is (= (:p1 (:applied-tokens frame-1')) nil)) + (t/is (= (:p2 (:applied-tokens frame-1')) nil)) + (t/is (= (:p3 (:applied-tokens frame-1')) nil)) + (t/is (= (:p4 (:applied-tokens frame-1')) nil)) (t/is (= (:p1 (:applied-tokens frame-2')) (:name token-target'))) (t/is (= (:p2 (:applied-tokens frame-2')) (:name token-target')))