Files
Oleg Isonen b9e60e9f7c feat: Keep original case of custom attributes (#3777)
## Description

- [x] name category with Properties & attributes for clarity
- [x] adapt humanizeString from prop/attribute names
- [x] add description to the combobox
- [x] Class Name > Class 
- [x] add validation for custom attributes

## Steps for reproduction

1. click button
4. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-07-23 19:46:59 +02:00

18 lines
465 B
TypeScript

import { noCase } from "change-case";
import { titleCase } from "title-case";
// Initialize the cache with abbreviations that don't follow the title case rules.
const cache: Map<string, string> = new Map([
["id", "ID"],
["url", "URL"],
]);
export const humanizeString = (string: string): string => {
let result = cache.get(string);
if (result === undefined) {
result = titleCase(noCase(string));
cache.set(string, result);
}
return result;
};