sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
360 stars 73 forks source link

Clean up units and percentages #124

Closed martin-kolinek closed 8 years ago

martin-kolinek commented 8 years ago

CSS doesn't seem to differentiate between relative and absolute units. It does, however, differentiate between lengths and percentages. I'm basing this on MDN.

The way clay does sizes prevents users from specifying e.g. a border width of 1em. They also could specify opacity of 1em, which shouldn't be possible.

For this reason I replaced Size Rel and Size Abs with Size Percentage and Size LengthUnit. Do you think the naming is good?

I also changed translate to allow usage of percentages for X and Y coordinates.

Also, the changes will not be really backwards comaptible, but the use cases which would work with CSS should also work after this change.

seanparsons commented 8 years ago

Hmmm, I need to have a think on the consequences of breaking compatibility.

martin-kolinek commented 8 years ago

Sure. There is also the option of introducing type classes for the different types of sizes. Then it's possible to keep Size Abs and Size Rel. However, pct would still need its own size type, as it can be used in different contexts as the sizes with other units. If you like this approach better, I can try to come up with something.

Another option would be to untroduce a new pct2 (or something) function with a new size type, but that's quite ugly.

seanparsons commented 8 years ago

You know what, I'm down with this, I'd be surprised if those changes actually affected a lot of people.