Skip to content

Commit 1561949

Browse files
committed
Add where-hover mixin
1 parent 179c8c0 commit 1561949

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

src/preset.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ const hoverMixin = {
5454
},
5555
};
5656

57+
const hoverWhereMixin = {
58+
'@media (hover: hover)': {
59+
'&:where(:hover)': {
60+
'@mixin-content': {},
61+
},
62+
},
63+
'@media (hover: none)': {
64+
'&:where(:active)': {
65+
'@mixin-content': {},
66+
},
67+
},
68+
};
69+
5770
const rtlMixin = {
5871
'[dir="rtl"] &': {
5972
'@mixin-content': {},
@@ -134,6 +147,7 @@ module.exports = () => {
134147
'where-light-root': rootColorSchemeMixin('light', 'where'),
135148
'where-dark-root': rootColorSchemeMixin('dark', 'where'),
136149
hover: hoverMixin,
150+
'where-hover': hoverWhereMixin,
137151
rtl: rtlMixin,
138152
ltr: ltrMixin,
139153
'not-rtl': notRtlMixin,

src/tests/__snapshots__/mixin-hover.test.ts.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ exports[`mixin-hover transforms hover mixin correctly 1`] = `
1414
}
1515
"
1616
`;
17+
18+
exports[`mixin-hover transforms where-hover mixin correctly 1`] = `
19+
"
20+
@media (hover: hover) {
21+
.demo:where(:hover) {
22+
color: orange
23+
}
24+
}
25+
@media (hover: none) {
26+
.demo:where(:active) {
27+
color: orange
28+
}
29+
}
30+
"
31+
`;

src/tests/mixin-hover.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ const baseInput = `
88
}
99
`;
1010

11+
const whereInput = `
12+
.demo {
13+
@mixin where-hover {
14+
color: orange;
15+
}
16+
}
17+
`;
18+
1119
describe('mixin-hover', () => {
1220
it('transforms hover mixin correctly', async () => {
1321
const res = await testTransform(baseInput);
1422
expect(res.css).toMatchSnapshot();
1523
});
24+
25+
it('transforms where-hover mixin correctly', async () => {
26+
const res = await testTransform(whereInput);
27+
expect(res.css).toMatchSnapshot();
28+
});
1629
});

0 commit comments

Comments
 (0)