Color is hard to parse. Perhaps expose hexvalue?
Closed this issue · 4 comments
I'd like to do a color comparison but its pretty complicated to do with color being broken up into RGBA values.
artboard.backgroundColor != "#ffffff"
Right now I have to check the values of each component which is no fun.
Here is what I ended up doing:
const backgroundColor = artboard.backgroundColor
if (
backgroundColor.alpha != 1 ||
backgroundColor.blue != 1 ||
backgroundColor.green != 1 ||
backgroundColor.red != 1
) {
utils.report({...})
}
I wholeheartedly agree, but the main consumer of the file format is of course Sketch itself so any changes to what is written to disk has to go via Sketch.
I wonder if there are any npm utils that could make life easier? https://github.com/sindresorhus/rgb-hex
Or perhaps we could consider adding a helper function to the rule utils
object? E.g. convert a Sketch file format color object to hex?
I do like the latter option by adding perhaps some helper functions to the utils
objects so you don't need to rely on another library to work with this common of a component.
That being said, thanks for the reminder about using any other npm color library xD kinda forgot you could also do that.
I'll close this one since I don't think changing the file format in this way is particularly achievable. If you've got an idea to improve the Assistant utils, feel free to open an issue over at https://github.com/sketch-hq/sketch-assistants thanks! 🙂