segmentio / myth

A CSS preprocessor that acts like a polyfill for future versions of the spec.
4.32k stars 130 forks source link

Act more like a fallback #64

Open MoOx opened 10 years ago

MoOx commented 10 years ago

Edit: let's go for it


What about adding the possibility to keep original sources & just add rules as fallback before the other ? If I take you example on the homepage:

:root {
  --purple: #847AD1;
  --large: 10px;
}

a {
  color: var(--purple);
}
a:hover {
  color: color(var(--purple) tint(20%));
}

pre {
  padding: var(--large);
  margin: calc(var(--large) * 2);
}

should yield into

:root {
  --purple: #847AD1;
  --large: 10px;
}

a {
  color: #847AD1;
  color: var(--purple);
}
a:hover {
  color: rgb(157, 149, 218);
  color: color(var(--purple) tint(20%));
}

pre {
  padding: 10px;
  padding: var(--large);

  margin: 20px;
  margin: calc(var(--large) * 2);
}

but instead give (note that the homepage include :root in the output while it's not here)

a {
  color: #847AD1;
}

a:hover {
  color: rgb(157, 149, 218);
}

pre {
  padding: 10px;
  margin: 20px;
}
ianstormtaylor commented 10 years ago

For those cases I don't think there is a benefit to acting as a fallback? Since the values don't change at runtime in those cases, so it would just be duplicate code?

MoOx commented 10 years ago

It's a bit like having prefixed & non prefixed version. And for example Firefox 31+ already support custom property (so variables too), this will be nice to be able to debug in the inspector using variable name & not "rendered" version. See https://github.com/reworkcss/rework-vars/issues/28

MoOx commented 10 years ago

Here is why I would like to be able to use myth as a fallback (at least during debug ?)

rework-vars & rework-calc have PRs (reworkcss/rework-vars#29 & reworkcss/rework-calc#3) & that hopefully will be merged should soon. @ianstormtaylor are you interested to get a PR for the color part ? I'll be very happy to bring that possibility for this part of myth too.

ianstormtaylor commented 10 years ago

Interesting, yeah I think I'd be down for a pull request. It might be something we want to put behind a flags like fallbacks: true? and keep it off by default since it will increase the output?

MoOx commented 10 years ago

Sure. What about preserve (default to false for now)