Skip to content

Commit f1703c5

Browse files
committed
fix color value shortcuts
1 parent 7b6be9d commit f1703c5

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/value-transformers/color.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,16 @@ export class ColorValueTransformer implements IValueTransformer {
1717
value = `Color.fromARGB(${parseInt(a, 16)}, ${parseInt(r, 16)}, ${parseInt(g, 16)}, ${parseInt(b, 16)})`;
1818
handled = true;
1919
}
20-
else if (!originalValue.startsWith('Colors.') && /^[a-zA-Z0-9\.\s*]+$/ig.test(originalValue)) {
21-
value = `Colors.${originalValue}`;
22-
handled = true;
20+
else if (!originalValue.startsWith('Colors.') &&
21+
!originalValue.startsWith('ctrl.') &&
22+
/^[a-zA-Z0-9\.\s*]+$/ig.test(originalValue) &&
23+
!originalValue.startsWith('widget.')) {
24+
const dotsCount = (originalValue.match(/\./g) || []).length;
25+
if (dotsCount === 1 && (originalValue.indexOf('.shade') > -1 || originalValue.indexOf('.with') > -1 && originalValue.indexOf('(') > -1) ||// e.g. accept red, red.shaded100, red.with*()
26+
dotsCount === 0) {
27+
value = `Colors.${originalValue}`;
28+
handled = true;
29+
}
2330
}
2431
else {
2532
value = originalValue;

0 commit comments

Comments
 (0)