teleporthq / teleport-code-generators

A collection of code generators for modern JavaScript applications
https://teleporthq.io
MIT License
1k stars 159 forks source link

(fix): Generate jsx and templates for all element props even if not used in components #913

Closed JayaKrishnaNamburu closed 2 months ago

JayaKrishnaNamburu commented 2 months ago

This PR fixes #911 for all the other frameworks like HTML, Vue and Angular I see now the playground is generating fragment as wrapper for these attrs. But fragment is not a valid html element. So, added a mapping. so, in non jsx projects it generates.

<div class="app-custom-fragment">
</div>
.app-custom-fragment {
  display: contents
}

And for jsx, it directly imports from React

PS: It is mandatory not to pass semanticType for fragment nodes. Or else these mappings don't work for react. You need to pass only elementType.

{
  "type": "element",
  "content": {
    "elementType": "fragment",
    "referencedStyles": {},
    "abilities": {},
    "children": [
      {
        "type": "element",
        "content": {
          "elementType": "text",
          "semanticType": "h1",
          "referencedStyles": {},
          "abilities": {},
          "children": [
            {
              "type": "static",
              "content": "Heading"
            }
          ]
        }
      }
    ]
  }
}