connorjs / css-typed

TypeScript declaration generator for CSS files
https://npmjs.com/package/css-typed
MIT License
4 stars 1 forks source link

Camelcase names #1

Closed rdparker closed 10 months ago

rdparker commented 1 year ago

This uses the logic from css-loader that Gastby uses for converting invalid names to camelcase.

I had to first update the glob dependency to the newer ESM version so that I could test it in my environment. I've included that commit in this pull request as well.

With this change processing

.container {
  margin: auto;
  max-width: 500px;
  font-family: sans-serif;
}

.heading {
  color: rebeccapurple;
}
.nav-links {
  display: flex;
  list-style: none;
  padding-left: 0;
}
.nav-link-item {
  padding-right: 2rem;
}
.nav-link-text {
  color: black;
}

produces

// Generated from src/components/layout.module.css by css-typed at 2023-10-07T12:16:44.347Z

export const container: string;
export const heading: string;
export const navLinks: string;
export const navLinkItem: string;
export const navLinkText: string;

instead of the invalid

// Generated from src/components/layout.module.css by css-typed at 2023-10-07T12:16:44.347Z

export const container: string;
export const heading: string;
export const nav-links: string;
export const nav-link-item: string;
export const nav-link-text: string;
connorjs commented 1 year ago

Thanks for opening the pull request! As mentioned in the README, I was interested in supporting this functionality.

  1. Can you update the README? (At the least, remove this from the Future section; at the most, add a section describing the kebab-case handling.)
  2. I think many/enough tools support this conversion (kebab-case to camel case), but it may be worth a disclaimer that this tool doesn't do any conversion (it simply generates types assuming that conversion happens). Related to (1)
  3. I have the repo set to require signed commits, let me know if that causes issues for you, or if you think it does not need that. (I have just switched to signed commits for everything following my reading of GitHub docs.)

Edit: I looked at the current readme, not this PRs. (1) is already done - thanks!

connorjs commented 10 months ago

I have added unit testing and updated dependencies. I’m looking to go through my "future" list and add that functionality now. I will start with this camel case.

connorjs commented 10 months ago

Canceling in favor of https://github.com/connorjs/css-typed/pull/8.