Skip to content

Commit

Permalink
fix: round color alpha to two decimal numbers
Browse files Browse the repository at this point in the history
* fix: round color alpha to two decimal numbers

* don't return new color
  • Loading branch information
gerdasi committed Dec 14, 2020
1 parent a599f13 commit 6f2a6ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ function handleColor(name, value) {
const color = parseColor(value);
if (color) {
if (value[0] === '#' && value.length === 9) {
return color.rgb().toString();
const alpha = color.alpha().toFixed(2);
return color.rgb().alpha(alpha).toString();
}
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion test/mjml-tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describe('mjml tags', () => {
</tags.MjmlColumn>,
),
).to.equal(
'<mj-column inner-background-color="rgba(255, 255, 255, 0.9333333333333333)" background-color="red"><mj-divider border-color="#fdfdfd" container-background-color="rgb(255,0,0)"></mj-divider><mj-text color="rgba(255,0,0,0.1)">Content</mj-text></mj-column>',
'<mj-column inner-background-color="rgba(255, 255, 255, 0.93)" background-color="red"><mj-divider border-color="#fdfdfd" container-background-color="rgb(255,0,0)"></mj-divider><mj-text color="rgba(255,0,0,0.1)">Content</mj-text></mj-column>',
);
});

Expand Down

0 comments on commit 6f2a6ee

Please sign in to comment.