Skip to content

Commit 8bb139f

Browse files
author
hoang.tran12
committed
update UI UX
1 parent 8895e97 commit 8bb139f

File tree

2 files changed

+40
-14
lines changed

2 files changed

+40
-14
lines changed

popup/index.js

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,16 @@ function createScriptButton(script, isFavorite = false) {
269269

270270
// what this? button
271271
if (script.infoLink) {
272-
const infoBtn = document.createElement("i");
273-
infoBtn.className = "fa-regular fa-circle-question";
272+
const infoBtn = document.createElement("div");
273+
infoBtn.innerHTML = `<i class="fa-regular fa-circle-question"></i>`;
274+
infoBtn.className = "more-item";
274275
if (typeof script.infoLink === "string") {
275276
infoBtn.title = t({
276277
en: "View info/demo",
277278
vi: "Xem giới thiệu/demo",
278279
});
280+
infoBtn.setAttribute("data-tooltip", infoBtn.title);
281+
infoBtn.setAttribute("data-flow", "left");
279282
}
280283
infoBtn.onclick = (e) => {
281284
e.stopPropagation();
@@ -288,7 +291,10 @@ function createScriptButton(script, isFavorite = false) {
288291
}
289292

290293
// add to favorite button
291-
const addFavoriteBtn = document.createElement("i");
294+
const addFavoriteBtn = document.createElement("div");
295+
addFavoriteBtn.innerHTML = `<i class="fa-solid fa-star"></i>`;
296+
addFavoriteBtn.className = "more-item";
297+
addFavoriteBtn.setAttribute("data-flow", "left");
292298
updateFavBtn(addFavoriteBtn, isFavorite);
293299
addFavoriteBtn.onclick = (e) => {
294300
e.stopPropagation();
@@ -302,12 +308,15 @@ function createScriptButton(script, isFavorite = false) {
302308
more.appendChild(addFavoriteBtn);
303309

304310
// view source button
305-
const viewSourceBtn = document.createElement("i");
311+
const viewSourceBtn = document.createElement("div");
312+
viewSourceBtn.innerHTML = `<i class="fa-solid fa-code"></i>`;
306313
viewSourceBtn.title = t({
307314
en: "View script source",
308315
vi: "Xem mã nguồn",
309316
});
310-
viewSourceBtn.className = "fa-solid fa-code view-source";
317+
viewSourceBtn.className = "more-item";
318+
viewSourceBtn.setAttribute("data-tooltip", viewSourceBtn.title);
319+
viewSourceBtn.setAttribute("data-flow", "left");
311320
viewSourceBtn.onclick = (e) => {
312321
e.stopPropagation();
313322
e.preventDefault();
@@ -350,9 +359,10 @@ function createScriptButton(script, isFavorite = false) {
350359
}
351360

352361
function updateFavBtn(btn, isFavorite) {
353-
btn.className = isFavorite
354-
? "fa-solid fa-star star active"
355-
: "fa-regular fa-star star";
362+
let i = btn.querySelector("i");
363+
i.classList.toggle("active", isFavorite);
364+
i.classList.toggle("fa-regular", !isFavorite);
365+
i.classList.toggle("fa-solid", isFavorite);
356366
btn.title = isFavorite
357367
? t({
358368
en: "Remove from favorite",
@@ -362,6 +372,7 @@ function updateFavBtn(btn, isFavorite) {
362372
en: "Add to farovite",
363373
vi: "Thêm vào yêu thích",
364374
});
375+
btn.setAttribute("data-tooltip", btn.title);
365376
}
366377

367378
async function updateButtonChecker(script, button, val) {
@@ -455,7 +466,21 @@ function initTooltip() {
455466

456467
function initSettings() {
457468
reloadBtn.onclick = () => {
458-
chrome.runtime.reload();
469+
Swal.fire({
470+
icon: "warning",
471+
title: t({
472+
vi: "Khởi động lại tiện ích?",
473+
en: "Reload extension?",
474+
}),
475+
text: t({
476+
vi: "Các chức năng tự chạy sẽ lỗi => cần tải lại trang web.",
477+
en: "Autorun scripts will be turned off => you have to reload website.",
478+
}),
479+
showCancelButton: true,
480+
confirmButtonText: t({ vi: "Khởi động lại", en: "Reload" }),
481+
}).then((res) => {
482+
if (res.isConfirmed) chrome.runtime.reload();
483+
});
459484
};
460485

461486
settingsBtn.onclick = () => {

popup/styles/default.less

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,25 +317,25 @@ option {
317317
z-index: 3;
318318
border: linear-gradient(rgb(210 213 219) 1px, transparent 1px), linear-gradient(to right, rgb(210 213 219) 1px, rgb(240 241 245) 1px);
319319

320-
.more i {
320+
.more .more-item {
321321
width: auto;
322322
margin-left: 5px;
323323
opacity: 1;
324324
}
325325
}
326326

327327
.more {
328-
i {
328+
.more-item {
329329
opacity: 0;
330-
width: 0;
331330
transition: all .2s;
331+
display: inline-block;
332332

333333
&:hover {
334-
transform: scale(1.8);
334+
transform: scale(1.1);
335335
}
336336
}
337337

338-
i.star.active {
338+
.more-item .active {
339339
color: @color_highlight;
340340
width: auto;
341341
margin-left: 5px;
@@ -634,6 +634,7 @@ option {
634634
background: #333333;
635635
color: @color_tooltip2;
636636
z-index: 100;
637+
pointer-events: none;
637638
}
638639

639640
&:hover {

0 commit comments

Comments
 (0)