@@ -5,18 +5,19 @@ import { TailwindTextBuilder } from "./tailwindTextBuilder";
55import { TailwindDefaultBuilder } from "./tailwindDefaultBuilder" ;
66import { PluginSettings } from "../code" ;
77import { tailwindAutoLayoutProps } from "./builderImpl/tailwindAutoLayout" ;
8+ import { commonSortChildrenWhenInferredAutoLayout } from "../common/commonChildrenOrder" ;
89
9- let globalLocalSettings : PluginSettings ;
10+ let localSettings : PluginSettings ;
1011
1112let previousExecutionCache : { style : string ; text : string } [ ] ;
1213
1314const selfClosingTags = [ "img" ] ;
1415
1516export const tailwindMain = (
1617 sceneNode : Array < SceneNode > ,
17- localSettings : PluginSettings
18+ settings : PluginSettings
1819) : string => {
19- globalLocalSettings = localSettings ;
20+ localSettings = settings ;
2021 previousExecutionCache = [ ] ;
2122
2223 let result = tailwindWidgetGenerator ( sceneNode , localSettings . jsx ) ;
@@ -81,7 +82,7 @@ const tailwindGroup = (node: GroupNode, isJsx: boolean = false): string => {
8182
8283 const vectorIfExists = tailwindVector (
8384 node ,
84- globalLocalSettings . layerName ,
85+ localSettings . layerName ,
8586 "" ,
8687 isJsx
8788 ) ;
@@ -90,12 +91,12 @@ const tailwindGroup = (node: GroupNode, isJsx: boolean = false): string => {
9091 // this needs to be called after CustomNode because widthHeight depends on it
9192 const builder = new TailwindDefaultBuilder (
9293 node ,
93- globalLocalSettings . layerName ,
94+ localSettings . layerName ,
9495 isJsx
9596 )
9697 . blend ( node )
97- . size ( node , globalLocalSettings . optimizeLayout )
98- . position ( node , globalLocalSettings . optimizeLayout ) ;
98+ . size ( node , localSettings . optimizeLayout )
99+ . position ( node , localSettings . optimizeLayout ) ;
99100
100101 if ( builder . attributes || builder . style ) {
101102 const attr = builder . build ( "" ) ;
@@ -111,10 +112,10 @@ const tailwindGroup = (node: GroupNode, isJsx: boolean = false): string => {
111112export const tailwindText = ( node : TextNode , isJsx : boolean ) : string => {
112113 let layoutBuilder = new TailwindTextBuilder (
113114 node ,
114- globalLocalSettings . layerName ,
115+ localSettings . layerName ,
115116 isJsx
116117 )
117- . commonPositionStyles ( node , globalLocalSettings . optimizeLayout )
118+ . commonPositionStyles ( node , localSettings . optimizeLayout )
118119 . textAlign ( node ) ;
119120
120121 const styledHtml = layoutBuilder . getTextSegments ( node . id ) ;
@@ -137,16 +138,19 @@ const tailwindFrame = (
137138 node : FrameNode | InstanceNode | ComponentNode | ComponentSetNode ,
138139 isJsx : boolean
139140) : string => {
140- const childrenStr = tailwindWidgetGenerator ( node . children , isJsx ) ;
141+ const childrenStr = tailwindWidgetGenerator (
142+ commonSortChildrenWhenInferredAutoLayout (
143+ node ,
144+ localSettings . optimizeLayout
145+ ) ,
146+ isJsx
147+ ) ;
141148
142149 if ( node . layoutMode !== "NONE" ) {
143150 const rowColumn = tailwindAutoLayoutProps ( node , node ) ;
144151 return tailwindContainer ( node , childrenStr , rowColumn , isJsx ) ;
145152 } else {
146- if (
147- globalLocalSettings . optimizeLayout &&
148- node . inferredAutoLayout !== null
149- ) {
153+ if ( localSettings . optimizeLayout && node . inferredAutoLayout !== null ) {
150154 const rowColumn = tailwindAutoLayoutProps ( node , node . inferredAutoLayout ) ;
151155 return tailwindContainer ( node , childrenStr , rowColumn , isJsx ) ;
152156 }
@@ -177,12 +181,8 @@ export const tailwindContainer = (
177181 return children ;
178182 }
179183
180- let builder = new TailwindDefaultBuilder (
181- node ,
182- globalLocalSettings . layerName ,
183- isJsx
184- )
185- . commonPositionStyles ( node , globalLocalSettings . optimizeLayout )
184+ let builder = new TailwindDefaultBuilder ( node , localSettings . layerName , isJsx )
185+ . commonPositionStyles ( node , localSettings . optimizeLayout )
186186 . commonShapeStyles ( node ) ;
187187
188188 if ( builder . attributes || additionalAttr ) {
@@ -221,10 +221,10 @@ export const tailwindContainer = (
221221export const tailwindLine = ( node : LineNode , isJsx : boolean ) : string => {
222222 const builder = new TailwindDefaultBuilder (
223223 node ,
224- globalLocalSettings . layerName ,
224+ localSettings . layerName ,
225225 isJsx
226226 )
227- . commonPositionStyles ( node , globalLocalSettings . optimizeLayout )
227+ . commonPositionStyles ( node , localSettings . optimizeLayout )
228228 . commonShapeStyles ( node ) ;
229229
230230 return `\n<div${ builder . build ( ) } ></div>` ;
@@ -234,11 +234,11 @@ export const tailwindSection = (node: SectionNode, isJsx: boolean): string => {
234234 const childrenStr = tailwindWidgetGenerator ( node . children , isJsx ) ;
235235 const builder = new TailwindDefaultBuilder (
236236 node ,
237- globalLocalSettings . layerName ,
237+ localSettings . layerName ,
238238 isJsx
239239 )
240- . size ( node , globalLocalSettings . optimizeLayout )
241- . position ( node , globalLocalSettings . optimizeLayout )
240+ . size ( node , localSettings . optimizeLayout )
241+ . position ( node , localSettings . optimizeLayout )
242242 . customColor ( node . fills , "bg" ) ;
243243
244244 if ( childrenStr ) {
0 commit comments