Skip to content

Commit b6088e2

Browse files
committed
refator: extract svg
1 parent 01e561f commit b6088e2

4 files changed

Lines changed: 18 additions & 17 deletions

File tree

icons/barcode.svg

Lines changed: 1 addition & 0 deletions
Loading

icons/chevron-right.svg

Lines changed: 1 addition & 0 deletions
Loading

popup/pola.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ body {
9898
}
9999

100100
#multiple-ul button:hover .code-chevron {
101-
color: var(--pola-red);
101+
background-color: var(--pola-red);
102102
}
103103

104104
.code-icon {
105105
width: 18px;
106106
height: 18px;
107107
flex-shrink: 0;
108-
color: var(--pola-red);
108+
background-color: var(--pola-red);
109+
-webkit-mask: url(../icons/barcode.svg) no-repeat center / contain;
110+
mask: url(../icons/barcode.svg) no-repeat center / contain;
109111
}
110112

111113
.code-value {
@@ -119,7 +121,10 @@ body {
119121
width: 16px;
120122
height: 16px;
121123
flex-shrink: 0;
122-
color: var(--pola-inactive);
124+
background-color: var(--pola-inactive);
125+
-webkit-mask: url(../icons/chevron-right.svg) no-repeat center / contain;
126+
mask: url(../icons/chevron-right.svg) no-repeat center / contain;
127+
transition: background-color 0.15s ease;
123128
}
124129

125130
#result-name {

popup/pola.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,14 @@
7272
for (let ean of eans) {
7373
let li = document.createElement('li');
7474
let button = document.createElement('button');
75-
button.innerHTML =
76-
'<svg class="code-icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">' +
77-
'<rect x="2" y="5" width="2" height="14" rx="0.5" />' +
78-
'<rect x="6" y="5" width="1" height="14" rx="0.5" />' +
79-
'<rect x="9" y="5" width="2" height="14" rx="0.5" />' +
80-
'<rect x="13" y="5" width="1" height="14" rx="0.5" />' +
81-
'<rect x="16" y="5" width="1.5" height="14" rx="0.5" />' +
82-
'<rect x="20" y="5" width="2" height="14" rx="0.5" />' +
83-
'</svg>' +
84-
'<span class="code-value"></span>' +
85-
'<svg class="code-chevron" viewBox="0 0 24 24" fill="none" aria-hidden="true">' +
86-
'<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />' +
87-
'</svg>';
88-
button.querySelector('.code-value').textContent = ean;
75+
let icon = document.createElement('span');
76+
icon.className = 'code-icon';
77+
let value = document.createElement('span');
78+
value.className = 'code-value';
79+
value.textContent = ean;
80+
let chevron = document.createElement('span');
81+
chevron.className = 'code-chevron';
82+
button.append(icon, value, chevron);
8983
button.addEventListener('click', this.setEan.bind(this, ean));
9084
li.appendChild(button);
9185
ul.appendChild(li);

0 commit comments

Comments
 (0)