Skip to content

Commit 96a7a32

Browse files
Modernize
1 parent 9f47ff7 commit 96a7a32

5 files changed

Lines changed: 49 additions & 65 deletions

File tree

dist/css/style.css

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ body {
8080
overflow: hidden;
8181
}
8282

83+
.button.tooltip {
84+
overflow: visible;
85+
}
86+
8387
.button:hover {
8488
background-color: #171b1f;
8589
}
@@ -450,7 +454,7 @@ span.ripple {
450454
}
451455

452456
.tooltip {
453-
overflow: auto;
457+
position: relative;
454458
}
455459

456460
.tooltip-text {
@@ -472,25 +476,17 @@ span.ripple {
472476
}
473477

474478
.modal {
475-
display: none;
476-
position: fixed;
477-
top: 0;
478-
left: 0;
479-
width: 100%;
480-
height: 100%;
481-
background-color: var(--modal-overlay);
482-
z-index: 1;
483-
}
484-
485-
.modal-content {
486-
position: absolute;
487-
top: 50%;
488-
left: 50%;
489-
transform: translate(-50%, -50%);
490-
background-color: var(--modal-background);
491-
padding: 1.25rem;
479+
border: none;
492480
border-radius: 1rem;
481+
padding: 1.25rem;
482+
background-color: var(--modal-background);
493483
box-shadow: 0rem 0rem 1.875rem var(--modal-shadow);
484+
color: var(--text-color);
485+
max-width: 90vw;
486+
}
487+
488+
.modal::backdrop {
489+
background-color: var(--modal-overlay);
494490
}
495491

496492
.close-btn {

dist/css/style.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/script.js

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,40 @@ function createRipple(event) {
55
const diameter = Math.max(button.clientWidth, button.clientHeight);
66
const radius = diameter / 2;
77

8-
circle.style.width = circle.style.height = `${diameter}px`;
9-
circle.style.left = `${event.offsetX - radius}px`;
10-
circle.style.top = `${event.offsetY - radius}px`;
8+
Object.assign(circle.style, {
9+
width: `${diameter}px`,
10+
height: `${diameter}px`,
11+
left: `${event.offsetX - radius}px`,
12+
top: `${event.offsetY - radius}px`,
13+
});
14+
1115
circle.classList.add("ripple");
1216

13-
const ripple = button.querySelector(".ripple");
14-
if (ripple) ripple.remove();
17+
button.querySelector(".ripple")?.remove();
1518

1619
button.appendChild(circle);
1720
}
1821

19-
const buttons = document.querySelectorAll("button[data-ripple]");
20-
for (const button of buttons) {
21-
if (!button.classList.contains("tooltip")) button.addEventListener("click", createRipple);
22+
for (const button of document.querySelectorAll("button[data-ripple]")) {
23+
if (!button.classList.contains("tooltip")) {
24+
button.addEventListener("click", createRipple);
25+
}
2226
}
2327

24-
const openModalButtons = document.querySelectorAll("button[data-modal]")
25-
for (const button of openModalButtons) {
28+
for (const button of document.querySelectorAll("button[data-modal]")) {
2629
button.addEventListener("click", () => {
27-
const id = button.getAttribute("data-modal");
28-
openModal(id);
29-
30-
document.addEventListener("keydown", (event) => event.key === "Escape" ? closeModal(id) : null);
30+
document.getElementById(button.dataset.modal)?.showModal();
3131
});
3232
}
3333

34-
const closeButtons = document.querySelectorAll(".close-btn");
35-
for (const button of closeButtons) {
34+
for (const button of document.querySelectorAll(".close-btn")) {
3635
button.addEventListener("click", () => {
37-
const id = button.getAttribute("data-modal");
38-
closeModal(id);
39-
40-
document.addEventListener("keydown", (event) => event.key === "Escape" ? closeModal(id) : null);
36+
button.closest("dialog")?.close();
4137
});
4238
}
4339

44-
function closeModal(id) {
45-
const modal = document.getElementById(id);
46-
modal.style.display = "none";
47-
}
48-
49-
function openModal(id) {
50-
const modal = document.getElementById(id);
51-
modal.style.display = "block";
40+
for (const dialog of document.querySelectorAll("dialog.modal")) {
41+
dialog.addEventListener("click", (event) => {
42+
if (event.target === dialog) dialog.close();
43+
});
5244
}

dist/js/script.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)