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

shortnames: Add possibility to set classname characters #778

Open
vladshcherbin opened this issue Aug 1, 2020 · 2 comments
Open

shortnames: Add possibility to set classname characters #778

vladshcherbin opened this issue Aug 1, 2020 · 2 comments

Comments

@vladshcherbin
Copy link

👋 Hey, it would be great if it was possible to set characters, used in shortnames generated classes. For example, I'd prefer them to be only lowercase.

Feature Use Case

namer: shortnames({ letters: [a...z, 0...9] })

// or

namer: shortnames({ case: 'lower' })

Feature Proposal

Add option to set letters used in classes or letter case.

From source code, alphabet package is used inside which already has methods to return only lowercase/uppercase letters.

Btw shortnames is located under packages/namer, wondering why 🤔

@tivac
Copy link
Owner

tivac commented Aug 1, 2020

Btw shortnames is located under packages/namer, wondering why

That's left over from before this was a monorepo, hasn't been important to rename it but wanted to give the package a more-descriptive name on NPM.

I think this would be really easy to add, based on looking at namer.js:

module.exports = () => {

Would need to take an option like shortnames({ identifiers : [ ... ] }), and the default value should be the already-existing everything value from up above.

const everything = [ ...letters, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];

Then it's a matter of using the identifiers param instead of everything whenever value(...) is called.

const output = value(letters, id) + value(everything, selectors.get(selector));

@darthmaim
Copy link

I have a package that generates short strings in a given alphabet: darthmaim/short-string.

I even wrote a package specifically for modular-css: darthmaim/modular-css-short-namer, but this will always use the default alphabet.

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

No branches or pull requests

3 participants