[BUG] string.dart: isColorReference() does not identify color references
freemansoft opened this issue · comments
ℹ️ Info
Version: 0.2.0-alpha
current head of the main branch
💬 Description
Working on loading a set of JSON files instead of a single file. Ran into an issue with color. It uses the same regex used in other places and I think it is incorrect.
I added a print statement in isColorReference
bool get isColorReference {
bool isColor =
!startsWith('{') && RegExp(r'{(.*?)}').firstMatch(this) != null;
print('looking at $this to see if it is a color - $isColor');
return isColor;
}
Example output from this function with my test data. This is attempting to resolve a font size 10xl that is nested a couple deep
fontSize.10xl
--> (fontSize.9xl
andfoundSize.Scale
)
fontSize.9xl
--> (fontSize.base
andfontSize.scale
)
fontSize.base
has a value of16
log trace shows that we don't see colors as colors but we still think 16 is a color outside of the color check and throw an exception when we can't find 16
looking at {color.white} to see if it is a color - false
looking at #ffffff to see if it is a color - false
ResolveTokenException{message: semantic.fontSize.10xl - Originating ResolveTokenException{message: Could not parse color for `16` originating from `semantic.fontSize.base`}}
looking at roundTo({semantic.fontSize.9xl} * {semantic.fontSize.scale}, 0) to see if it is a color - true
looking at roundTo({semantic.fontSize.base} * {semantic.fontSize.scale}^10, 0) to see if it is a color - true
looking at 16 to see if it is a color - false
📜 tokens file you tried to import
I'll put the json file in a PR #4
Closed by PR #4