-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
two new built in functions #1793
Conversation
zero converts 0px, 0em, 0% to only 0. unitonly returns the unit of the number.
Wouldn't it make more sense to improve min/max functions rather then introduce two new functions only to overcome min/max limitations? Either way here's a workaround for your particular use-case w/o introducing new functions:
Or an alternative (less readable) workaround w/o using min/max at all:
|
OK,.... suggest a name for Now the workaround presented by you gives what i expect to get. But the one think I dont want is Professionals use 0 instead of 0px, 0em, 0% etc. If they don't know what is being returned. Amateurs might change the variables, and if 0px or etc. is passed While I have a better idea for
I Personally Think, keeping simple |
Well, let's just wait for other opinions. |
I want the same too, it would make the function more flexible. Anyway, for now
And do specify the tricks in detail. |
Like this for example (it is actually possible to optimize the whole |
What exactly is being proposed here? I don't understand this. |
Improved built in
On my side and opinion, I would like all the 3 functions merged. But @seven-phases-max , your decision will be my order. |
Better error handling, now max(0, -2px) returns 0 ... etc.
Better error handling, now max(0, -2px) returns 0 ... etc.
min file has not been updated. |
@deviprsd21 Also note that I do not make any decisions (for instance to merge something or not), I try to actively participate by expressing opinions and thoughts but I prefer to leave the actual decision to be made by other LESS team members (for multiple reasons). P.S. Speaking of your code changes: note that the changes are to be made in less/lib files, that's where the compiler code is (see https://github.com/less/less.js/blob/master/CONTRIBUTING.md#pull-requests). |
closing this for, adding PR's properly. |
One more thing @seven-phases-max, i'm much of a intermediate to grunt. How to invoke and submit my test files. |
For tests you just edit (or create new) files in less/test. For running tests using grunt see https://github.com/less/less.js/blob/master/README.md#contributing |
@deviprsd21 |
Ok, so ill remove ... the errors handlers. But, max and min are not yet supported by any browser. Till then, LESS has to support it. |
@extemporalgenome max and min are not yet supported by any browser. Till then LESS should do it. So, according to me, since LESS doesn't support the conversion of px to em or % or absolute lengths so i'll keep the error handlers intact. Whenever max and min have been supported.I'll be the person to revert them back the original design. |
Named
zero
andunitonly
.zero :
It takes a dimensional value (2px, 56%, 7em, ...) as parameter and
truncates 0unit to only 0 while rest values remain unaltered.
Example: zero(0em) // 0 | zero(2px) // 2px | zero(5%) // 5% | zero(0%) // 0
unitonly :
It takes a dimensional value (2px, 56%, 7em, ...) as parameter and
returns the unit of the value passed.
Example: unitonly(2px) // px | unitonly(2em) // em | unitonly(2%) // %