Skip to content

Commit ddaf60c

Browse files
adamwathanreininkmathieutu
authored
Support "undoing" prose styles (#205)
* Add `.not-prose` class * Respect `className` option when adding `not-prose` to selectors Co-authored-by: Jonathan Reinink <[email protected]> Co-authored-by: Mathieu TUDISCO <[email protected]>
1 parent 19cc584 commit ddaf60c

File tree

2 files changed

+17035
-9199
lines changed

2 files changed

+17035
-9199
lines changed

Diff for: src/index.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ const computed = {
1010
// bulletColor: (color) => ({ 'ul > li::before': { backgroundColor: color } }),
1111
}
1212

13-
function inWhere(selector) {
13+
function inWhere(selector, className) {
1414
if (selector.endsWith('::before')) {
15-
return `:where(${selector.slice(0, -8)})::before`
15+
return `:where(${selector.slice(0, -8)}):not(:where(.not-${className} *))::before`
1616
}
1717

1818
if (selector.endsWith('::after')) {
19-
return `:where(${selector.slice(0, -7)})::after`
19+
return `:where(${selector.slice(0, -7)}):not(:where(.not-${className} *))::after`
2020
}
2121

22-
return `:where(${selector})`
22+
return `:where(${selector}):not(:where(.not-${className} *))`
2323
}
2424

25-
function configToCss(config = {}, target) {
25+
function configToCss(config = {}, { target, className }) {
2626
return Object.fromEntries(
2727
Object.entries(
2828
merge(
@@ -38,7 +38,7 @@ function configToCss(config = {}, target) {
3838
}
3939

4040
if (typeof v == 'object' && v.constructor == Object) {
41-
return [inWhere(k), v]
41+
return [inWhere(k, className), v]
4242
}
4343

4444
return [k, v]
@@ -74,7 +74,7 @@ module.exports = plugin.withOptions(
7474
all.map((modifier) => ({
7575
[modifier === 'DEFAULT' ? `.${className}` : `.${className}-${modifier}`]: configToCss(
7676
config[modifier],
77-
target,
77+
{ target, className },
7878
),
7979
})),
8080
variants('typography')

0 commit comments

Comments
 (0)