Skip to content

feat(design-system): setup Figma Code Connect CLI [AR-71339]#553

Open
iromanchuk-dn wants to merge 5 commits into
drivenets:mainfrom
iromanchuk-dn:AR-71339-setup-code-connect-cli-for-ds-status-badge-v-2
Open

feat(design-system): setup Figma Code Connect CLI [AR-71339]#553
iromanchuk-dn wants to merge 5 commits into
drivenets:mainfrom
iromanchuk-dn:AR-71339-setup-code-connect-cli-for-ds-status-badge-v-2

Conversation

@iromanchuk-dn

Copy link
Copy Markdown
Collaborator

Figma Code Connect setup

  • Added @figma/code-connect devDependency and scripts in packages/design-system/package.json:
    • figma:validate — parse/check mappings locally
    • figma:publish — publish to Figma Dev Mode
  • Added figma.config.json — scans *.figma.ts / *.stories.tsx, maps imports to @drivenets/design-system, React/JSX label
  • Updated tsconfig.json — includes @figma/code-connect/figma-types for editor/type support

CI

  • Added .github/workflows/figma-code-connect.yml:
    • PR: validates Code Connect files when relevant paths change
    • main push / manual: publishes to Figma using FIGMA_ACCESS_TOKEN secret

Before merge

  • @StyleShit / @aroba-dn could you add the FIGMA_ACCESS_TOKEN GitHub Actions secret (Figma PAT with Code Connect write + file content read) so the publish job can run after merge.

First component mapping

  • Added ds-status-badge-v2.figma.ts — maps the Figma DsStatusBadgeV2 component to React code, handling phase, variant, size, structure (icon+text / icon-only / text-only), and dynamic label
image image image

@netlify

netlify Bot commented Jun 18, 2026

Copy link
Copy Markdown

Deploy Preview for drivenets-design-system ready!

Name Link
🔨 Latest commit 8e360fc
🔍 Latest deploy log https://app.netlify.com/projects/drivenets-design-system/deploys/6a351c7a797b8d0008b92dc8
😎 Deploy Preview https://deploy-preview-553--drivenets-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.


export default {
example:
structure === 'icon-only'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious... so we define examples here (hard code) and in the stories? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great question!
I had a debate over this half of the day yesterday.
Here is my conversation with LLM: https://chatgpt.com/share/e/6a351ac3-55ec-832e-b54d-fb7ed40f2a75
TLDR: we keep figma.ts files small and simple, for complex examples like DsTable we rely on Storybook.

I've implemented ds-status-badge-v2 docs via "Figma Code Connect + Storybook integration" and via ".figma.ts" file. "Figma Code Connect + Storybook integration" is very limited, I could not map "icon-only" boolean React prop to "structure=='icon-only'" property in Figma, also stories that render all possible component variants at once are not suitable for Figma Code Connect. Comparing the code of 2 approaches I could clearly see that .figma.ts is better, despite it looks like a duplicated at first glance. Moreover, Figma MCP contains skill that help you write figma.ts file, so it's even easier to maintain separate files than inside storybook.

? figma.code`<DsStatusBadgeV2 phase="${phase}" label="${label}" variant="${variant}" size="${size}" icon={null} />`
: figma.code`<DsStatusBadgeV2 phase="${phase}" label="${label}" variant="${variant}" size="${size}" />`,
imports: ["import { DsStatusBadgeV2 } from '@drivenets/design-system'"],
id: 'ds-status-badge-v2',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, what happens if we change the name and ID? In figma everything just updates, si?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, every time figma publish command runs, it overwrites everything

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a release for this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's separate this into 2 workflows

  • pull_request - validation (figma-code-connect-validate.yml)
  • push: main - publish (figma-code-connect-publish.yml)

Comment on lines +5 to +9
paths: &figma_paths
- packages/design-system/**/*.figma.ts
- packages/design-system/figma.config.json
- packages/design-system/package.json
- .github/workflows/figma-code-connect.yml

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having a list here, let's move this to a turborepo task, so it'll be cached

- name: Publish Code Connect files
run: pnpm --filter @drivenets/design-system figma:publish
env:
FIGMA_ACCESS_TOKEN: ${{ secrets.FIGMA_ACCESS_TOKEN }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's talk about this, we'll need to define it. We might need to involve other people for this.

@@ -0,0 +1,10 @@
{
"codeConnect": {
"include": ["**/*.figma.ts", "**/*.stories.tsx"],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"include": ["**/*.figma.ts", "**/*.stories.tsx"],
"include": ["**/*.figma.ts"],

Comment on lines +4 to +6
"importPaths": {
"src/components/*": "@drivenets/design-system"
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants