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

The complex CSS is removed #7291

Closed
rafaucau opened this issue Oct 10, 2022 · 7 comments · Fixed by #7487
Closed

The complex CSS is removed #7291

rafaucau opened this issue Oct 10, 2022 · 7 comments · Fixed by #7487
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes. Upstream Bug Requires an upstream change from WordPress, Gutenberg, or another dependency.
Milestone

Comments

@rafaucau
Copy link

Bug Description

I have such CSS and it works fine on the standard version of the site:

:where(.container) {
   width: min(var(--container-max-width), 100% - calc(var(--container-padding) * 2));
   margin-inline: auto;
}

However, when I display the AMP version of the page, it is broken because there is only such CSS left in the .container class:

:where(.container) {
   margin-inline: auto;
}

I don't even see in the file preview that it was removed, so it's probably some kind of bug:
image
image

Expected Behaviour

It shouldn't be removed.

Screenshots

No response

PHP Version

8.1

Plugin Version

2.3.0

AMP plugin template mode

Transitional

WordPress Version

6.0.2

Site Health

No response

Gutenberg Version

No response

OS(s) Affected

All

Browser(s) Affected

All

Device(s) Affected

All

Acceptance Criteria

No response

Implementation Brief

No response

QA Testing Instructions

No response

Demo

No response

Changelog Entry

No response

@rafaucau rafaucau added the Bug Something isn't working label Oct 10, 2022
@thelovekesh
Copy link
Collaborator

I believe the problem arises from 100% - calc(var(—container-padding)* 2) which the parser is unsure how to handle, but browsers are fairly intelligent and automatically display the desired results.

It should be possible for the parser to parse it as intended if you make it a little more precise.

:where(.container) {
-  width: min(var(--container-max-width), 100% - calc(var(--container-padding) * 2));
+  width: min(var(--container-max-width), calc(100% - calc(var(--container-padding) * 2)));
   margin-inline: auto;
}

@rafaucau
Copy link
Author

rafaucau commented Oct 13, 2022

Thanks, it helped! I'm using SCSS and had to additionally wrap it in #{' '} because the Sass compiler simplifies some things.

:where(.container) {
   width: #{'min(var(--container-max-width), calc(100% - calc(var(--container-padding) * 2)))'};
   margin-inline: auto;
}

I think this should be fixed in this plugin anyway, since the Sass compiler turns it into a shorter version by default and this is valid CSS.

@westonruter
Copy link
Member

@rafaucau This would be something needing to be fixed in the underlying PHP-CSS-Parser package. Could you report the issue there instead?

@rafaucau
Copy link
Author

rafaucau commented Oct 13, 2022

It appears that it is already reported there: MyIntervals/PHP-CSS-Parser#388

@westonruter westonruter added the Upstream Bug Requires an upstream change from WordPress, Gutenberg, or another dependency. label Oct 13, 2022
@westonruter westonruter closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2022
@westonruter
Copy link
Member

Also just raised again in the support forum. I think we'll have to work up a workaround to get around this limitation of php-css-parser.

@westonruter westonruter reopened this Mar 10, 2023
@westonruter westonruter self-assigned this Mar 10, 2023
@westonruter westonruter added Upstream Bug Requires an upstream change from WordPress, Gutenberg, or another dependency. and removed Upstream Bug Requires an upstream change from WordPress, Gutenberg, or another dependency. labels Mar 10, 2023
@westonruter westonruter added this to the v2.4.1 milestone Mar 15, 2023
@westonruter
Copy link
Member

Before:

Screenshot 2023-03-17 10 32 13

After:

Screenshot 2023-03-17 10 32 43

In terms of the CSS change before/after, the following complex CSS values are preserved:

669a670,672
>     --wp--preset--font-size--small: clamp(.875rem, .875rem + ((1vw - .48rem) * .24), 1rem);
>     --wp--preset--font-size--medium: clamp(1rem, 1rem + ((1vw - .48rem) * .24), 1.125rem);
>     --wp--preset--font-size--large: clamp(1.75rem, 1.75rem + ((1vw - .48rem) * .24), 1.875rem);
670a674
>     --wp--preset--font-size--xx-large: clamp(4rem, 4rem + ((1vw - .48rem) * 11.538), 10rem);
676a681
>     --wp--preset--spacing--40: clamp(1.8rem, 1.8rem + ((1vw - .48rem) * 2.885), 3rem);
678a684
>     --wp--preset--spacing--70: clamp(5rem, 5.25rem + ((1vw - .48rem) * 9.096), 8rem);
801a808
>     font-size: clamp(2.719rem, 2.719rem + ((1vw - .48rem) * 1.742), 3.625rem);

@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Mar 22, 2023
@westonruter
Copy link
Member

This is now released on the WordPress.org Plugin Directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Changelogged Whether the issue/PR has been added to release notes. Upstream Bug Requires an upstream change from WordPress, Gutenberg, or another dependency.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants