Skip to content

Commit ac0fcda

Browse files
Fix generation of prose-headings variant (#264)
* Fix prose-headings variant * Update changelog
1 parent b42c452 commit ac0fcda

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- Fix prose elements `legacy` mode ([#259](https://github.com/tailwindlabs/tailwindcss-typography/pull/259))
1717
- Allow `lead` class to override element styles ([#260](https://github.com/tailwindlabs/tailwindcss-typography/pull/260))
18+
- Fix generation of `prose-headings` variant ([#264](https://github.com/tailwindlabs/tailwindcss-typography/pull/264))
1819

1920
## [0.5.2] - 2022-02-14
2021

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ module.exports = plugin.withOptions(
8989

9090
let options = { className, prefix }
9191

92-
for (let [name, selector = name] of [
93-
['headings', 'h1, h2, h3, h4, th'],
92+
for (let [name, ...selectors] of [
93+
['headings', 'h1', 'h2', 'h3', 'h4', 'th'],
9494
['h1'],
9595
['h2'],
9696
['h3'],
@@ -117,7 +117,13 @@ module.exports = plugin.withOptions(
117117
['hr'],
118118
['lead', '[class~="lead"]'],
119119
]) {
120-
addVariant(`${className}-${name}`, target === 'legacy' ? `& ${selector}` : `& :is(${inWhere(selector, options)})`)
120+
selectors = selectors.length === 0 ? [name] : selectors
121+
122+
let selector = target === 'legacy'
123+
? selectors.map(selector => `& ${selector}`)
124+
: selectors.join(', ')
125+
126+
addVariant(`${className}-${name}`, target === 'legacy' ? selector : `& :is(${inWhere(selector, options)})`)
121127
}
122128

123129
addComponents(

src/index.test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ test('modifiers', async () => {
335335
test('legacy target', async () => {
336336
let config = {
337337
plugins: [typographyPlugin({ target: 'legacy' })],
338-
content: [{ raw: html`<div class="prose prose-h1:text-center"></div>` }],
338+
content: [{ raw: html`<div class="prose prose-h1:text-center prose-headings:text-ellipsis"></div>` }],
339339
theme: {
340340
typography: {
341341
DEFAULT: {
@@ -423,6 +423,21 @@ test('legacy target', async () => {
423423
.prose code::after {
424424
content: '&#96;';
425425
}
426+
.prose-headings\:text-ellipsis h1 {
427+
text-overflow: ellipsis;
428+
}
429+
.prose-headings\:text-ellipsis h2 {
430+
text-overflow: ellipsis;
431+
}
432+
.prose-headings\:text-ellipsis h3 {
433+
text-overflow: ellipsis;
434+
}
435+
.prose-headings\:text-ellipsis h4 {
436+
text-overflow: ellipsis;
437+
}
438+
.prose-headings\:text-ellipsis th {
439+
text-overflow: ellipsis;
440+
}
426441
.prose-h1\:text-center h1 {
427442
text-align: center;
428443
}

0 commit comments

Comments
 (0)