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

postcss-calc cannot parse objects/_scrollable-pane.scss (moj-frontend v1.6.1) #433

Closed
1 task done
ivanELEC opened this issue Jan 9, 2023 · 8 comments
Closed
1 task done

Comments

@ivanELEC
Copy link

ivanELEC commented Jan 9, 2023

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Reproduced the problem
    • Followed all applicable steps in the debugging guide
    • Checked the FAQs on the message board for common solutions
    • Checked that your issue doesn't exist: https://github.com/ministryofjustice/moj-frontend/issues
    • Checked that there is not already a package that provides the described functionality

Description

I am trying to update @ministryofjustice/moj-frontend to v1.6.3 in my Ruby-on-Rails project.
When installing and compiling assets for this project, the following command is run:
bundle exec rails assets:precompile

When this command is run, postcss-calc, a dependency that reduces calculations in css etc files, has the following error:
JisonLexerError: Lexical error on line 1: Unrecognized text.

This is a current issue in postcss-calc which has been open for about a year, but it doesn't look like there's any activity on it

I have found that the following changes to src/moj/objects/_scrollable-pane.scss:

.moj-scrollable-pane {
  $scrollableBgColor: white;
  $scrollableTransparentColor: rgba(255, 255, 255, 0);
  $scrollableShadowColor: rgba(0, 0, 0, 0.2);
  $scrollableShadowSize: 0.75em;

  overflow-x: scroll;
  background: linear-gradient(
      to right,
      $scrollableBgColor,
      $scrollableBgColor,
      $scrollableTransparentColor calc(var($scrollableShadowSize) * 2) //changed line
    ),
    radial-gradient(
      farthest-side at 0 50%,
      $scrollableShadowColor,
      $scrollableTransparentColor
    ),
    linear-gradient(
      to left,
      $scrollableBgColor,
      $scrollableBgColor,
      $scrollableTransparentColor calc(var($scrollableShadowSize) * 2) //changed line
    ),
    radial-gradient(
        farthest-side at 100% 50%,
        $scrollableShadowColor,
        $scrollableTransparentColor
      )
      100%;
  background-color: $scrollableBgColor;
  background-repeat: no-repeat;
  background-attachment: local, scroll, local, scroll;
  background-size: 100% 100%, $scrollableShadowSize 100%, 100% 100%,
    $scrollableShadowSize 100%;
}

@include govuk-media-query($until: 1020px) {
  .moj-scrollable-pane .govuk-table__header,
  .moj-scrollable-pane .govuk-table__cell {
    white-space: nowrap;
  }
}

Steps to Reproduce

  1. Include @ministryofjustice/moj-frontend in a rails project
  2. Run bundle exec rails assets:precompile

Expected behaviour: Packages successfully install
Actual behaviour: Parser error occurs

Reproduces how often: Always

Versions

From v1.6.1

Additional Information

Note the 2 lines that were changed were originally:
$scrollableTransparentColor calc($scrollableShadowSize * 2)

@ivanELEC ivanELEC changed the title postcss-calc cannot parse objects/_scrollable-pane.scss (moj-frontend v1.6.3) postcss-calc cannot parse objects/_scrollable-pane.scss (moj-frontend v1.6.1) Jan 9, 2023
gregtyler added a commit that referenced this issue Jan 9, 2023
postcss-calc isn't happy about the `calc()` function without a `var()` (see #433).
This new syntax is compatible and produces the same output in our distributed file.
@gregtyler
Copy link
Contributor

@ivanELEC Thanks for reporting this, I've applied your changes in #425 and confirmed it doesn't affect our dist files, which is good. Could you install that branch (yarn add https://github.com/ministryofjustice/moj-frontend#use-postcss-calc-compatible-syntax) and confirm it fixes the problem for you before I put it out for review/merge?

@ivanELEC
Copy link
Author

ivanELEC commented Jan 9, 2023

sure will give it a shot now

@ivanELEC
Copy link
Author

ivanELEC commented Jan 9, 2023

Getting this error when trying to run that command:
error Can't add "@ministryofjustice/frontend": invalid package version undefined.
I think this could be fixed by adding the version property to the package.json temporarily? Not sure if there's a way I can hotfix the issue locally

@gregtyler
Copy link
Contributor

Ah sorry, that was naive on my part. I forgot that what we publish to NPM isn't just the plain GitHub repo. I'll publish it to a personal clone instead.

@gregtyler
Copy link
Contributor

Right, this is a bit weird but you can install my clone under the normal namespace with:

yarn add @ministryofjustice/frontend@npm:@gregtyler/moj-frontend-clone@1.6.4

You should then be able to see the var(...) change in your node_modules and be able to verify that it builds.

We're working on making prereleases better in moj-frontend, so this process has been a good reminder of why 😄

@ivanELEC
Copy link
Author

ivanELEC commented Jan 9, 2023

yeah, I can confirm that works for me - thanks so much. Will look forward to this being added in the next version

@gregtyler
Copy link
Contributor

Amazing, I'll get that in and released ASAP

gregtyler added a commit that referenced this issue Jan 9, 2023
postcss-calc isn't happy about the `calc()` function without a `var()` (see #433).
This new syntax is compatible and produces the same output in our distributed file.
gregtyler pushed a commit that referenced this issue Jan 9, 2023
## [1.6.4](v1.6.3...v1.6.4) (2023-01-09)

### Bug Fixes

* use syntax compatible with postcss-calc ([#435](#435)) ([3f21884](3f21884)), closes [#433](#433)
@gregtyler
Copy link
Contributor

Fixed in 1.6.4 (release upcoming)

gregtyler pushed a commit that referenced this issue Jan 9, 2023
## [1.6.4](v1.6.3...v1.6.4) (2023-01-09)

### Bug Fixes

* use syntax compatible with postcss-calc ([#435](#435)) ([3f21884](3f21884)), closes [#433](#433)
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

2 participants