feat(css): add classNameSlug option to createCssContext #4834
Openflow-pie wants to merge 1 commit into main from feat/css-class-name-slug· opened 2 days ago
+61−18
flow-pie commented 2 days agoAuthor
Description
Adds an optional classNameSlug function to createCssContext that lets users customize generated CSS
class names instead of the default css-1234567890 format.
Closes #4577
Before: Always generates css-1234567890After: Pass classNameSlug: (hash, label, css) => string to get custom names
Description
Adds an optional
classNameSlugfunction tocreateCssContextthat lets users customize generated CSS class names instead of the defaultcss-1234567890format.Closes #4577
Before: Always generates
css-1234567890After: PassclassNameSlug: (hash, label, css) => stringto get custom namesChanges
src/helper/css/common.ts: exportedClassNameSlugtype, added optionalclassNameSlugparam tocssCommon()src/helper/css/index.ts: addedclassNameSlugoption tocreateCssContext(), exportedClassNameSlugtypesrc/helper/css/index.test.tsx: 4 new tests for custom slug, label extraction, fallback, and default behaviorVerification
API
The function receives:
hash: the defaultcss-1234567890stringlabel: extracted from/* comment */at start of template (may be empty)css: the minified CSS string