Giter Club home page Giter Club logo

Comments (6)

jimmy-guo avatar jimmy-guo commented on May 29, 2024 1

Hi @yunusga, I also have a repro of this issue: https://codesandbox.io/s/postcss-forked-vw07gs?file=/src/index.js:102-192.

Input:

@supports(container-type:inline-size) {
  @media(min-width: 300px) {
    color: red;
  }
}

Output:

@supports(container-type:inline-size) {
}
@media (min-width: 300px) {
    color: red
}

Expected output (same as input):

@supports(container-type:inline-size) {
  @media(min-width: 300px) {
    color: red;
  }
}

from postcss-sort-media-queries.

iamskok avatar iamskok commented on May 29, 2024

I can confirm this is an issue. Here is the code example where the sorting logic fails:

@custom-media --breakpoint-sm (min-width: 600px);
@custom-media --hover-check (hover: hover);

.link {
  color: blue;

  @media (--hover-check) {
    &:hover {
      color: red;
    }
  }

  @media (--breakpoint-sm) {
    color: green;

    @media (--hover-check) {
      &:hover {
        color: pink;
      }
    }
  }
}

Which results to:

.link {
  color: blue;
}

@media (min-width: 600px){
  .link {
    color: green
  }

  @media (hover: hover) {
    .link:hover {
      color: pink;
    }
  }
}

@media (hover: hover){
  .link:hover {
    color: red;
  }
  .link:hover {
    color: pink;
  }
}

Instead of:

.link {
  color: blue;
}

@media (hover: hover) {
  .link:hover {
    color: red;
  }
}

@media (min-width: 600px) {
  .link {
    color: green
  }

  @media (hover: hover) {
    .link:hover {
      color: pink;
    }
  }
}

from postcss-sort-media-queries.

yunusga avatar yunusga commented on May 29, 2024

@iamskok need your configuration because i have different result for your example without sorting

@media (min-width: 600px) and (hover: hover)

Result without sorting
.link {
  color: blue;
}

@media (hover: hover) {
  .link:hover {
    color: red;
  }
}

@media (min-width: 600px) {
  .link {
    color: green;
  }
}

@media (min-width: 600px) and (hover: hover) {
  .link:hover {
    color: pink;
  }
}

from postcss-sort-media-queries.

yunusga avatar yunusga commented on May 29, 2024

Hi @jimmy-guo, thanks, yes, that's right, I am aware of this problem, I will add an update soon. I didn't do this functionality because Firefox still doesn't support it https://caniuse.com/css-nesting

from postcss-sort-media-queries.

yunusga avatar yunusga commented on May 29, 2024

Linked issue OlehDutchenko/sort-css-media-queries#24

from postcss-sort-media-queries.

yunusga avatar yunusga commented on May 29, 2024

@iamskok, @jimmy-guo, @pavel-klimov I added quick fix for problem with ejected nested media queries postcss-sort-media-queries/blob/v5.2.0/README.md#only-top-level

from postcss-sort-media-queries.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.