Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't preserve camel casing in export #197

Open
SteveAtKlover opened this issue Mar 31, 2022 · 7 comments
Open

Doesn't preserve camel casing in export #197

SteveAtKlover opened this issue Mar 31, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@SteveAtKlover
Copy link

I have, for instance, a figma token called brandPrimary, but when it gets exported out to the file, it saves as brandprimary, lowercasing the P. I messed with the casing option and it doesn't do it correctly in any case.

@lukasoppermann
Copy link
Owner

Hey @SteveAtKlover,

can you give me more details?

So you are using the "standard" token format?
And you have set the name conversion option to camelCase but still get the converted version, correct?

@SteveAtKlover
Copy link
Author

@lukasoppermann yeah, i use the standard format, and tried default as well as camel case.

when the file spits out, a figma token that is brandPrimary gets exported as brandprimary.

@lukasoppermann lukasoppermann added the bug Something isn't working label Apr 7, 2022
@lukasoppermann
Copy link
Owner

Hey, you are right and this is a bug.

Currently the code just lowercases everything and merges words where you have spaces and uppercases the first letter.
This does remove already existing camelCase names.

Another issue I ran across is that emojis like 😅 produce an error when camelCasing which breaks the plugin.

Would you be able to send a PR to address the issues?

@SteveAtKlover
Copy link
Author

I can try. What file should I be working in? Thanks.

@lukasoppermann
Copy link
Owner

Awesome, reach out any time if you have questions.

The conversion happens here: https://github.com/lukasoppermann/design-tokens/blob/main/src/utilities/transformName.ts

The module is than used here: https://github.com/lukasoppermann/design-tokens/blob/main/src/utilities/groupByName.ts

I think there are two things:

  1. Fixing the camelCase: https://github.com/lukasoppermann/design-tokens/blob/main/src/utilities/transformName.ts#L10-L20
  2. Changing the guard: https://github.com/lukasoppermann/design-tokens/blob/main/src/utilities/transformName.ts#L1-L8
    here it would probably be better to try to convert, if it fails we should try to return the original and only throw if this fails as well, what do you think?

@cailborg
Copy link

Any update on this issue? Existing camelCase just needs to be passed through

@cailborg
Copy link

#290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants