Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directives in CSS Not Working #66

Open
bmoellers opened this issue Jun 5, 2020 · 4 comments
Open

Directives in CSS Not Working #66

bmoellers opened this issue Jun 5, 2020 · 4 comments

Comments

@bmoellers
Copy link

bmoellers commented Jun 5, 2020

So I hooked this up in to a next JS implementation. This requires a couple steps but it is definitely building the CSS for both RTL and LTR together. Running I have it able to flip between the two styles based on language but what I am not able to do is keep the check mark as it should.

So we sort of draw the checkmark using some code to use the borders:

  &::after {
    position: absolute;
    top: 5px;
    left: 3px;
    content: none;
    display: flex;
    height: 4px;
    width: 9px;
    border-left: 2px solid;
    border-bottom: 2px solid;
    border-color: blue;
    transform: rotate(-45deg);
  }

But this results in a flipped check mark in the generated CSS.
image

This generates the following CSS:

    .verification-warning form input::after {
      position: absolute;
      top: 5px;
      content: none;
      display: flex;
      height: 4px;
      width: 9px; }
    [dir] .verification-warning form input::after {
      border-bottom: 2px solid;
      border-color: #0072CE; }
    [dir=ltr] .verification-warning form input::after {
  left: 3px;
  border-left: 2px solid;
  transform: rotate(-45deg); }
    [dir=rtl] .verification-warning form input::after {
      right: 3px;
      border-right: 2px solid;
      transform: rotate(45deg); }

So I know that either 1) I want the plug in to leave it alone to see what happens or 2) I want the transform to be transform: rotate(-45deg) scaleX(-1); through testing.

So I tried this:

/* rtl:begin:ignore */
      &::after {
        position: absolute;
        top: 5px;
        left: 3px;
        content: none;
        display: flex;
        height: 4px;
        width: 9px;
        border-left: 2px solid;
        border-bottom: 2px solid;
        border-color: $ps-blue;
        transform: rotate(-45deg);
      }
/* rtl:end:ignore */

Deleted the generated CSS so it would regenerate and it is the same as it was above.

Then I tried this:

      &::after {
        position: absolute;
        top: 5px;
        left: 3px;
        content: none;
        display: flex;
        height: 4px;
        width: 9px;
        border-left: 2px solid;
        border-bottom: 2px solid;
        border-color: $ps-blue;
        transform: rotate(-45deg) /* rtl: rotate(-45deg) scaleX(-1) */;
      }

Still it does not generate any different output.

Am I missing something?

My postcss.config.js file that next.js uses for its webpack is this:

module.exports = {
  plugins: {
    'postcss-flexbugs-fixes': {},
    'postcss-preset-env': {
      autoprefixer: {
        flexbox: 'no-2009',
      },
      stage: 3,
      features: {
        'custom-properties': false,
      },
    },
    'postcss-rtl': {},
  },
};
@bmoellers
Copy link
Author

Just a note added:

    'postcss-rtl': {
      removeComments: false,
    },

And there are no comments in the file as well.

@fabercancio
Copy link

Hi @bmoellers did you try to remove postcss-rtl from the list and check that the comments are not stripped out by another plugin? I tested and the flip is ignored using the directives:

https://runkit.com/embed/vp0al7am9mmj

@brian-gonzalez
Copy link

@bmoellers I know this is late, but I was just dealing with the same problem.

If you're using SASS, you need to use SASS' interpolation syntax, according to the RTLCSS page: https://rtlcss.com/learn/usage-guide/value-directives/#tip

For example:
transform: rotate(-45deg) #{"/* rtl: rotate(-45deg) scaleX(-1) */"};

@taurheim
Copy link

Doing this correctly gets the comment to be parsed but it looks like the comment is also not being stripped? I have removeComments set to true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants