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

Nested media queries have wrong indentation on first arg #5

Open
420factorauthentication opened this issue Jun 20, 2020 · 1 comment

Comments

@420factorauthentication

Nested media queries have wrong indentation on first arg

Media query arguments should have tab_size * (depth + 1) indentation,
but a nested media query incorrectly indents it's first arg to be tab_size * ((depth * 2) + 1).

Input

/* Works fine on depth 0 */
@media only screen and (min-width: 480px) {
    #box {
        background-color: green;
    }
}

/* But not on nested media queries */
@supports (display: grid) {
    @media only screen and (min-width : 480px) {
        @media (color) and (min-height: 480px) and (max-height : 767px) {
            #box {
                background-color: red;
            }
        }
        @media (color) and (min-height: 768px) and (max-height: 991px) {
            #box {
                background-color: blue;
            }
        }
    }
}

My .csscleanrc file:

{
  "tab_size": 4,
  "tab_char": "space"
}

Actual Output

/* Works fine on depth 0 */

@media 
    only screen
    and (min-width : 480px) {
    #box {
        background-color : green;
    }
}

/* But not on nested media queries */

@supports (display: grid) {
    @media 
            only screen
        and (min-width : 480px) {
        @media 
                    (color)
            and (min-height : 480px)
            and (max-height : 767px) {
            #box {
                background-color : red;
            }
        }
        @media 
                    (color)
            and (min-height : 768px)
            and (max-height : 991px) {
            #box {
                background-color : blue;
            }
        }
    }
}

Expected Output

/* Works fine on depth 0 */

@media 
    only screen
    and (min-width : 480px) {
    #box {
        background-color : green;
    }
}

/* But not on nested media queries */

@supports (display: grid) {
    @media 
        only screen
        and (min-width : 480px) {
        @media 
            (color)
            and (min-height : 480px)
            and (max-height : 767px) {
            #box {
                background-color : red;
            }
        }
        @media 
            (color)
            and (min-height : 768px)
            and (max-height : 991px) {
            #box {
                background-color : blue;
            }
        }
    }
}
@420factorauthentication
Copy link
Author

420factorauthentication commented Jun 20, 2020

After looking at the readme, it seems like the intention is that all arguments should be aligned with the first argument, not indented based on tab size.

However, it seems like the intention of src/main/getValue/modules/mediaQuery.js is to indent all arguments based on tab size. Did you change your intention for the project, but not update the readme?

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

Successfully merging a pull request may close this issue.

1 participant