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 namespacing of text style names #42

Open
asos-dylanslewis opened this issue Jun 13, 2018 · 2 comments
Open

Support namespacing of text style names #42

asos-dylanslewis opened this issue Jun 13, 2018 · 2 comments
Projects
Milestone

Comments

@asos-dylanslewis
Copy link
Contributor

To get around Sketch's strict limitation of one alignment and colour per text style, some Sketch projects are set up with text styles that may look like this:

  • TextStyle1/Left/White
  • TextStyle1/Centre/White
  • TextStyle1/Right/White
  • TextStyle2/Left/White
  • TextStyle2/Centre/White
  • TextStyle2/Right/White

There should be a parameter to treat these namespaced text styles as the same style, so that only TextStyle1 and TextStyle2 would be exported.

The issues that need to be resolved are:

  • Checking that all namespaces styles share the same other variables, e.g. make sure TextStyle1/Left/White has the same point size as TextStyle1/Centre/White.
  • Which identifier to use? There will be multiple identifiers for each style, and between runs of stylesync there may be identifiers added or removed. It's vital that stylesync has a persistent reference to a style's identifier
@asos-dylanslewis
Copy link
Contributor Author

asos-dylanslewis commented Jun 13, 2018

In the current implementation, it's possible for every variable except the identifier to change and for stylesync to handle this well. This means that the identifier is the only source of truth. When running in a mode to support this hack, it's possible that the identifiers could also completely change, so the best solution I can think of so far is:

  • each text style keeps an array of all the identifiers associated with it from the current run
  • the next time the script runs, it tries to find any of those identifiers, and use that to have knowledge of a style name

The case this doesn't handle is that all the identifiers of all the namespaces styles changes between runs, however this is an edge case. Hopefully Sketch starts properly supporting mutable alignment and colours in text styles soon, which will remove the necessity for the original hack.

@dylanslewis dylanslewis added this to the v1.0.4 milestone Jun 16, 2018
@dylanslewis
Copy link
Owner

Since a namespaces style will be formed of multiline styles that will have different colour values, it will not be able to export a colour. Using namespaced styles within Sketch is exactly to get around the issue of having multiple colours and the same name, so this shouldn't be a problem in practise.

@dylanslewis dylanslewis added this to To do in v1.1.0 Jun 16, 2018
@dylanslewis dylanslewis moved this from To do to Doing in v1.1.0 Jun 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v1.1.0
  
Doing
Development

No branches or pull requests

2 participants