Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

conditional defaults #402

Closed
ansis opened this issue Jan 26, 2016 · 10 comments
Closed

conditional defaults #402

ansis opened this issue Jan 26, 2016 · 10 comments

Comments

@ansis
Copy link
Contributor

ansis commented Jan 26, 2016

In the renderers we already have different default values for -rotation-alignment based on whether symbol-placement is line or point. This isn't specified in the spec, so it doesn't show up in the documentation and it doesn't appear correctly in studio.

I think it could be a good idea to have symbol-avoid-edges also have a different default for line labels.

@jfirebaugh thoughts on how we should/shouldn't do this?

@jfirebaugh
Copy link
Contributor

Yes, if these cases are necessary we should record them in the spec somehow.

@ansis
Copy link
Contributor Author

ansis commented Jan 26, 2016

@lucaswoj you've been working on a lot of style stuff in -js recently. Any ideas on how this should be implemented?

@lucaswoj
Copy link

lucaswoj commented Jan 27, 2016

I foresee us adding a lot of logic to the style spec in the near future. We should embrace the precedent set by filters and use a lisp-ey syntax.

{
    "default": ["if", ["==", "symbol-placement", "line"], "point", "line"]
}

@lucaswoj
Copy link

... hopefully this'll dovetail nicely into future data-driven styling features

@1ec5
Copy link
Contributor

1ec5 commented Sep 20, 2016

#104 (comment) proposes this conditional syntax as an elegant means for supporting token fallbacks via the has operator. This would make it easier to support fallbacks for nonexistent sprites: an exists operator would be far less magical than the special behavior implemented for icon-image in #104 (comment).

@lucaswoj
Copy link

@1ec5 Would the exists operator be specific to sprites?

@1ec5
Copy link
Contributor

1ec5 commented Sep 21, 2016

It would only be meaningful in relation to properties that deal with sprite names (or URLs once we implement #485). Could we define exists to always resolve to false for other properties?

@lucaswoj
Copy link

@1ec5 Would a general icon-exists operator work for the use case you have in mind?

@1ec5
Copy link
Contributor

1ec5 commented Sep 21, 2016

Yes.

@jfirebaugh
Copy link
Contributor

We dealt with this by adding auto enum values for the properties in question, and documenting how they behave.

In general, conditional defaults add complexity to the implementation and the mental model required to author styles. We should try not to add more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants