Skip to content

feat: Update Switch Code Connect with proper Figma mappings#9

Open
beaucalvez wants to merge 2 commits intomainfrom
feat/switch-code-connect
Open

feat: Update Switch Code Connect with proper Figma mappings#9
beaucalvez wants to merge 2 commits intomainfrom
feat/switch-code-connect

Conversation

@beaucalvez
Copy link
Collaborator

Summary

  • Fixed Switch.figma.tsx to use local DS component instead of Mantine directly
  • Added proper property mappings for all Figma properties
  • Implemented conditional spread to optimize prop output
  • Successfully tested with both populated and empty inner labels

What Changed

  1. Import fix: Changed from @mantine/core to ./Switch (local DS component)
  2. Size mapping: Added all 5 size variants (xs, sm, md, lg, xl)
  3. Property mapping: Added label, checked, onLabel, offLabel from Figma
  4. Conditional spread: Only include onLabel/offLabel when they have values
  5. Node ID update: Updated to point to correct Figma component (5449-1439)

Code Optimization

Uses conditional spread operators to omit empty props:

{...(props.onLabel && { onLabel: props.onLabel })}
{...(props.offLabel && { offLabel: props.offLabel })}

When onLabel="" and offLabel="", the generated code is:

<Switch size="lg" label="Enable feature" checked />

When onLabel="ON" and offLabel="OFF", the generated code is:

<Switch size="lg" label="Enable feature" checked onLabel="ON" offLabel="OFF" />

Test Plan

  • Tested with Figma component with onLabel/offLabel populated
  • Tested with Figma component with empty onLabel/offLabel
  • Verified conditional spread works correctly
  • Published to Figma successfully
  • Code Connect shows correct React code in Figma Dev Resources

Made with Cursor

beaucalvez and others added 2 commits February 13, 2026 16:16
- Fix Radio.figma.tsx to remove value and name props (not in Figma component)
- Update figma.config.json to include all .tsx files for proper import resolution
- Add figma-publish.sh script to properly load .env.local token
- Update package.json to use shell script for figma:publish command
- Successfully published 41 Code Connect components to Figma

The Code Connect setup now works correctly with npm run figma:publish
and properly maps all component properties from Figma to React code.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Fix import from @mantine/core to ./Switch (local DS component)
- Add all size variants (xs, sm, md, lg, xl)
- Map label, checked, onLabel, and offLabel properties from Figma
- Use conditional spread to omit empty onLabel/offLabel props
- Update node-id to point to correct Figma component

The Code Connect now properly generates clean Switch code with
optional inner labels only when they have values.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants