new feat übersetzer und faq
This commit is contained in:
@@ -36,5 +36,4 @@
|
||||
<text x="280" y="69" text-anchor="middle" font-size="28" font-family="Arial, sans-serif" fill="#2f5e35">$</text>
|
||||
</g>
|
||||
</g>
|
||||
<text x="480" y="90" text-anchor="middle" font-size="54" font-family="Arial, sans-serif" fill="#f0db8e">Gift Fund</text>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
53
backend/static/faq.js
Normal file
53
backend/static/faq.js
Normal file
@@ -0,0 +1,53 @@
|
||||
(() => {
|
||||
function initFaqItem(item) {
|
||||
const summary = item.querySelector("summary");
|
||||
const answer = item.querySelector(".faq-answer");
|
||||
if (!summary || !answer) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isAnimating = false;
|
||||
|
||||
summary.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
if (isAnimating) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.open) {
|
||||
item.open = true;
|
||||
item.classList.remove("is-closing");
|
||||
item.classList.add("is-opening");
|
||||
const finishOpen = () => {
|
||||
item.classList.remove("is-opening");
|
||||
isAnimating = false;
|
||||
};
|
||||
isAnimating = true;
|
||||
answer.addEventListener("animationend", finishOpen, { once: true });
|
||||
window.setTimeout(
|
||||
finishOpen,
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 360,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
isAnimating = true;
|
||||
item.classList.remove("is-opening");
|
||||
item.classList.add("is-closing");
|
||||
const finishClose = () => {
|
||||
item.classList.remove("is-closing");
|
||||
item.open = false;
|
||||
isAnimating = false;
|
||||
};
|
||||
answer.addEventListener("animationend", finishClose, { once: true });
|
||||
window.setTimeout(
|
||||
finishClose,
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 360,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll(".faq-item").forEach(initFaqItem);
|
||||
});
|
||||
})();
|
||||
81
backend/static/onboarding.js
Normal file
81
backend/static/onboarding.js
Normal file
@@ -0,0 +1,81 @@
|
||||
(() => {
|
||||
function initOnboarding(dialog) {
|
||||
const slides = Array.from(dialog.querySelectorAll("[data-onboarding-slide]"));
|
||||
const dots = Array.from(dialog.querySelectorAll("[data-onboarding-dot]"));
|
||||
const progress = dialog.querySelector("[data-onboarding-progress]");
|
||||
const backButton = dialog.querySelector("[data-onboarding-back]");
|
||||
const nextButton = dialog.querySelector("[data-onboarding-next]");
|
||||
const completeUrl = dialog.dataset.completeUrl;
|
||||
const progressTemplate = dialog.dataset.progressTemplate || "Step {current} of {total}";
|
||||
|
||||
if (!slides.length || !progress || !backButton || !nextButton || !completeUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
let currentIndex = 0;
|
||||
let completionSent = false;
|
||||
|
||||
const markComplete = () => {
|
||||
if (completionSent) {
|
||||
return;
|
||||
}
|
||||
completionSent = true;
|
||||
window.fetch(completeUrl, {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||
keepalive: true,
|
||||
}).catch(() => {
|
||||
completionSent = false;
|
||||
});
|
||||
};
|
||||
|
||||
const finish = () => {
|
||||
markComplete();
|
||||
dialog.close();
|
||||
};
|
||||
|
||||
const render = () => {
|
||||
slides.forEach((slide, index) => {
|
||||
slide.hidden = index !== currentIndex;
|
||||
});
|
||||
dots.forEach((dot, index) => {
|
||||
dot.classList.toggle("is-active", index <= currentIndex);
|
||||
});
|
||||
progress.textContent = progressTemplate
|
||||
.replace("{current}", String(currentIndex + 1))
|
||||
.replace("{total}", String(slides.length));
|
||||
backButton.hidden = currentIndex === 0;
|
||||
const isLast = currentIndex === slides.length - 1;
|
||||
nextButton.textContent = isLast ? nextButton.dataset.finishLabel : nextButton.dataset.nextLabel;
|
||||
};
|
||||
|
||||
backButton.addEventListener("click", () => {
|
||||
currentIndex = Math.max(0, currentIndex - 1);
|
||||
render();
|
||||
});
|
||||
|
||||
nextButton.addEventListener("click", () => {
|
||||
if (currentIndex === slides.length - 1) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
currentIndex += 1;
|
||||
render();
|
||||
});
|
||||
|
||||
dialog.addEventListener("cancel", (event) => {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
render();
|
||||
dialog.showModal();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const dialog = document.querySelector("[data-onboarding-dialog]");
|
||||
if (dialog) {
|
||||
initOnboarding(dialog);
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -697,7 +697,17 @@ input[type="file"]:focus {
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.toolbar-session-actions {
|
||||
.toolbar-faq-btn svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
}
|
||||
|
||||
.toolbar-translate-btn svg {
|
||||
width: 1.02rem;
|
||||
height: 1.02rem;
|
||||
}
|
||||
|
||||
.toolbar-row {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.38rem;
|
||||
@@ -816,6 +826,437 @@ input[type="file"]:focus {
|
||||
0 1px 0 rgba(255, 255, 255, 0.5) inset;
|
||||
}
|
||||
|
||||
.faq-card {
|
||||
width: min(760px, 100%);
|
||||
margin-inline: auto;
|
||||
padding: clamp(1.2rem, 3vw, 2rem);
|
||||
}
|
||||
|
||||
.faq-card h1 {
|
||||
margin-bottom: 0.55rem;
|
||||
}
|
||||
|
||||
.faq-intro {
|
||||
width: min(56ch, 100%);
|
||||
margin: 0 auto 1.4rem;
|
||||
color: rgba(31, 26, 23, 0.76);
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.faq-list {
|
||||
display: grid;
|
||||
gap: 0.7rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.faq-item {
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(31, 58, 47, 0.14);
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(180deg, #fffdf9 0%, #fbf3e6 100%);
|
||||
box-shadow: 0 5px 14px rgba(31, 58, 47, 0.07);
|
||||
}
|
||||
|
||||
.faq-item summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem;
|
||||
color: var(--forest);
|
||||
font-weight: 650;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.faq-item summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.faq-item summary:focus-visible {
|
||||
outline: 2px solid var(--gold);
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
.faq-toggle {
|
||||
position: relative;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
flex: 0 0 1rem;
|
||||
}
|
||||
|
||||
.faq-toggle::before,
|
||||
.faq-toggle::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 0.85rem;
|
||||
height: 2px;
|
||||
border-radius: 2px;
|
||||
background: var(--gold);
|
||||
transform: translate(-50%, -50%);
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.faq-toggle::after {
|
||||
transform: translate(-50%, -50%) rotate(90deg);
|
||||
}
|
||||
|
||||
.faq-item[open] .faq-toggle::after {
|
||||
transform: translate(-50%, -50%) rotate(0deg);
|
||||
}
|
||||
|
||||
.faq-answer {
|
||||
padding: 0 1rem 1rem;
|
||||
color: rgba(31, 26, 23, 0.8);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.faq-answer p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.faq-item.is-opening .faq-answer {
|
||||
animation: faq-slide-in 300ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.faq-item.is-closing .faq-answer {
|
||||
animation: faq-slide-out 260ms cubic-bezier(0.55, 0.06, 0.68, 0.19) both;
|
||||
}
|
||||
|
||||
@keyframes faq-slide-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(2.5rem);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes faq-slide-out {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translateX(2.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
.translator-dialog {
|
||||
width: min(92vw, 520px);
|
||||
max-height: min(88vh, 720px);
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
color: var(--ink);
|
||||
border: 1px solid rgba(31, 58, 47, 0.16);
|
||||
border-radius: 22px;
|
||||
background: var(--card);
|
||||
box-shadow: 0 24px 70px rgba(18, 31, 24, 0.28);
|
||||
}
|
||||
|
||||
.translator-dialog::backdrop {
|
||||
background: rgba(18, 31, 24, 0);
|
||||
}
|
||||
|
||||
.translator-dialog.is-opening {
|
||||
animation: translator-slide-up 320ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
|
||||
}
|
||||
|
||||
.translator-dialog.is-opening::backdrop {
|
||||
animation: translator-backdrop-in 320ms ease-out both;
|
||||
}
|
||||
|
||||
.translator-dialog.is-closing {
|
||||
animation: translator-slide-down 280ms cubic-bezier(0.55, 0.06, 0.68, 0.19) both;
|
||||
}
|
||||
|
||||
.translator-dialog.is-closing::backdrop {
|
||||
animation: translator-backdrop-out 280ms ease-in both;
|
||||
}
|
||||
|
||||
@keyframes translator-slide-up {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(3.5rem);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes translator-slide-down {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translateY(3.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes translator-backdrop-in {
|
||||
from {
|
||||
background: rgba(18, 31, 24, 0);
|
||||
}
|
||||
to {
|
||||
background: rgba(18, 31, 24, 0.22);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes translator-backdrop-out {
|
||||
from {
|
||||
background: rgba(18, 31, 24, 0.22);
|
||||
}
|
||||
to {
|
||||
background: rgba(18, 31, 24, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.translator-sheet {
|
||||
max-height: min(88vh, 720px);
|
||||
padding: clamp(1.1rem, 4vw, 1.6rem);
|
||||
overflow-y: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.translator-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.translator-head h2 {
|
||||
margin-bottom: 0.8rem;
|
||||
}
|
||||
|
||||
.translator-direction {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--forest);
|
||||
font-weight: 650;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.translator-direction > span {
|
||||
padding: 0.55rem 0.7rem;
|
||||
border: 1px solid rgba(31, 58, 47, 0.14);
|
||||
border-radius: 999px;
|
||||
background: rgba(178, 137, 70, 0.09);
|
||||
}
|
||||
|
||||
.translator-swap {
|
||||
width: 2.35rem;
|
||||
height: 2.35rem;
|
||||
border: 0;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: var(--forest);
|
||||
font-size: 1.1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.translator-label {
|
||||
display: block;
|
||||
margin-bottom: 0.35rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.translator-input {
|
||||
width: 100%;
|
||||
min-height: 7.5rem;
|
||||
resize: vertical;
|
||||
padding: 0.85rem;
|
||||
border: 1px solid rgba(31, 58, 47, 0.22);
|
||||
border-radius: 14px;
|
||||
color: var(--ink);
|
||||
background: #fff;
|
||||
font: inherit;
|
||||
line-height: 1.45;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.translator-input:focus {
|
||||
outline: 2px solid rgba(178, 137, 70, 0.55);
|
||||
border-color: var(--gold);
|
||||
}
|
||||
|
||||
.translator-quick-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 0.45rem;
|
||||
margin-top: 0.7rem;
|
||||
}
|
||||
|
||||
.translator-quick-list button {
|
||||
padding: 0.38rem 0.65rem;
|
||||
border: 1px solid rgba(31, 58, 47, 0.16);
|
||||
border-radius: 999px;
|
||||
color: var(--forest);
|
||||
background: rgba(255, 253, 248, 0.92);
|
||||
font: inherit;
|
||||
font-size: 0.86rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.translator-privacy {
|
||||
margin: 1rem 0 0.8rem;
|
||||
color: rgba(31, 26, 23, 0.7);
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.translator-submit {
|
||||
width: 100%;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.onboarding-dialog {
|
||||
width: min(92vw, 560px);
|
||||
max-height: min(88vh, 720px);
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
color: var(--ink);
|
||||
border: 1px solid rgba(31, 58, 47, 0.16);
|
||||
border-radius: 24px;
|
||||
background: var(--card);
|
||||
box-shadow: 0 26px 72px rgba(18, 31, 24, 0.3);
|
||||
}
|
||||
|
||||
.onboarding-dialog::backdrop {
|
||||
background: rgba(18, 31, 24, 0.5);
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.onboarding-shell {
|
||||
max-height: min(88vh, 720px);
|
||||
padding: clamp(1.25rem, 4vw, 1.8rem);
|
||||
overflow-y: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.onboarding-progress {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 0.38rem;
|
||||
margin-bottom: 0.55rem;
|
||||
}
|
||||
|
||||
.onboarding-progress span {
|
||||
width: 1.4rem;
|
||||
height: 0.28rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(31, 58, 47, 0.14);
|
||||
}
|
||||
|
||||
.onboarding-progress span.is-active {
|
||||
background: var(--gold);
|
||||
}
|
||||
|
||||
.onboarding-step-label {
|
||||
margin: 0 0 0.3rem;
|
||||
color: var(--gold-text);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.onboarding-shell > h2 {
|
||||
margin-bottom: 1rem;
|
||||
color: var(--forest);
|
||||
}
|
||||
|
||||
.onboarding-slide {
|
||||
min-height: 14rem;
|
||||
padding: 1.15rem;
|
||||
border: 1px solid rgba(31, 58, 47, 0.12);
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(180deg, #fffdf8 0%, #fdf5e8 100%);
|
||||
box-shadow: 0 8px 20px rgba(31, 58, 47, 0.08);
|
||||
}
|
||||
|
||||
.onboarding-slide[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.onboarding-icon {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 3.4rem;
|
||||
height: 3.4rem;
|
||||
margin: 0 auto 0.8rem;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
background: linear-gradient(180deg, #2a4a3b 0%, var(--forest) 100%);
|
||||
box-shadow: 0 7px 16px rgba(31, 58, 47, 0.2);
|
||||
font-size: 1.35rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.onboarding-icon svg {
|
||||
width: 1.5rem;
|
||||
height: 1.5rem;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.onboarding-icon-route svg {
|
||||
width: 1.65rem;
|
||||
height: 1.65rem;
|
||||
fill: none;
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.8;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.onboarding-slide h3 {
|
||||
margin-bottom: 0.55rem;
|
||||
color: var(--forest);
|
||||
font-size: 1.35rem;
|
||||
}
|
||||
|
||||
.onboarding-slide p {
|
||||
max-width: 44ch;
|
||||
margin: 0 auto;
|
||||
color: var(--gold-text);
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.onboarding-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.65rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.onboarding-actions > div {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.onboarding-actions .btn {
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.faq-tour-restart {
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
margin: 1.2rem auto 0;
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.gallery-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
@@ -1172,6 +1613,20 @@ input[type="file"]:focus {
|
||||
padding: 0.74rem 1.2rem;
|
||||
}
|
||||
|
||||
.route-location-btn.btn-ghost {
|
||||
color: #174ea6;
|
||||
border-color: #a8c7fa;
|
||||
background: linear-gradient(180deg, #f2f7ff 0%, #e8f0fe 100%);
|
||||
box-shadow: 0 5px 12px rgba(66, 133, 244, 0.12);
|
||||
}
|
||||
|
||||
.route-location-btn.btn-ghost:hover {
|
||||
color: #123d82;
|
||||
border-color: #7eaff8;
|
||||
background: linear-gradient(180deg, #edf5ff 0%, #dce9fd 100%);
|
||||
box-shadow: 0 7px 16px rgba(66, 133, 244, 0.2);
|
||||
}
|
||||
|
||||
body.has-route-modal {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -1296,6 +1751,7 @@ body.has-route-modal {
|
||||
}
|
||||
|
||||
.gift-image-wrap {
|
||||
position: relative;
|
||||
max-width: min(640px, 100%);
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -1309,6 +1765,18 @@ body.has-route-modal {
|
||||
box-shadow: 0 12px 28px rgba(31, 58, 47, 0.18);
|
||||
}
|
||||
|
||||
.gift-money-label {
|
||||
position: absolute;
|
||||
top: 7%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
color: #f0db8e;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: clamp(1.35rem, 5.6vw, 2.25rem);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gift-caption {
|
||||
margin: 0.8rem 0 0;
|
||||
font-weight: 700;
|
||||
@@ -1528,6 +1996,33 @@ body.has-route-modal {
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 0.28rem;
|
||||
width: 13.2rem;
|
||||
}
|
||||
|
||||
.toolbar-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.toolbar-login {
|
||||
width: auto;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.toolbar-login .toolbar-row {
|
||||
width: auto;
|
||||
justify-content: flex-end;
|
||||
gap: 0.38rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 1.15rem auto 1.25rem;
|
||||
}
|
||||
@@ -1609,9 +2104,62 @@ body.has-route-modal {
|
||||
.route-open-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.translator-dialog {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
max-height: 88vh;
|
||||
margin: auto 0 0;
|
||||
border-radius: 22px 22px 0 0;
|
||||
}
|
||||
|
||||
.translator-sheet {
|
||||
max-height: 88vh;
|
||||
padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.onboarding-dialog {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
max-height: 90vh;
|
||||
margin: auto 0 0;
|
||||
border-radius: 24px 24px 0 0;
|
||||
}
|
||||
|
||||
.onboarding-shell {
|
||||
max-height: 90vh;
|
||||
padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.onboarding-slide {
|
||||
min-height: 12.5rem;
|
||||
}
|
||||
|
||||
.onboarding-actions {
|
||||
align-items: stretch;
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
.onboarding-actions > div,
|
||||
.onboarding-actions .btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.translator-dialog.is-opening,
|
||||
.translator-dialog.is-closing,
|
||||
.faq-item.is-opening .faq-answer,
|
||||
.faq-item.is-closing .faq-answer {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.translator-dialog.is-opening::backdrop,
|
||||
.translator-dialog.is-closing::backdrop {
|
||||
animation: none;
|
||||
background: rgba(18, 31, 24, 0.14);
|
||||
}
|
||||
|
||||
.gift-reveal.is-active {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
117
backend/static/translator.js
Normal file
117
backend/static/translator.js
Normal file
@@ -0,0 +1,117 @@
|
||||
(() => {
|
||||
function initTranslator(dialog) {
|
||||
const openButton = document.querySelector("[data-translator-open]");
|
||||
const swapButton = dialog.querySelector("[data-translator-swap]");
|
||||
const submitButton = dialog.querySelector("[data-translator-submit]");
|
||||
const input = dialog.querySelector("[data-translator-input]");
|
||||
const sourceLabel = dialog.querySelector("[data-translator-source]");
|
||||
const targetLabel = dialog.querySelector("[data-translator-target]");
|
||||
const phraseButtons = dialog.querySelectorAll("[data-translator-phrase]");
|
||||
|
||||
if (!openButton || !swapButton || !submitButton || !input || !sourceLabel || !targetLabel) {
|
||||
return;
|
||||
}
|
||||
|
||||
let sourceLang = dialog.dataset.sourceLang === "en" ? "en" : "de";
|
||||
const labels = {
|
||||
de: sourceLang === "de" ? sourceLabel.textContent : targetLabel.textContent,
|
||||
en: sourceLang === "en" ? sourceLabel.textContent : targetLabel.textContent,
|
||||
};
|
||||
|
||||
const renderDirection = () => {
|
||||
const targetLang = sourceLang === "de" ? "en" : "de";
|
||||
sourceLabel.textContent = labels[sourceLang];
|
||||
targetLabel.textContent = labels[targetLang];
|
||||
};
|
||||
|
||||
const updateSubmit = () => {
|
||||
submitButton.disabled = input.value.trim().length === 0;
|
||||
};
|
||||
|
||||
let isClosing = false;
|
||||
|
||||
const close = () => {
|
||||
if (!dialog.open || isClosing) {
|
||||
return;
|
||||
}
|
||||
isClosing = true;
|
||||
dialog.classList.remove("is-opening");
|
||||
dialog.classList.add("is-closing");
|
||||
|
||||
const finishClose = () => {
|
||||
if (!dialog.open) {
|
||||
return;
|
||||
}
|
||||
dialog.classList.remove("is-closing");
|
||||
dialog.close();
|
||||
isClosing = false;
|
||||
openButton.focus();
|
||||
};
|
||||
|
||||
dialog.addEventListener("animationend", finishClose, { once: true });
|
||||
window.setTimeout(
|
||||
finishClose,
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : 360,
|
||||
);
|
||||
};
|
||||
|
||||
openButton.addEventListener("click", () => {
|
||||
dialog.showModal();
|
||||
dialog.classList.remove("is-closing");
|
||||
dialog.classList.add("is-opening");
|
||||
window.requestAnimationFrame(() => input.focus());
|
||||
});
|
||||
|
||||
dialog.addEventListener("click", (event) => {
|
||||
if (event.target === dialog) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
dialog.addEventListener("cancel", (event) => {
|
||||
event.preventDefault();
|
||||
close();
|
||||
});
|
||||
|
||||
swapButton.addEventListener("click", () => {
|
||||
sourceLang = sourceLang === "de" ? "en" : "de";
|
||||
renderDirection();
|
||||
phraseButtons.forEach((button) => {
|
||||
input.value = input.value === button.dataset.de || input.value === button.dataset.en
|
||||
? button.dataset[sourceLang]
|
||||
: input.value;
|
||||
});
|
||||
updateSubmit();
|
||||
input.focus();
|
||||
});
|
||||
|
||||
phraseButtons.forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
input.value = button.dataset[sourceLang] || "";
|
||||
updateSubmit();
|
||||
input.focus();
|
||||
});
|
||||
});
|
||||
|
||||
input.addEventListener("input", updateSubmit);
|
||||
submitButton.addEventListener("click", () => {
|
||||
const text = input.value.trim();
|
||||
if (!text) {
|
||||
return;
|
||||
}
|
||||
const targetLang = sourceLang === "de" ? "en" : "de";
|
||||
const url = `https://www.deepl.com/translator#${sourceLang}/${targetLang}/${encodeURIComponent(text)}`;
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
close();
|
||||
});
|
||||
|
||||
renderDirection();
|
||||
updateSubmit();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const dialog = document.querySelector("[data-translator-dialog]");
|
||||
if (dialog) {
|
||||
initTranslator(dialog);
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user