Skip to content

Commit 01edddf

Browse files
committed
1 parent 770ef8f commit 01edddf

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

.vscode/settings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"node_modules": true,
88
"libs": false,
99
"build": false,
10-
"dist": true,
11-
"resources/eez-framework-amalgamation": true
10+
"dist": true
1211
},
1312
"typescript.reportStyleChecksAsWarnings": false,
1413
"typescript.suggest.autoImports": true,

packages/eez-studio-shared/color.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export function parseColorString(
292292
color = color.trim();
293293

294294
// #RRGGBB or #RGB
295-
if (/^#[0-9a-fA-F]{6}$/.test(color)) {
295+
if (/^#?[0-9a-fA-F]{6}$/.test(color)) {
296296
const v = parseInt(color.slice(1), 16);
297297
return {
298298
r: (v >> 16) & 0xff,
@@ -301,7 +301,7 @@ export function parseColorString(
301301
a: 1
302302
};
303303
}
304-
if (/^#[0-9a-fA-F]{3}$/.test(color)) {
304+
if (/^#?[0-9a-fA-F]{3}$/.test(color)) {
305305
const hex = color.slice(1);
306306
const expanded =
307307
hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
@@ -315,7 +315,7 @@ export function parseColorString(
315315
}
316316

317317
// #RRGGBBAA or #RGBA
318-
if (/^#[0-9a-fA-F]{8}$/.test(color)) {
318+
if (/^#?[0-9a-fA-F]{8}$/.test(color)) {
319319
const v = parseInt(color.slice(1), 16);
320320
return {
321321
r: (v >> 24) & 0xff,
@@ -324,7 +324,7 @@ export function parseColorString(
324324
a: ((v & 0xff) / 255)
325325
};
326326
}
327-
if (/^#[0-9a-fA-F]{4}$/.test(color)) {
327+
if (/^#?[0-9a-fA-F]{4}$/.test(color)) {
328328
const hex = color.slice(1);
329329
const expanded =
330330
hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];

packages/project-editor/features/style/color-format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class ColorFormat {
157157
input = input.trim();
158158

159159
// 1) #RRGGBB or #RGB
160-
if (/^#[0-9a-fA-F]{3,6}$/.test(input)) {
160+
if (/^#?[0-9a-fA-F]{3,6}$/.test(input)) {
161161
cf.formatType = ColorFormatType.HEX_HASH;
162162
const hexPart = input.slice(1);
163163
cf.hexUpperCase = hexPart === hexPart.toUpperCase();

0 commit comments

Comments
 (0)