kristoferjoseph / postcss-modular-scale

PostCSS plugin for adding modular scale to your styles
MIT License
53 stars 9 forks source link

Cannot use the result of modular scale as a negative measure #16

Closed wc-matteo closed 8 years ago

wc-matteo commented 8 years ago

Input

margin: 0 -ms(1)rem;

Output

margin: 0 1rem;

Expected

margin: 0 -1rem;


Even worse:

Input

margin: 0 -ms(1)rem -ms(1)rem;

Output

margin: 0 -ms(1;

Expected

margin: 0 -1rem -1rem;

kristoferjoseph commented 8 years ago

these are two issues in one.

  1. ms currently does not support short hand ( on purpose ) but I have been considering adding support because this issue gets filed a bit.
  2. there is not a way to negate a scale step currently. A work around would be to add the step you want as a negative value in the scale itself. ms is naive in that it solely looks up a scale value and appends the unit to it. adding a - to the beginning of a function name is actually renaming the function to call. margin: -ms(1)rem is equivalent to saying margin: hamsandwich-ms(1)rem
wc-matteo commented 8 years ago

Thank you for your answer.

A work around would be to add the step you want as a negative value in the scale itself.

And how would I do that? Currently, I'm binding the scale to some CSS vars (i.e. --ms1, --ms2, etc.).

I don't get the 'rename function to call with -' bit...

First, is it so according to the CSS spec or PostCSS? And second, are you saying that the character - and every character before it is effectively ignored from the parser when determining a function name? If so, what's the point?

Anyway, the PostcSS processor for var() supports the minus in front of it just fine.

I think this issue is an important one to solve; consequently, it should stay open.

Just as an example: when using columns with padding and box-sizing: border-box, you'll usually want to apply a negative margin equal to column padding to the container.


As an aside, I read that you were against a default unit for ms(). I found that rem is the default though; what made you change your mind?