Skip to content

[Bug] : postcss-colormin transforms z-index: 999999 to z-index: #999 #1113

Closed

Description

@mynameisbogdan

Describe the bug
postcss-colormin transforms z-index: 999999 to z-index: #999

To Reproduce

var postcss = require('postcss');
var colormin = require('postcss-colormin');

var css = 'div {z-index: 999999} div {z-index: 9999999}';
console.log(postcss(colormin()).process(css).css);

Expected behavior
Should not be transformed to a hex

Screenshots
Screenshot 2021-05-20 at 14 25 22

Desktop (please complete the following information):
[email protected]
[email protected]

OS: macOS Mojave 10.14.6
Node: 16.2.0

Activity

  1. evilPaprika commented on May 20, 2021

    @evilPaprika

    I have the same problem. How can I get around this?

  2. daks01 commented on May 20, 2021

    @daks01

    similarly with z-index range from 100 to 999

  3. mynameisbogdan commented on May 20, 2021

    @mynameisbogdan
    Author

    @evilPaprika disable colormin for now.

    Since I'm using css-minimizer-webpack-plugin:

    new CssMinimizerPlugin({
        minimizerOptions: {
            preset: [
                'default',
                {
                    colormin: false,
                },
            ],
        },
    }),
  4. alexander-akait commented on May 20, 2021

    @alexander-akait
    Member

    /cc @ludofischer I think high priority

  5. romainmenke commented on May 20, 2021

    @romainmenke
    Contributor
  6. michaelfaith commented on May 20, 2021

    @michaelfaith

    This is affecting us as well via Angular 12 update. Adding hashes to some of our components' z-index.

  7. added 2 commits that reference this issue on May 20, 2021
    44d9924
    c835ef9
  8. ludofischer commented on May 20, 2021

    @ludofischer
    Collaborator

    As a workaround you can change the z-index from 999 to 99 (or 9999). I believe the issue is that the new color parser we introduced in the release interprets any number that could work as a hex color as a hex color, so any sequence of 3, 4, 6 or 8 digits will get a hex in front or potentially convert to an rgb() value.

  9. added 2 commits that reference this issue on May 20, 2021
    1a0a268
    9684747
  10. enrique-ramirez commented on May 21, 2021

    @enrique-ramirez

    Just to add my two cents: I have an issue where my :root variables are being added the # as well. I store my variables as rgb values like this:

    :root {
    
      /* Colors */
      --colorPageBackground: 255, 255, 255;
      --colorPageBackgroundAlt: 246, 246, 246;
      --colorDarkBackground: 19, 37, 51;
      --colorDarkestBackground: 12, 20, 27;
      --colorHover: 42, 121, 159;
      --colorHoverLink: 90, 170, 208;
      --colorButtonHover: 59, 79, 95;
      --colorFont: 19, 37, 51;
      --colorError: 208, 2, 27;
      --colorFontLighter: 155, 155, 155;
      --colorLightFont: 246, 246, 246;
      --colorLink: 31, 143, 197;
      --colorCTA: 31, 143, 197;
      --colorCTAHover: 90, 170, 208;
      --colorBorder: 201, 201, 201;
      --colorBorderLight: 245, 243, 240;
      --colorBorderLighter: 220, 220, 220;
      --colorBorderDark: 151, 151, 151;
      --colorInputPlaceholder: 102, 102, 103;
      --colorHeart: 223, 77, 63;
      --colorPromise: 132, 161, 139;
      --colorPromoBox: 164, 179, 168;
      --colorPromoBoxAlmost: 228, 103, 65;
      --colorButtonAlt: 223, 77, 63;
      --colorButtonAltHover: 238, 102, 90;
      --colorNoHighlight: 164, 172, 179;
      --colorAccent: 3, 191, 53;
      --colorHoliday: 230, 77, 74;
      --colorHolidayButton: 184, 133, 84;
      --colorButtonSecondary: 209, 213, 217;
      --colorButtonSecondaryHover: 216, 222, 228;
    
      /* Fonts */
      --fontSerif: "adonis-web", serif;
      --fontSansSerif: "urw-geometric", sans-serif;
    
      /* Font styles */
      --fontSpacing: 1.53px;
    
      /* Spacings */
      --elementSpacing: 25px;
      --negativeElementSpacing: -25px;
    
      /* z-indexes */
      --z6000: 6000;
      --z7000: 7000;
      --z8000: 8000;
      --z9000: 9000;
      --z10000: 10000;
    }

    Reason being, it was the only way to use alpha on my colors. (e.g. color: rgba(var(--colorPageBackground), 0.5);)
    This gets converted to the following:

    :root {
    	--colorPageBackground: #255, #255, #255;
    	--colorPageBackgroundAlt: #246, #246, #246;
    	--colorDarkBackground: 19, 37, 51;
    	--colorDarkestBackground: 12, 20, 27;
    	--colorHover: 42, #121, #159;
    	--colorHoverLink: 90, #170, #208;
    	--colorButtonHover: 59, 79, 95;
    	--colorFont: 19, 37, 51;
    	--colorError: #208, 2, 27;
    	--colorFontLighter: #155, #155, #155;
    	--colorLightFont: #246, #246, #246;
    	--colorLink: 31, #143, #197;
    	--colorCTA: 31, #143, #197;
    	--colorCTAHover: 90, #170, #208;
    	--colorBorder: #201, #201, #201;
    	--colorBorderLight: #245, #243, #240;
    	--colorBorderLighter: #220, #220, #220;
    	--colorBorderDark: #151, #151, #151;
    	--colorInputPlaceholder: #102, #102, #103;
    	--colorHeart: #223, 77, 63;
    	--colorPromise: #132, #161, #139;
    	--colorPromoBox: #164, #179, #168;
    	--colorPromoBoxAlmost: #228, #103, 65;
    	--colorButtonAlt: #223, 77, 63;
    	--colorButtonAltHover: #238, #102, 90;
    	--colorNoHighlight: #164, #172, #179;
    	--colorAccent: 3, #191, 53;
    	--colorHoliday: #230, 77, 74;
    	--colorHolidayButton: #184, #133, 84;
    	--colorButtonSecondary: #209, #213, #217;
    	--colorButtonSecondaryHover: #216, #222, #228;
    	--fontSerif: "adonis-web", serif;
    	--fontSansSerif: "urw-geometric", sans-serif;
    	--fontSpacing: 1.53px;
    	--elementSpacing: 25px;
    	--negativeElementSpacing: -25px;
    	--z6000: 6000;
    	--z7000: 7000;
    	--z8000: 8000;
    	--z9000: 9000;
    	--z10000: 10000
    }
  11. yellow1912 commented on Oct 22, 2021

    @yellow1912

    I wonder if this is still an issue, I'm on 5.0.8 and I have issue with tailwindcss, z-50:50 is converted to z-50:5, the trailing 0 is removed.

    NVM, it was due to zindex reduction, I removed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions