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

Make requirements for text offset props more precise #8418

Merged
merged 2 commits into from
Jul 5, 2019

Conversation

dereklieu
Copy link
Contributor

@dereklieu dereklieu commented Jul 1, 2019

This PR partially addresses #8410.

  • Adds text-field requirement to text-radial-offset and text-variable-anchor.
  • Adds !: text-variable-anchor requirement to text-offset.
  • Merges a duplicate requires field on text-anchor.

cc @mapbox/studio

Copy link
Contributor

@asheemmamoowala asheemmamoowala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dereklieu Thanks for this PR!

Based on your changes, text-variable-anchor will now be documented as:
Screen Shot 2019-07-01 at 2 02 39 PM
And text-anchor as:
Screen Shot 2019-07-01 at 2 02 46 PM

The docs should be clear as to which of these properties will take precedence and be applied in the event that both are present. In symbol_layout.js text-variable-anchor is given precedence if found on the layer style.

@dereklieu
Copy link
Contributor Author

@asheemmamoowala that's a great point. Is precedence of one property over another something that is the responsibility of the style spec to communicate? If not, what are next steps to making sure the docs reflect this?

@andrewharvey
Copy link
Collaborator

@dereklieu

If your PR affects documentation relevant to the currently released version, please use publisher-production as the base branch. See https://github.com/mapbox/mapbox-gl-js/blob/master/docs/README.md#committing-and-publishing-documentation

Should this PR target publisher-production or does it relate to changes only in master, not yet part of a release?

@mourner
Copy link
Member

mourner commented Jul 2, 2019

@andrewharvey in this case, I think we should target master because the main purpose is to propagate the constraints to Studio, which will happen through a new release of mapbox-gl-style-spec. The docs will catch up as a part of the next release (since it's not urgent to update them).

@dereklieu
Copy link
Contributor Author

Yep, that is indeed the goal. Let me know what else I can contribute here. Thanks for the feedback so far.

@asheemmamoowala
Copy link
Contributor

Is precedence of one property over another something that is the responsibility of the style spec to communicate?

It is, in that the spec is converted automatically into documentation. There are a couple ways we can go about this:

  • undo the Adds !:text-variable-anchor requirement to text-offset. portion of this PR. This is what is done in the case of *-color/*-pattern properties where that pattern property takes precedence.
  • keep the change, and let the docs be ambiguous about which takes priority when both are present
  • Update the spec to use a new way to specify when a property disables another, i.e takes precedence in the priority. This would also require updating the documentation generation.

I suggest going with the first options to keep the docs consistent, and we consider a separate PR for the third option.

@dereklieu
Copy link
Contributor Author

@asheemmamoowala thanks for the recommendation! I think the ambiguity in the docs currently extends to two property pairs:

  • text-offset and text-radial-offset
  • text-anchor and text-variable-anchor

In both cases, the docs tell you one can't be used with the other, but if both are present, GL will make a choice. I agree this choice should be documented.

Screen Shot 2019-07-02 at 12 29 21 PM

In these cases, I think a good way forward is that the overriding property should have fewer requirements. The overriding property can exist in the presence of the secondary property. The secondary property is literally disabled in the presence of the overriding property.

text-anchor: {
  requires: [
    'text-field',
    { !: 'text-variable-anchor }
  ]
},
text-variable-anchor: {
  requires: [
    'text-field',
    { "symbol-placement": [ "point" ]
  ]
},
text-offset: {
  requires: {
    'text-field',
    { !: 'text-radial-offset' },
    { !: 'text-variable-anchor' }
  }
},
text-radial-offset: {
  requires: {
    'text-field'
  }
}

undo the Adds !:text-variable-anchor requirement to text-offset.

I think we should keep this. text-anchor is disabled by text-variable-anchor. However, I think we should relax the requirement of text-variable-anchor, which currently includes ! text-offset, since having a text-offset doesn't stop you from overriding it with a variable anchor.

Let me know if this makes sense to you - if so I will adjust the PR. Thanks again for your help and consideration here!

@asheemmamoowala
Copy link
Contributor

Let me know if this makes sense to you - if so I will adjust the PR. Thanks again for your help and consideration here!

Sounds good to me!

@dereklieu
Copy link
Contributor Author

👍 Those changes are reflected in the last commit.

@chloekraw
Copy link
Contributor

Hi, I realize I’m jumping in late here and I’m not sure of the visual effect that Derek's last commits will have. @dereklieu could you add another screenshot?

I also don’t have a great understanding of how the text of our docs are generated. Is all of the text customizable? I’m wondering if it’s an option to make the overriding explicit for the docs on text-radial-offset? So where Derek’s screenshot in #8418 (comment) says “Disabled by text-offset”, we write “Overrides text-offset”? IMO that’s the clearest way to document this behavior.

@dereklieu
Copy link
Contributor Author

Hey @chloekraw I've attached some screenshots below that show the documentation wording that this would generate.

I agree that the override language clarifies the behavior. However, I believe the Disabled by {property_name} language is automatically generated, and that adding the override means a new property in the style spec and new parsing logic in the documentation generator, which seems beyond the scope of this PR.

An alternative is to include the override language in the doc portion, which is defined in the style spec.

Screen Shot 2019-07-03 at 1 35 59 PM

Screen Shot 2019-07-03 at 1 35 35 PM

Screen Shot 2019-07-03 at 1 35 06 PM

Copy link
Contributor

@chloekraw chloekraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dereklieu, looks good to me!

@mourner mourner merged commit d75dfa8 into master Jul 5, 2019
@mourner mourner deleted the text-field-style-spec-updates branch July 5, 2019 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants