Skip to content

Prefixed Tokens results with extra dash #3

Description

@JoshRosenstein

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions