Skip to content

Commit

Permalink
fix: rename classResponsivePrefixSeparator option to responsivePrefix…
Browse files Browse the repository at this point in the history
…ClassSeparator
  • Loading branch information
saneef committed Apr 29, 2024
1 parent 5f4ad43 commit 8d7c803
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ In the previous example, if we provide breakpoints and set `responsiveVariants:
}
```

You can use `classResponsivePrefixSeparator` property (default: `-`) in `options` to change the separator between responsive prefix and class name.
To generate Tailwind style responsive modifiers, set `classResponsivePrefixSeparator: "\\:"`.
You can use `responsivePrefixClassSeparator` property (default: `-`) in `options` to change the separator between responsive prefix and class name.
To generate Tailwind style responsive modifiers, set `responsivePrefixClassSeparator: "\\:"`.
_Beware if you are using purgecss.
Class names with some special character are not considered._
[See note](https://purgecss.com/extractors.html#default-extractor).
Expand Down
8 changes: 4 additions & 4 deletions lib/design-token-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = ({
customProperties = [],
breakpoints = {},
utilityClasses = [],
classResponsivePrefixSeparator = "-",
responsivePrefixClassSeparator = "-",
} = {}) => {
const prefixMap = new Map(
customProperties
Expand Down Expand Up @@ -36,7 +36,7 @@ module.exports = ({
Declaration,
Rule,
AtRule,
classResponsivePrefixSeparator,
responsivePrefixClassSeparator,
result,
});
},
Expand Down Expand Up @@ -74,7 +74,7 @@ function insertUtilityClasses(
atRule,
classObjects,
viewportEntries,
{ AtRule, Rule, Declaration, classResponsivePrefixSeparator, result },
{ AtRule, Rule, Declaration, responsivePrefixClassSeparator, result },
) {
// Insert utility classes
if (
Expand Down Expand Up @@ -112,7 +112,7 @@ function insertUtilityClasses(
Rule,
Declaration,
selector: ({ selectorBase }) =>
`.${mqPrefix}${classResponsivePrefixSeparator}${selectorBase}`,
`.${mqPrefix}${responsivePrefixClassSeparator}${selectorBase}`,
});

return rule;
Expand Down
5 changes: 3 additions & 2 deletions test/utility-classes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ test("Generate viewport variants with colon separated classes", async (t) => {
responsiveVariants: true,
},
],
classResponsivePrefixSeparator: ":",
responsivePrefixClassSeparator: "\\:",
};
const res = await run(input, { tokens, ...options });

t.is(
res.css,
`.text-accent{color:var(--color-accent)}@media (min-width: 320px){.sm:text-accent{color:var(--color-accent)}}@media (min-width: 640px){.md:text-accent{color:var(--color-accent)}}`,
`.text-accent{color:var(--color-accent)}@media (min-width: 320px){.sm\\:text-accent{color:var(--color-accent)}}@media (min-width: 640px){.md\\:text-accent{color:var(--color-accent)}}`,
);
});

0 comments on commit 8d7c803

Please sign in to comment.