Skip to content
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

Support more "isdatatype" functions #1549

Closed
Justineo opened this issue Sep 16, 2013 · 9 comments
Closed

Support more "isdatatype" functions #1549

Justineo opened this issue Sep 16, 2013 · 9 comments

Comments

@Justineo
Copy link
Contributor

We've got already quite a few such functions like iscolor, isstring, etc.

I think it's good to add more such kind of functions such as islength, isangle, istime, isposition, isresolution or even something like iscolorstop. This should make writing guardian expressions easier if we want to "overload" mixins.

@lukeapage
Copy link
Member

We have

isunit(15px, px) // true

@Justineo
Copy link
Contributor Author

isdatatype is quite different here. For example, islength equals a bunch of isunit checks and will greatly simplify the type check.

And some isdatatype functions can process more complex arguments such as:

isposition(top left) // true
iscolorstop(red 80%) //true

@lukeapage
Copy link
Member

I can see how this would be useful writing library code

@Justineo
Copy link
Contributor Author

As Less 1.7.0 started to support using ruleset as mixin parameters, I think isruleset should be a necessary type check function now.

@lukeapage
Copy link
Member

Fair point.

@seven-phases-max
Copy link
Member

Could we have one generic function, e.g. is(value, type-identifier), instead of writing a dedicated one every time?

@seven-phases-max
Copy link
Member

Speaking of "composite" CSS types (as opposed to native Less types like ruleset) and functions like isposition or iscolorstop. I don't think it's a good idea to have this in the core, simply because the number of such "composite" types is literally infinite. How about isbackground(radial-gradient(5em circle at top left, yellow, blue), url(a.png) bottom left no-repeat, hsl(12, 34%, 56%) url("metal.jpg") top center / 100% auto no-repeat); // true? :)

I guess the plugins and/or #538 is the solution in this case.

@matthew-dean
Copy link
Member

Could we have one generic function, e.g. is(value, type-identifier), instead of writing a dedicated one every time?

+1 Seems easier to maintain and document.

@stale
Copy link

stale bot commented Nov 14, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 14, 2017
@stale stale bot closed this as completed Nov 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants