Skip to content

Commit dcfe332

Browse files
committed
Add where rtl mixins
1 parent 908d09c commit dcfe332

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

src/preset.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,30 @@ const notLtrMixin = {
7878
},
7979
};
8080

81+
const rtlWhereMixin = {
82+
':where([dir="rtl"]) &': {
83+
'@mixin-content': {},
84+
},
85+
};
86+
87+
const ltrWhereMixin = {
88+
':where([dir="ltr"]) &': {
89+
'@mixin-content': {},
90+
},
91+
};
92+
93+
const notRtlWhereMixin = {
94+
':where([dir="ltr"]) &': {
95+
'@mixin-content': {},
96+
},
97+
};
98+
99+
const notLtrWhereMixin = {
100+
':where([dir="ltr"]) &': {
101+
'@mixin-content': {},
102+
},
103+
};
104+
81105
const smallerThanMixin = (_mixin: string, breakpoint: string) => ({
82106
[`@media (max-width: ${converters.em(converters.px(breakpoint) - 0.1)})`]: {
83107
'@mixin-content': {},
@@ -114,6 +138,10 @@ module.exports = () => {
114138
ltr: ltrMixin,
115139
'not-rtl': notRtlMixin,
116140
'not-ltr': notLtrMixin,
141+
'where-rtl': rtlWhereMixin,
142+
'where-ltr': ltrWhereMixin,
143+
'where-not-rtl': notRtlWhereMixin,
144+
'where-not-ltr': notLtrWhereMixin,
117145
'smaller-than': smallerThanMixin,
118146
'larger-than': largerThanMixin,
119147
},

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@ exports[`mixin-rtl transforms rtl mixins correctly 1`] = `
1010
}
1111
"
1212
`;
13+
14+
exports[`mixin-rtl transforms where-rtl mixins correctly 1`] = `
15+
"
16+
:where([dir="rtl"]) .demo {
17+
margin-right: 1rem
18+
}
19+
:where([dir="ltr"]) .demo {
20+
margin-left: 1rem
21+
}
22+
"
23+
`;

src/tests/mixin-rtl.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,26 @@ const baseInput = `
1212
}
1313
`;
1414

15+
const whereInput = `
16+
.demo {
17+
@mixin where-rtl {
18+
margin-right: 1rem;
19+
}
20+
21+
@mixin where-not-rtl {
22+
margin-left: 1rem;
23+
}
24+
}
25+
`;
26+
1527
describe('mixin-rtl', () => {
1628
it('transforms rtl mixins correctly', async () => {
1729
const res = await testTransform(baseInput);
1830
expect(res.css).toMatchSnapshot();
1931
});
32+
33+
it('transforms where-rtl mixins correctly', async () => {
34+
const res = await testTransform(whereInput);
35+
expect(res.css).toMatchSnapshot();
36+
});
2037
});

0 commit comments

Comments
 (0)