From 1b55ba8d9d7fb727e561d6c66850c3121f9901af Mon Sep 17 00:00:00 2001 From: hiroshi Date: Tue, 17 Oct 2023 15:25:56 -0400 Subject: [PATCH 1/2] feat: add description when create variables --- src/app/components/EditTokenForm.tsx | 14 +++++++++++--- src/plugin/setValuesOnVariable.ts | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/components/EditTokenForm.tsx b/src/app/components/EditTokenForm.tsx index 9044b1898..04c4cd8b8 100644 --- a/src/app/components/EditTokenForm.tsx +++ b/src/app/components/EditTokenForm.tsx @@ -90,9 +90,17 @@ function EditTokenForm({ resolvedTokens }: Props) { }, [internalEditToken, error, isValidColorToken, isValidDimensionToken]); const hasNameThatExistsAlready = React.useMemo( - () => resolvedTokens - .filter((t) => t.internal__Parent === activeTokenSet) - .find((t) => t.name === internalEditToken?.name), + () => { + const editToken = resolvedTokens + .filter((t) => t.internal__Parent === activeTokenSet) + .find((t) => t.name === internalEditToken?.name); + + if (editToken) { + editToken.description = internalEditToken.description; + } + + return editToken; + }, [internalEditToken, resolvedTokens, activeTokenSet], ); diff --git a/src/plugin/setValuesOnVariable.ts b/src/plugin/setValuesOnVariable.ts index 4d3678bdf..1800b89fe 100644 --- a/src/plugin/setValuesOnVariable.ts +++ b/src/plugin/setValuesOnVariable.ts @@ -29,6 +29,7 @@ export default function setValuesOnVariable( variable = figma.variables.createVariable(t.path, collection.id, variableType); } if (variable) { + variable.description = t.description ?? ''; switch (variableType) { case 'BOOLEAN': if (typeof t.value === 'string') { @@ -70,6 +71,7 @@ export default function setValuesOnVariable( } catch (e) { console.error('Setting values on variable is failed', e); } + return { variableKeyMap, referenceVariableCandidates, From de30344a27dd0bfb480e19bb0073b6b8ef5fb7a9 Mon Sep 17 00:00:00 2001 From: SorsOps <80043879+sorsOps@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:51:23 +0200 Subject: [PATCH 2/2] Add changeset --- .changeset/dirty-otters-notice.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/dirty-otters-notice.md diff --git a/.changeset/dirty-otters-notice.md b/.changeset/dirty-otters-notice.md new file mode 100644 index 000000000..ce43d93a2 --- /dev/null +++ b/.changeset/dirty-otters-notice.md @@ -0,0 +1,5 @@ +--- +'@tokens-studio/figma-plugin': patch +--- + +We now carry over token descriptions when creating variables