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

create PostCSS processor to generate content: … hack properties #32

Open
rodneyrehm opened this issue Dec 23, 2014 · 4 comments
Open

Comments

@rodneyrehm
Copy link
Owner

In a build pipeline this would work very much like Autoprefixer - refactoring CSS after it's gone through SASS/LESS/whatever, adding the missing pieces.

Based on PostCSS a "simple" processor could identify all the rules using viewport units (e.g. width: 50vw;), aggregate them into a content: "viewport-units-buggyfill; width: 50vw;"; property and add them back to the declaration block. The processor should also check for the existence of the content property an issue a warning/error if one were created on generated content.

This would automate turning

.some-selector {
  width: 50vw;
}

into

.some-selector {
  width: 50vw;
  content: "viewport-units-buggyfill; width: 50vw;";
}

thus making viewport units work "immediately" in old Android Stock Browsers (amongst others).

@henryruhs
Copy link
Contributor

👍

1 similar comment
@extractachris
Copy link

👍

@springuper
Copy link

springuper commented Dec 29, 2016

I've created such a postcss plugin today as I also need one. Please take a look and give some suggestions.

https://github.com/springuper/postcss-viewport-units.

How to handle a css rule which already has a content property? Currently my plugin just send out a warning. I think a better way is to append our hack strings and dynamically remove it when hack script runs.

@mieszko4
Copy link

Postcss plugin looks great! I created a sass mixin. Perhaps could be be of someone's use:

@mixin buggyfy($properties) {
  $content: "viewport-units-buggyfill;";
  @each $property, $value in $properties {
    #{$property}: $value;
    $content: "#{$content}#{$property}:#{$value};";
  }
  content: $content;
}

body {
  @include buggyfy((
    width: 50vmin,
    height: 50vmax,
    top: calc(50vh - 100px),
    left: calc(50vw - 100px)
  ));
}

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

No branches or pull requests

5 participants