Skip to content

Commit 6650606

Browse files
author
Ivelin Iliev
committed
fix: striping hexa value to hex
1 parent 32dd1bc commit 6650606

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/demo/js/script.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,17 @@ let preview = {
1010
const params = Array.from(document.querySelectorAll(".param")).reduce(
1111
(acc, next) => {
1212
let obj = { ...acc };
13-
obj[next.id] = next.value.replace(/#/g, "").replace(/(F|f){2}$/, "");
13+
let value = next.value;
14+
15+
if (value.indexOf('#') >= 0) {
16+
// if the value is colour, remove the hash sign
17+
value = value.replace(/#/g, "");
18+
if (value.length > 6) {
19+
// if the value is in hexa and opacity is 1, remove FF
20+
value = value.replace(/(F|f){2}$/, "");
21+
}
22+
}
23+
obj[next.id] = value;
1424
return obj;
1525
},
1626
{}

0 commit comments

Comments
 (0)