@@ -227,32 +227,29 @@ function parseComponent(node: PluginUINodeData): Anatomy {
227227 return anatomy ;
228228}
229229
230- function cleanNodeName ( nodeName : string ) : string {
231- // Remove non-ascii characters
232- return nodeName . replace ( / [ ^ \x20 - \x7F ] / g, "" ) . trim ( ) ;
233- }
234-
235- function isNotContextNode ( nodeName : string , componentName : string ) : boolean {
236- return nodeName . toLowerCase ( ) !== componentName . toLowerCase ( )
230+ function isContextNode ( node : PluginUINodeData , componentName : string ) : boolean {
231+ // Remove non-ascii characters (we tried a convention of decorating template node names)
232+ const nodeName = node . name . replace ( / [ ^ \x20 - \x7F ] / g, "" ) . trim ( ) ;
233+ return node . type === "COMPONENT" || nodeName . toLowerCase ( ) === componentName . toLowerCase ( ) ;
237234}
238235
239236function walkNode ( node : PluginUINodeData , componentName : string , condition : Record < string , string | boolean > | undefined , anatomy : Anatomy ) : void {
240- const nodeName = cleanNodeName ( node . name ) ;
241-
242- if ( nodeName === "Focus indicator" ) {
237+ if ( node . name === "Focus indicator" ) {
243238 // Ignore for now
244239 return ;
245240 }
246241
247- if ( node . type === "INSTANCE" && isNotContextNode ( nodeName , componentName ) ) {
242+ const isContext = isContextNode ( node , componentName ) ;
243+
244+ if ( node . type === "INSTANCE" && ! ( node . config . inline === true || isContext ) ) {
248245 // TODO: This is too simplified, but it addresses many nested component issues for now.
249246 return ;
250247 }
251248
252249 if ( ! node . name . endsWith ( ignoreLayerName ) ) {
253250 // TODO, not only frames, but what?
254- if ( node . type === "FRAME" && isNotContextNode ( nodeName , componentName ) ) {
255- anatomy . parts . add ( nodeName ) ;
251+ if ( node . type === "FRAME" && ! isContext ) {
252+ anatomy . parts . add ( node . name ) ;
256253 }
257254
258255 if ( node . appliedStyleModules . length > 0 || node . appliedDesignTokens . size > 0 ) {
@@ -271,9 +268,9 @@ function walkNode(node: PluginUINodeData, componentName: string, condition: Reco
271268 styleRule . properties . set ( target , tokenRef ) ;
272269 } ) ;
273270
274- if ( isNotContextNode ( nodeName , componentName ) ) {
275- anatomy . parts . add ( nodeName )
276- styleRule . part = nodeName ;
271+ if ( ! isContext ) {
272+ anatomy . parts . add ( node . name )
273+ styleRule . part = node . name ;
277274 }
278275
279276 anatomy . styleRules . add ( styleRule ) ;
0 commit comments