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

cacl() function invalid in for loop #17

Open
LouisaNikita opened this issue Dec 15, 2016 · 3 comments
Open

cacl() function invalid in for loop #17

LouisaNikita opened this issue Dec 15, 2016 · 3 comments

Comments

@LouisaNikita
Copy link

LouisaNikita commented Dec 15, 2016

calc() function invalid in for loop,but avaliable outside the for loop

`

   @for $i from 2 to 12 {
         &.is-circle$i {
              transform: rotate(calc(360deg / 12 * ($i - 1)));
              &::before {
                  animation-delay: calc(-1.2s + 1.2s / 12 * ($i - 1));
              }
          }
     }

`

@travco
Copy link
Contributor

travco commented Dec 16, 2016

Hey @LouisaNikita, is there any chance you can post the load order of your postcss plugins?

That might help identify the issue, as you (should) be able to do this.

@drewbaker
Copy link

I ran into this error today with a Nuxt site. Works locally, but on Netlifty it errors out at build:

3:09:39 PM: ERR! JisonLexerError: Lexical error on line 1: Unrecognized text.
3:09:39 PM: ERR!
3:09:39 PM: ERR!   Erroneous area:
3:09:39 PM: ERR! 1: $(i) * 40ms
3:09:39 PM: ERR! ^..^
3:09:39 PM: ERR!     at /opt/build/repo/components/PanelMenu.vue:99:21
3:09:39 PM: ERR!     at Object.parseError (/opt/build/repo/node_modules/postcss-calc/dist/parser.js:1200:15)
3:09:39 PM: ERR!     at Object.lexer_parseError [as parseError] (/opt/build/repo/node_modules/postcss-calc/dist/parser.js:2333:44)

Because of this code:

            /* Stagger animate menu items */
            @for $i from 1 to 50 {
                .menu-item:nth-child($(i)) {
                    transition-delay: calc($(i) * 40ms);
                }
            }

Using @nuxt/postcss8, and my plugin order is:

        postcss: {
            plugins: {
                "postcss-for": {},
                "postcss-nested": {},
                "postcss-custom-media": {},
                "postcss-hexrgba": {},
            },
        },

@drewbaker
Copy link

I managed to get a successful deploy by just changing the syntax to this:

            @for $i from 1 to 50 {
                .menu-item:nth-child($(i)) {
                    --index: $(i);
                    transition-delay: calc(var(--index) * 40ms);
                }
            }

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

3 participants