Skip to content

Commit f87cf80

Browse files
authored
Adjust multiple codes view (#6)
* feat: adjust multiple codes view * refator: extract svg
1 parent 080f1d0 commit f87cf80

5 files changed

Lines changed: 94 additions & 24 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: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,89 @@ 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+
background-color: var(--pola-red);
102+
}
103+
104+
.code-icon {
105+
width: 18px;
106+
height: 18px;
107+
flex-shrink: 0;
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;
111+
}
112+
113+
.code-value {
114+
flex: 1;
115+
min-width: 0;
116+
overflow: hidden;
117+
text-overflow: ellipsis;
118+
}
119+
120+
.code-chevron {
121+
width: 16px;
122+
height: 16px;
123+
flex-shrink: 0;
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;
67128
}
68129

69130
#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: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@
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+
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);
7783
button.addEventListener('click', this.setEan.bind(this, ean));
7884
li.appendChild(button);
7985
ul.appendChild(li);
@@ -83,16 +89,16 @@
8389
if (!url) {
8490
return false;
8591
}
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-
}
92+
try {
93+
const u = new URL(url);
94+
if (u.protocol !== 'http:' && u.protocol !== 'https:') {
95+
return false;
96+
}
97+
const host = u.hostname.toLowerCase();
98+
return host !== 'example.pl' && host !== 'example.com' && !host.endsWith('.example.pl') && !host.endsWith('.example.com');
99+
} catch {
100+
return false;
101+
}
96102
}
97103
restartAnimation(el) {
98104
el.classList.remove('animate');

0 commit comments

Comments
 (0)