mikaelvesavuori / figmagic

Figmagic is the missing piece between DevOps and design: Generate design tokens, export graphics, and extract design token-driven React components from your Figma documents.
https://docs.figmagic.com
MIT License
807 stars 71 forks source link

Writing Figma graphics as elements errors out if their name has special characters #112

Closed vilanz closed 2 years ago

vilanz commented 2 years ago

Describe the bug If a graphic is named like action / reorder (instead of just ActionReorder), the code for writing graphics ignores the special characters like /.

But the code for writing elements doesn't ignore them. It tries to read from {outputFolderGraphics}/Action/Reorder.svg and finds nothing - which later on will throw a No data passed to cleanSvgData() afterwards.

I know I can ask the designer to fix the names, but we've got 234 icons... Currently we're manually creating the React components from SVGs anyway, introducing elements would be a plus.

To Reproduce

  1. Have a Figma graphic named file / upload
  2. Make Figmagic process it as a element
    "syncGraphics": true,
    "outputFolderGraphics": "src/Icons/svgs",
    "outputGraphicElements": true,
    "syncElements": true,
    "outputFolderElements": "src/Icons/elements",
    "outputFormatElements": "tsx",
  3. An No data passed to cleanSvgData() error will occur

Expected behavior Special characters are ignored when writing elements and everything goes well.

Extra info:

mikaelvesavuori commented 2 years ago

Hi! Thanks for opening this.

I will need to investigate (and potentially clean this). The behavior is known and it may be non-trivial to support because of slashes being formed as a file path (meaning they end up as nested folders instead of as actual characters). Potentially an easy fix, potentially not.

mikaelvesavuori commented 2 years ago

I am trying to push out 4.3.5 now which should fix this.

There was previously no support whatsoever for nested names on graphics or components (such as Buttons/Edit/OK). This is added in the mentioned release.

Since this is the first release supporting that functionality, it may exhibit unknown behaviours.

Please note that "special characters" do not get any specific handling at all (thus implicitly they are supported). The exception was of course the forward slash (/) which is now supported.