postcss / postcss-color-function

PostCSS plugin to transform W3C CSS color function to more compatible CSS
MIT License
325 stars 31 forks source link

Do not throw exception when a color can't be resolved #4

Closed MoOx closed 7 years ago

MoOx commented 9 years ago

Ref https://github.com/postcss/postcss/issues/177

eviltwin commented 8 years ago

This would be great for when we set preserve: true on postcss-custom-properties (so that we can progressively enhance). Right now postcss-color-function balks on the preserved rule (with var(--my-color)) in it.

Ideally, I'd expect the following code:

:root {
  --my-color: #567cde;
}

.widget {
  background-color: color(var(--my-color) blackness(50%) a(0.9));
}

To get polyfilled to:

:root {
  --my-color: #567cde;
}

.widget {
  background-color: rgba(87, 98, 128, 0.9);
  background-color: color(var(--my-color) blackness(50%) a(0.9));
}

This could be achieved simply by leaving the unprocessable rule alone and carrying on. The first background-color would get generated by postcss-custom-properties and then transformed by postcss-color-function, the second would be generated by postcss-custom-properties and then ignored by postcss-color-function. Then we can have our cake and eat it too :)

MoOx commented 8 years ago

PR welcome :)

MoOx commented 7 years ago

Closed by #35 and #36