From 9244501c6e36cf00e9838d4bf34317aa272d8bfa Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 09:56:44 +0200 Subject: [PATCH 1/6] :sparkles: Add variants/v1 feature to default features emited by sdk --- common/src/app/common/files/builder.cljc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index 181824c672..3a3f734d61 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -200,7 +200,8 @@ "layout/grid" "components/v2" "plugins/runtime" - "design-tokens/v1"}) + "design-tokens/v1" + "variants/v1"}) ;; WORKAROUND: the same as features (def available-migrations From b30cb0e0848de8266d95cd5c914a19dfcd59a3ef Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 10:28:00 +0200 Subject: [PATCH 2/6] :sparkles: Allow pass variant related attrs on add-component change --- common/src/app/common/files/changes.cljc | 8 ++++++-- common/src/app/common/types/components_list.cljc | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/files/changes.cljc b/common/src/app/common/files/changes.cljc index 73f48f5661..62810a0e02 100644 --- a/common/src/app/common/files/changes.cljc +++ b/common/src/app/common/files/changes.cljc @@ -320,14 +320,18 @@ [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:path {:optional true} :string] [:main-instance-id ::sm/uuid] - [:main-instance-page ::sm/uuid]]] + [:main-instance-page ::sm/uuid] + ;; Only used by external processes (like Penpot SDK) + [:variant-id {:optional true} ::sm/uuid] + [:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]] [:mod-component [:map {:title "ModCompoenentChange"} [:type [:= :mod-component]] [:id ::sm/uuid] - [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:name {:optional true} :string] + [:path {:optional true} :string] + [:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]] [:variant-id {:optional true} ::sm/uuid] [:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]] diff --git a/common/src/app/common/types/components_list.cljc b/common/src/app/common/types/components_list.cljc index fd75341681..68d8e72ef0 100644 --- a/common/src/app/common/types/components_list.cljc +++ b/common/src/app/common/types/components_list.cljc @@ -35,7 +35,7 @@ (defn add-component [fdata {:keys [id name path main-instance-id main-instance-page annotation variant-id variant-properties]}] - (let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))] + (let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))] (cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page) annotation (update-in [:components id] assoc :annotation annotation) variant-id (update-in [:components id] assoc :variant-id variant-id) @@ -83,9 +83,11 @@ (nil? variant-properties) (dissoc :variant-properties)) + + ;; The set of properties that doesn't mark a component as touched diff (set/difference (ctk/diff-components component new-comp) - #{:annotation :modified-at :variant-id :variant-properties})] ;; The set of properties that doesn't mark a component as touched + #{:annotation :modified-at :variant-id :variant-properties})] (if (empty? diff) new-comp From 588eb0b4fa7e38c57e68db85f77d6130816b6dea Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 10:28:24 +0200 Subject: [PATCH 3/6] :arrow_up: Update shadow-cljs dependency on sdk --- library/deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/deps.edn b/library/deps.edn index 0b2473bf81..9edca59650 100644 --- a/library/deps.edn +++ b/library/deps.edn @@ -21,7 +21,7 @@ :dev {:extra-paths ["dev"] :extra-deps - {thheller/shadow-cljs {:mvn/version "3.1.7"} + {thheller/shadow-cljs {:mvn/version "3.2.1"} com.bhauman/rebel-readline {:mvn/version "RELEASE"} org.clojure/tools.namespace {:mvn/version "RELEASE"} criterium/criterium {:mvn/version "RELEASE"}}} From 6b0d0a302f57889036c543d08ea31403978ba811 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 11:52:08 +0200 Subject: [PATCH 4/6] :sparkles: Enable variant attrs on SDK addComponent method --- common/src/app/common/files/builder.cljc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/files/builder.cljc b/common/src/app/common/files/builder.cljc index 3a3f734d61..6dbaf47efd 100644 --- a/common/src/app/common/files/builder.cljc +++ b/common/src/app/common/files/builder.cljc @@ -8,11 +8,11 @@ "Internal implementation of file builder. Mainly used as base impl for penpot library" (:require + ;; [app.common.features :as cfeat] [app.common.data :as d] [app.common.data.macros :as dm] [app.common.exceptions :as ex] [app.common.files.changes :as ch] - ;; [app.common.features :as cfeat] [app.common.files.helpers :as cph] [app.common.files.migrations :as fmig] [app.common.geom.shapes :as gsh] @@ -26,6 +26,7 @@ [app.common.types.path :as types.path] [app.common.types.shape :as types.shape] [app.common.types.typography :as types.typography] + [app.common.types.variant :as types.variant] [app.common.uuid :as uuid] [cuerdas.core :as str])) @@ -126,10 +127,12 @@ [:map [:component-id ::sm/uuid] [:file-id {:optional true} ::sm/uuid] + [:page-id {:optional true} ::sm/uuid] + [:frame-id {:optional true} ::sm/uuid] [:name {:optional true} ::sm/text] [:path {:optional true} ::sm/text] - [:frame-id {:optional true} ::sm/uuid] - [:page-id {:optional true} ::sm/uuid]]) + [:variant-id {:optional true} ::sm/uuid] + [:variant-properties {:optional true} [:vector types.variant/schema:variant-property]]]) (def ^:private check-add-component (sm/check-fn schema:add-component @@ -444,7 +447,7 @@ (defn add-component [state params] - (let [{:keys [component-id file-id page-id frame-id name path]} + (let [{:keys [component-id file-id page-id frame-id name path variant-id variant-properties]} (-> (check-add-component params) (update :component-id default-uuid)) @@ -464,7 +467,9 @@ :name (or name "anonmous") :path path :main-instance-id frame-id - :main-instance-page page-id}) + :main-instance-page page-id + :variant-id variant-id + :variant-properties variant-properties}) change2 {:type :mod-obj From 987dea80484a1e764be9aeb3c0e9c518ecefcc8d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 11:53:26 +0200 Subject: [PATCH 5/6] :books: Update changelog --- library/CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/CHANGES.md b/library/CHANGES.md index 22cd12ea2e..71fa68ffb8 100644 --- a/library/CHANGES.md +++ b/library/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.0.10 + +- Enable variant/v1 feature by default +- Add variant attrs handling to addComponent method + + ## 1.0.9 - Fix dependencies declaration on package.json From 613acd5b29b9221b5156e8383d34e4ff60934515 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 6 Oct 2025 11:56:23 +0200 Subject: [PATCH 6/6] :paperclip: Update version on library/package.json file --- library/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/package.json b/library/package.json index 13851f6d6d..c2d967f1b4 100644 --- a/library/package.json +++ b/library/package.json @@ -1,6 +1,6 @@ { "name": "@penpot/library", - "version": "1.0.9", + "version": "1.0.10", "license": "MPL-2.0", "author": "Kaleidos INC", "packageManager": "yarn@4.9.1+sha512.f95ce356460e05be48d66401c1ae64ef84d163dd689964962c6888a9810865e39097a5e9de748876c2e0bf89b232d583c33982773e9903ae7a76257270986538",