@@ -363,6 +363,72 @@ export const extractSkinJsonData = (
363363 } ;
364364 } ) ;
365365
366+ const spacingArray = Object . keys (
367+ parsedContent . spacing
368+ ) . flatMap ( ( key ) => {
369+ const value =
370+ parsedContent . spacing [ key ] . value ;
371+ const result = [ ] ;
372+
373+ // Helper to capitalize axis/side and append to token name
374+ const capitalize = ( str ) =>
375+ str . charAt ( 0 ) . toUpperCase ( ) +
376+ str . slice ( 1 ) ;
377+
378+ // Push all breakpoints for a given axis or side
379+ const pushBreakpoints = (
380+ axisOrSide ,
381+ breakpoints
382+ ) => {
383+ Object . keys ( breakpoints ) . forEach (
384+ ( breakpoint ) => {
385+ // Build Figma-friendly name
386+ const figmaName = axisOrSide
387+ ? `${ key } ${ capitalize ( axisOrSide ) } `
388+ : key ;
389+
390+ result . push ( {
391+ name : `spacing/${ breakpoint } /${ figmaName } ` ,
392+ value : Number (
393+ breakpoints [ breakpoint ]
394+ ) ,
395+ } ) ;
396+ }
397+ ) ;
398+ } ;
399+
400+ // CASE 1 — scalar (all sides or gap)
401+ if (
402+ typeof value === "object" &&
403+ value !== null &&
404+ ! ( "x" in value ) &&
405+ ! ( "y" in value ) &&
406+ ! ( "top" in value )
407+ ) {
408+ pushBreakpoints ( null , value ) ;
409+ return result ;
410+ }
411+
412+ // CASE 2 — axis-based (x / y)
413+ if ( "x" in value || "y" in value ) {
414+ if ( value . x )
415+ pushBreakpoints ( "x" , value . x ) ;
416+ if ( value . y )
417+ pushBreakpoints ( "y" , value . y ) ;
418+ return result ;
419+ }
420+
421+ // CASE 3 — side-based (top / right / bottom / left)
422+ [ "top" , "right" , "bottom" , "left" ] . forEach (
423+ ( side ) => {
424+ if ( value [ side ] )
425+ pushBreakpoints ( side , value [ side ] ) ;
426+ }
427+ ) ;
428+
429+ return result ;
430+ } ) ;
431+
366432 // Accumulate results
367433 accumulator [ fileName ] = {
368434 light : processColors (
@@ -380,6 +446,7 @@ export const extractSkinJsonData = (
380446 fontWeight : fontWeightArray ,
381447 fontSize : fontSizeArray ,
382448 lineHeight : lineHeightArray ,
449+ spacing : spacingArray ,
383450 } ;
384451
385452 return accumulator ;
@@ -760,6 +827,72 @@ export const extractMiddlewareJsonData = (
760827 } ;
761828 } ) ;
762829
830+ const spacingArray = Object . keys (
831+ parsedContent . spacing
832+ ) . flatMap ( ( key ) => {
833+ const value =
834+ parsedContent . spacing [ key ] . value ;
835+ const result = [ ] ;
836+
837+ // Helper to capitalize axis/side and append to token name
838+ const capitalize = ( str ) =>
839+ str . charAt ( 0 ) . toUpperCase ( ) +
840+ str . slice ( 1 ) ;
841+
842+ // Push all breakpoints for a given axis or side
843+ const pushBreakpoints = (
844+ axisOrSide ,
845+ breakpoints
846+ ) => {
847+ Object . keys ( breakpoints ) . forEach (
848+ ( breakpoint ) => {
849+ // Figma-friendly name: append axis/side
850+ const figmaName = axisOrSide
851+ ? `${ key } ${ capitalize ( axisOrSide ) } `
852+ : key ;
853+
854+ result . push ( {
855+ name : `spacing/${ breakpoint } /${ figmaName } ` ,
856+ value : Number (
857+ breakpoints [ breakpoint ]
858+ ) ,
859+ } ) ;
860+ }
861+ ) ;
862+ } ;
863+
864+ // CASE 1 — scalar (all sides / gap)
865+ if (
866+ typeof value === "object" &&
867+ value !== null &&
868+ ! ( "x" in value ) &&
869+ ! ( "y" in value ) &&
870+ ! ( "top" in value )
871+ ) {
872+ pushBreakpoints ( null , value ) ;
873+ return result ;
874+ }
875+
876+ // CASE 2 — axis-based (x / y)
877+ if ( "x" in value || "y" in value ) {
878+ if ( value . x )
879+ pushBreakpoints ( "x" , value . x ) ;
880+ if ( value . y )
881+ pushBreakpoints ( "y" , value . y ) ;
882+ return result ;
883+ }
884+
885+ // CASE 3 — side-based (top / right / bottom / left)
886+ [ "top" , "right" , "bottom" , "left" ] . forEach (
887+ ( side ) => {
888+ if ( value [ side ] )
889+ pushBreakpoints ( side , value [ side ] ) ;
890+ }
891+ ) ;
892+
893+ return result ;
894+ } ) ;
895+
763896 const themeVariantArray = Object . keys (
764897 parsedContent . themeVariant
765898 ) . map ( ( key ) => ( {
@@ -773,7 +906,8 @@ export const extractMiddlewareJsonData = (
773906 ) . map ( ( key ) => ( {
774907 name : `componentProperties/${ key } ` ,
775908 value :
776- parsedContent . componentProperties [ key ] . value ,
909+ parsedContent . componentProperties [ key ]
910+ . value ,
777911 } ) ) ;
778912
779913 // Accumulate results
@@ -793,8 +927,10 @@ export const extractMiddlewareJsonData = (
793927 fontWeight : fontWeightArray ,
794928 fontSize : fontSizeArray ,
795929 lineHeight : lineHeightArray ,
930+ spacing : spacingArray ,
796931 themeVariant : themeVariantArray ,
797- componentProperties : componentPropertiesArray ,
932+ componentProperties :
933+ componentPropertiesArray ,
798934 } ;
799935
800936 return accumulator ;
0 commit comments