Skip to content

Commit 0627ac2

Browse files
authored
fix: done #29 (#45)
1 parent 66ef57f commit 0627ac2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/helpers/colorTool.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ const parse = (raw, _format) => {
336336
let error;
337337
let format = _format || 'unknown';
338338
if (raw === 'transparent') {
339-
value = undefined;
340339
color.name = raw;
341340
format = 'plain';
341+
alpha = 0;
342342
} else if (typeof raw === 'string') {
343343
const r = raw.trim().toLocaleLowerCase();
344344
const index = colorsCssConditions.findIndex(func => func(r));
@@ -373,7 +373,7 @@ const parse = (raw, _format) => {
373373
}
374374
if (value === undefined) {
375375
value = 0;
376-
alpha = undefined;
376+
alpha = alpha === 0 ? alpha : undefined;
377377
color.css = {
378378
backgroundImage: `
379379
linear-gradient(45deg, #ccc 25%, transparent 25%),

test/colorTool.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ test('ColorTool parse simple', () => {
193193
test('ColorTool parse css color keywords', () => {
194194
let color = ColorTool.parse('transparent');
195195
expect(color.raw).toEqual('transparent');
196-
expect(color.hex).toEqual('000000');
196+
expect(color.hex).toEqual('00000000');
197197
CSS_COLOR_NAMES.forEach(name => {
198198
color = ColorTool.parse(name);
199199
expect(color.name).toEqual(name);

0 commit comments

Comments
 (0)