Skip to content

Commit 01e561f

Browse files
committed
feat: adjust multiple codes view
1 parent 5dc3f6b commit 01e561f

3 files changed

Lines changed: 93 additions & 24 deletions

File tree

popup/pola.css

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,84 @@ body {
4242

4343
#multiple {
4444
display: none;
45-
padding-top: 20px;
46-
text-align: center;
47-
font-size: larger;
45+
}
46+
47+
.multiple-heading {
48+
font-size: 20px;
49+
font-weight: bold;
50+
color: var(--pola-text);
51+
margin: 0 0 0.3em;
52+
}
53+
54+
.multiple-subtitle {
55+
font-size: 13px;
56+
font-weight: 600;
57+
color: var(--pola-text);
58+
margin: 0 0 1em;
4859
}
4960

5061
#multiple-ul {
5162
list-style: none;
52-
padding: 0;
63+
padding: 2px;
5364
margin: 0;
54-
width: 100%;
55-
overflow: auto;
56-
max-height: 250px;
65+
overflow-y: auto;
66+
max-height: 290px;
67+
display: flex;
68+
flex-direction: column;
69+
gap: 8px;
70+
}
71+
72+
#multiple-ul li {
73+
margin: 0;
74+
padding: 0;
5775
}
5876

5977
#multiple-ul button {
78+
display: flex;
79+
align-items: center;
80+
gap: 10px;
81+
width: 100%;
82+
padding: 12px 14px;
83+
background: var(--pola-light-gray);
84+
border: none;
85+
border-radius: 12px;
86+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
87+
font-family: inherit;
88+
font-size: 15px;
89+
font-weight: 700;
90+
color: var(--pola-text);
91+
text-align: left;
6092
cursor: pointer;
61-
width: 90%;
62-
padding: 5px;
93+
transition: background 0.15s ease;
6394
}
6495

65-
#multiple-ul li {
66-
padding: 5px;
96+
#multiple-ul button:hover {
97+
background: var(--pola-friend-bg);
98+
}
99+
100+
#multiple-ul button:hover .code-chevron {
101+
color: var(--pola-red);
102+
}
103+
104+
.code-icon {
105+
width: 18px;
106+
height: 18px;
107+
flex-shrink: 0;
108+
color: var(--pola-red);
109+
}
110+
111+
.code-value {
112+
flex: 1;
113+
min-width: 0;
114+
overflow: hidden;
115+
text-overflow: ellipsis;
116+
}
117+
118+
.code-chevron {
119+
width: 16px;
120+
height: 16px;
121+
flex-shrink: 0;
122+
color: var(--pola-inactive);
67123
}
68124

69125
#result-name {

popup/pola.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<div id="loading">Ładowanie...</div>
1212
<div id="null">Nie znaleziono kodu na stronie</div>
1313
<div id="multiple">
14-
Wybierz kod:
14+
<h3 class="multiple-heading">Wybierz kod</h3>
15+
<p class="multiple-subtitle">Na tej stronie znaleźliśmy kilka kodów kreskowych. Wybierz jeden, aby zobaczyć informacje o&nbsp;producencie.</p>
1516
<ul id="multiple-ul">
1617

1718
</ul>

popup/pola.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,20 @@
7272
for (let ean of eans) {
7373
let li = document.createElement('li');
7474
let button = document.createElement('button');
75-
let t = document.createTextNode(ean);
76-
button.appendChild(t);
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;
7789
button.addEventListener('click', this.setEan.bind(this, ean));
7890
li.appendChild(button);
7991
ul.appendChild(li);
@@ -83,16 +95,16 @@
8395
if (!url) {
8496
return false;
8597
}
86-
try {
87-
const u = new URL(url);
88-
if (u.protocol !== 'http:' && u.protocol !== 'https:') {
89-
return false;
90-
}
91-
const host = u.hostname.toLowerCase();
92-
return host !== 'example.pl' && host !== 'example.com' && !host.endsWith('.example.pl') && !host.endsWith('.example.com');
93-
} catch {
94-
return false;
95-
}
98+
try {
99+
const u = new URL(url);
100+
if (u.protocol !== 'http:' && u.protocol !== 'https:') {
101+
return false;
102+
}
103+
const host = u.hostname.toLowerCase();
104+
return host !== 'example.pl' && host !== 'example.com' && !host.endsWith('.example.pl') && !host.endsWith('.example.com');
105+
} catch {
106+
return false;
107+
}
96108
}
97109
restartAnimation(el) {
98110
el.classList.remove('animate');

0 commit comments

Comments
 (0)