added background wedding music with play/pause toggle button
This commit is contained in:
parent
97ef656125
commit
ac8a37f5c0
BIN
assets/music.mp3
Normal file
BIN
assets/music.mp3
Normal file
Binary file not shown.
@ -34,6 +34,9 @@
|
||||
.form-card h3 { font-weight: 400; font-size: 1.1rem; margin-bottom: var(--kt-ai-space-4); }
|
||||
.form-success { margin-top: var(--kt-ai-space-4); padding: var(--kt-ai-space-3); border-radius: 8px; background: var(--kt-ai-primary-subtle); color: var(--kt-ai-fg); font-size: 0.9rem; }
|
||||
.rsvp-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--kt-ai-space-3); }
|
||||
.music-btn { position: fixed; right: 18px; top: 18px; z-index: 50; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--kt-ai-border); background: var(--kt-ai-card-bg); color: var(--kt-ai-primary); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--kt-ai-card-shadow); }
|
||||
.music-btn:hover { border-color: var(--kt-ai-border-strong); }
|
||||
.music-btn.on { background: var(--kt-ai-primary-subtle); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -161,6 +164,11 @@
|
||||
<a class="kt-ai-link" href="#rsvp">Ответить</a>
|
||||
</footer>
|
||||
|
||||
<script src="design-system/icons/kt-ai-icons.js"></script>
|
||||
<script src="script.js"></script>
|
||||
<audio id="bgMusic" loop preload="auto" src="assets/music.mp3"></audio>
|
||||
<button type="button" class="music-btn" id="musicBtn" aria-label="Включить музыку">
|
||||
<svg class="kt-icon" aria-hidden="true"><use href="#play"></use></svg>
|
||||
</button>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
20
script.js
20
script.js
@ -34,6 +34,26 @@
|
||||
tick();
|
||||
setInterval(tick, 1000);
|
||||
|
||||
var music = document.getElementById("bgMusic");
|
||||
var musicBtn = document.getElementById("musicBtn");
|
||||
if (musicBtn && music) {
|
||||
musicBtn.addEventListener("click", function () {
|
||||
if (music.paused) {
|
||||
music.play();
|
||||
musicBtn.classList.add("on");
|
||||
musicBtn.setAttribute("aria-label", "Приостановить музыку");
|
||||
} else {
|
||||
music.pause();
|
||||
musicBtn.classList.remove("on");
|
||||
musicBtn.setAttribute("aria-label", "Включить музыку");
|
||||
}
|
||||
});
|
||||
music.addEventListener("ended", function () {
|
||||
musicBtn.classList.remove("on");
|
||||
musicBtn.setAttribute("aria-label", "Включить музыку");
|
||||
});
|
||||
}
|
||||
|
||||
var form = document.getElementById("rsvpForm");
|
||||
var success = document.getElementById("formSuccess");
|
||||
if (form) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user