Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions __tests__/variantsAtRule.test.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ test('it can generate even variants', () => {
})
})

test('it can generate only-child variants', () => {
const input = `
@variants only {
.banana { color: yellow; }
.chocolate { color: brown; }
}
`

const output = `
.banana { color: yellow; }
.chocolate { color: brown; }
.only\\:banana:only-child { color: yellow; }
.only\\:chocolate:only-child { color: brown; }
`

return run(input).then(result => {
expect(result.css).toMatchCss(output)
expect(result.warnings().length).toBe(0)
})
})

test('it can generate group-hover variants', () => {
const input = `
@variants group-hover {
Expand Down
1 change: 1 addition & 0 deletions src/lib/substituteVariantsAtRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const defaultVariantGenerators = config => ({
last: generatePseudoClassVariant('last-child', 'last'),
odd: generatePseudoClassVariant('nth-child(odd)', 'odd'),
even: generatePseudoClassVariant('nth-child(even)', 'even'),
only: generatePseudoClassVariant('only-child', 'only'),
})

export default function(config, { variantGenerators: pluginVariantGenerators }) {
Expand Down