Closed RaphyRaph closed 6 years ago
Yeah I've only briefly looked into this, but there was no obvious trivial way to add that at the time. Just to make sure I understand your use case, in what situation(s) does this tend to be an issue? Are they accidental duplicates?
If it's anything like what I've been running into when working on components in individual files, then merging those into our master design system file, here's what I've run into:
Having the ability to remove or merge duplicate styles would be a godsend.
Agreed, that would indeed be pretty handy. So from what I understand, the duplicate styles would often have the same name?
Just asking cause it might be easier to merge styles by the same name, than to reliably compare all their properties. So that's a feature I'd probably be able to get out quicker. I'll look into it :)
@sigtm I'd love this feature as well.
Yes, my duplicate styles typically have the same name.
You might take a look at Sketch Fix Styles for reference. It supported the ability to merge Text Styles with the same name, but it no longer works in Sketch 45+.
There are 2 use cases for duplicate styles:
when there is neither the same name or the same properties, the style should be deleted.
Thanks for the tip @seandellis! That plugin looks easy enough to replicate (famous last words). It assumes the styles you want to merge have identical names and properties, so it just picks a random one to keep and removes the rest.
Otherwise you'd need a comparison step for picking which one to use, which is a bunch more complexity. I'll stick to what I think I can release reasonably quickly, which should cover most use cases anyway.
@RaphyRaph Updating style names that have changed in the source file is a bit trickier, but yeah that's on my radar too. It probably means storing some form of change log to apply the changes next time you pull from that document, since I'm not sure style IDs (which are separate from their names) can be reliably used for matching styles across documents. All in all, a fair few unknowns there so I'll do my best but can't promise anything!
Updating styles by the same name, and deleting styles that don't exist, is already supported :)
That was surprisingly straightforward actually. I'll release the new version in the morning so I'm not asleep if someone immediately finds an unforeseen bug :)
In the meantime, if anyone is feeling adventurous you can already get it on the feature/merge-styles branch:
https://github.com/sigtm/sketch-style-libraries/tree/feature/merge-styles
Shipped!
Just wanted to chime in and thank you for your openness and responsiveness to the community. Killing it! Thank you :)
@sigtm Awesome! Thanks for adding this feature. It's a huge lifesaver.
I use a lot of complex nested styles and was surprised by the number of styles that were merged.
It would be great if the plugin showed a text list of the styles that it's about to merge with the option to Cancel or Merge.
would be great to parse styles by properties and clean/merge them automatically