Spaces:
Running
Running
design a web-layer for this website with before and after on/off button
Browse files- components/audio-comparison.js +148 -0
- index.html +2 -1
- single-track-mastering.html +1 -0
components/audio-comparison.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class AudioComparison extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
margin: 2rem 0;
|
| 9 |
+
}
|
| 10 |
+
.comparison-container {
|
| 11 |
+
position: relative;
|
| 12 |
+
background: #1e1e1e;
|
| 13 |
+
border-radius: 12px;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
| 16 |
+
}
|
| 17 |
+
.audio-wrapper {
|
| 18 |
+
position: relative;
|
| 19 |
+
height: 80px;
|
| 20 |
+
}
|
| 21 |
+
audio {
|
| 22 |
+
width: 100%;
|
| 23 |
+
opacity: 0.7;
|
| 24 |
+
transition: opacity 0.3s ease;
|
| 25 |
+
}
|
| 26 |
+
audio.active {
|
| 27 |
+
opacity: 1;
|
| 28 |
+
}
|
| 29 |
+
.toggle-container {
|
| 30 |
+
display: flex;
|
| 31 |
+
justify-content: center;
|
| 32 |
+
padding: 1rem;
|
| 33 |
+
background: #2a2a2a;
|
| 34 |
+
}
|
| 35 |
+
.toggle-switch {
|
| 36 |
+
position: relative;
|
| 37 |
+
display: inline-block;
|
| 38 |
+
width: 120px;
|
| 39 |
+
height: 44px;
|
| 40 |
+
}
|
| 41 |
+
.toggle-switch input {
|
| 42 |
+
opacity: 0;
|
| 43 |
+
width: 0;
|
| 44 |
+
height: 0;
|
| 45 |
+
}
|
| 46 |
+
.slider {
|
| 47 |
+
position: absolute;
|
| 48 |
+
cursor: pointer;
|
| 49 |
+
top: 0;
|
| 50 |
+
left: 0;
|
| 51 |
+
right: 0;
|
| 52 |
+
bottom: 0;
|
| 53 |
+
background: linear-gradient(to right, #4f46e5, #7c3aed);
|
| 54 |
+
transition: .4s;
|
| 55 |
+
border-radius: 34px;
|
| 56 |
+
}
|
| 57 |
+
.slider:before {
|
| 58 |
+
position: absolute;
|
| 59 |
+
content: "";
|
| 60 |
+
height: 36px;
|
| 61 |
+
width: 36px;
|
| 62 |
+
left: 4px;
|
| 63 |
+
bottom: 4px;
|
| 64 |
+
background-color: white;
|
| 65 |
+
transition: .4s;
|
| 66 |
+
border-radius: 50%;
|
| 67 |
+
}
|
| 68 |
+
input:checked + .slider {
|
| 69 |
+
background: linear-gradient(to right, #7c3aed, #4f46e5);
|
| 70 |
+
}
|
| 71 |
+
input:checked + .slider:before {
|
| 72 |
+
transform: translateX(76px);
|
| 73 |
+
}
|
| 74 |
+
.labels {
|
| 75 |
+
position: absolute;
|
| 76 |
+
top: 50%;
|
| 77 |
+
transform: translateY(-50%);
|
| 78 |
+
width: 100%;
|
| 79 |
+
display: flex;
|
| 80 |
+
justify-content: space-between;
|
| 81 |
+
padding: 0 12px;
|
| 82 |
+
pointer-events: none;
|
| 83 |
+
}
|
| 84 |
+
.label {
|
| 85 |
+
color: white;
|
| 86 |
+
font-weight: bold;
|
| 87 |
+
font-size: 14px;
|
| 88 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
| 89 |
+
}
|
| 90 |
+
.before-label {
|
| 91 |
+
margin-left: 50px;
|
| 92 |
+
}
|
| 93 |
+
.after-label {
|
| 94 |
+
margin-right: 50px;
|
| 95 |
+
}
|
| 96 |
+
</style>
|
| 97 |
+
<div class="comparison-container">
|
| 98 |
+
<div class="audio-wrapper">
|
| 99 |
+
<audio id="before-audio" controls>
|
| 100 |
+
<source src="" type="audio/mpeg">
|
| 101 |
+
Your browser does not support the audio element.
|
| 102 |
+
</audio>
|
| 103 |
+
<audio id="after-audio" controls class="active">
|
| 104 |
+
<source src="" type="audio/mpeg">
|
| 105 |
+
Your browser does not support the audio element.
|
| 106 |
+
</audio>
|
| 107 |
+
</div>
|
| 108 |
+
<div class="toggle-container">
|
| 109 |
+
<label class="toggle-switch">
|
| 110 |
+
<input type="checkbox" checked>
|
| 111 |
+
<span class="slider"></span>
|
| 112 |
+
<div class="labels">
|
| 113 |
+
<span class="label before-label">Before</span>
|
| 114 |
+
<span class="label after-label">After</span>
|
| 115 |
+
</div>
|
| 116 |
+
</label>
|
| 117 |
+
</div>
|
| 118 |
+
</div>
|
| 119 |
+
`;
|
| 120 |
+
|
| 121 |
+
const beforeAudio = this.shadowRoot.getElementById('before-audio');
|
| 122 |
+
const afterAudio = this.shadowRoot.getElementById('after-audio');
|
| 123 |
+
const toggle = this.shadowRoot.querySelector('input[type="checkbox"]');
|
| 124 |
+
|
| 125 |
+
// Set audio sources from attributes
|
| 126 |
+
if (this.hasAttribute('before-src')) {
|
| 127 |
+
beforeAudio.querySelector('source').src = this.getAttribute('before-src');
|
| 128 |
+
beforeAudio.load();
|
| 129 |
+
}
|
| 130 |
+
if (this.hasAttribute('after-src')) {
|
| 131 |
+
afterAudio.querySelector('source').src = this.getAttribute('after-src');
|
| 132 |
+
afterAudio.load();
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
// Toggle functionality
|
| 136 |
+
toggle.addEventListener('change', () => {
|
| 137 |
+
if (toggle.checked) {
|
| 138 |
+
beforeAudio.classList.remove('active');
|
| 139 |
+
afterAudio.classList.add('active');
|
| 140 |
+
} else {
|
| 141 |
+
beforeAudio.classList.add('active');
|
| 142 |
+
afterAudio.classList.remove('active');
|
| 143 |
+
}
|
| 144 |
+
});
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
customElements.define('audio-comparison', AudioComparison);
|
index.html
CHANGED
|
@@ -302,7 +302,8 @@
|
|
| 302 |
<script>
|
| 303 |
feather.replace();
|
| 304 |
</script>
|
|
|
|
| 305 |
<script src="script.js"></script>
|
| 306 |
-
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 307 |
</body>
|
| 308 |
</html>
|
|
|
|
| 302 |
<script>
|
| 303 |
feather.replace();
|
| 304 |
</script>
|
| 305 |
+
<script src="components/audio-comparison.js"></script>
|
| 306 |
<script src="script.js"></script>
|
| 307 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 308 |
</body>
|
| 309 |
</html>
|
single-track-mastering.html
CHANGED
|
@@ -156,6 +156,7 @@
|
|
| 156 |
<script>
|
| 157 |
feather.replace();
|
| 158 |
</script>
|
|
|
|
| 159 |
<script src="script.js"></script>
|
| 160 |
</body>
|
| 161 |
</html>
|
|
|
|
| 156 |
<script>
|
| 157 |
feather.replace();
|
| 158 |
</script>
|
| 159 |
+
<script src="components/audio-comparison.js"></script>
|
| 160 |
<script src="script.js"></script>
|
| 161 |
</body>
|
| 162 |
</html>
|