Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: styled-components/stylis-plugin-rtl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.0.1
Choose a base ref
...
head repository: styled-components/stylis-plugin-rtl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2.0.2
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 10, 2021

  1. Copy the full SHA
    701b1f8 View commit details

Commits on Mar 19, 2021

  1. v2.0.2

    quantizor committed Mar 19, 2021
    Copy the full SHA
    80bd7b5 View commit details
Showing with 33 additions and 3 deletions.
  1. +1 −1 package.json
  2. +1 −1 src/stylis-rtl.js
  3. +31 −1 src/stylis-rtl.test.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylis-plugin-rtl",
"version": "2.0.1",
"version": "2.0.2",
"description": "Fork of stylis-rtl, uses cssjanus under the hood to flip style orientations for RTL",
"main": "dist/stylis-rtl.js",
"types": "types/stylis-rtl.d.ts",
2 changes: 1 addition & 1 deletion src/stylis-rtl.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ function stringifyPreserveComments(element, index, children, callback) {
}

function stylisRTLPlugin(element: Object, index: number, children: Object[], callback: Function): ?string {
if (element.type === KEYFRAMES || (element.type === RULESET && (!element.parent || element.parent.type === MEDIA))) {
if (!element.root) {
const stringified = cssjanus.transform(
stringifyPreserveComments(element, index, children, callback)
);
32 changes: 31 additions & 1 deletion src/stylis-rtl.test.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import { compile, middleware, prefixer, serialize, stringify } from 'stylis';
import stylisRtlPlugin from './stylis-rtl';

const stylis = (css, extraPlugins = []) =>
serialize(compile(css), middleware([stylisRtlPlugin, ...extraPlugins, stringify]));
serialize(compile(css), middleware([...extraPlugins, stylisRtlPlugin, stringify]));

describe('integration test with stylis', () => {
it('flips simple rules', () => {
@@ -74,6 +74,23 @@ describe('integration test with stylis', () => {
);
});

it('flips supports queries', () => {
expect(
stylis(
`@supports (display: flex) {
.a {
padding-left: 5px;
margin-right: 5px;
border-left: 1px solid red;
}
}
`
)
).toMatchInlineSnapshot(
`"@supports (display: flex){.a{padding-right:5px;margin-left:5px;border-right:1px solid red;}}"`
);
});

it('works in tandem with prefixer', () => {
expect(
stylis(
@@ -103,4 +120,17 @@ describe('integration test with stylis', () => {
`)
).toMatchInlineSnapshot(`".cls .nested{color:hotpink;}"`);
});

it("works for nested rules", () => {
expect(
stylis(`
.cls {
margin-right: 32px;
& .first-child {
margin-right: 32px;
}
}
`)
).toMatchInlineSnapshot(`".cls{margin-left:32px;}.cls .first-child{margin-left:32px;}"`);
});
});