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

Prefixed Tokens results with extra dash #3

Open
JoshRosenstein opened this issue Dec 8, 2020 · 2 comments
Open

Prefixed Tokens results with extra dash #3

JoshRosenstein opened this issue Dec 8, 2020 · 2 comments

Comments

@JoshRosenstein
Copy link

If the final key of a token path starts with a symbol, the resulting variable returns a extra dash. This causes inconsistent css variable naming conventions when tokens have different depths.

).replace(cssDisallowedRe, '-')

Not sure if there was a certain reason for replacing special characters with a dash, if there is, would it be an issue if you were to just remove any special character at the beginning of a key?

const cssDisallowedRe = /[^\w-]/g;
const names = ["color", "red"];
const key = "$100";

console.log(names.join("-") + "-" + key.replace(cssDisallowedRe, "-"));
// color-red--100
console.log(
  names.join("-") +
    "-" +
    key.charAt(0).replace(cssDisallowedRe, "") +
    key.slice(1).replace(cssDisallowedRe, "-")
);
// color-red-100
@jaredLunde
Copy link
Member

Thank you for filing! This is a good point. Would you want to submit a PR? Otherwise I can do it tonight.

@JoshRosenstein
Copy link
Author

@jaredLunde Sorry, didn't see your response till today, PR submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants