@jjlmoya/utils-health 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +60 -0
- package/src/category/i18n/en.ts +60 -0
- package/src/category/i18n/es.ts +60 -0
- package/src/category/i18n/fr.ts +60 -0
- package/src/category/index.ts +22 -0
- package/src/category/seo.astro +15 -0
- package/src/components/PreviewNavSidebar.astro +116 -0
- package/src/components/PreviewToolbar.astro +143 -0
- package/src/data.ts +28 -0
- package/src/env.d.ts +5 -0
- package/src/index.ts +36 -0
- package/src/layouts/PreviewLayout.astro +117 -0
- package/src/pages/[locale]/[slug].astro +146 -0
- package/src/pages/[locale].astro +251 -0
- package/src/pages/index.astro +4 -0
- package/src/tests/faq_count.test.ts +19 -0
- package/src/tests/locale_completeness.test.ts +42 -0
- package/src/tests/mocks/astro_mock.js +2 -0
- package/src/tests/no_h1_in_components.test.ts +48 -0
- package/src/tests/schemas_fulfillment.test.ts +23 -0
- package/src/tests/seo_length.test.ts +22 -0
- package/src/tests/title_quality.test.ts +55 -0
- package/src/tests/tool_validation.test.ts +17 -0
- package/src/tool/binauralTuner/bibliography.astro +14 -0
- package/src/tool/binauralTuner/component.astro +687 -0
- package/src/tool/binauralTuner/i18n/en.ts +187 -0
- package/src/tool/binauralTuner/i18n/es.ts +187 -0
- package/src/tool/binauralTuner/i18n/fr.ts +187 -0
- package/src/tool/binauralTuner/index.ts +27 -0
- package/src/tool/binauralTuner/seo.astro +14 -0
- package/src/tool/binauralTuner/ui.ts +18 -0
- package/src/tool/bloodUnitConverter/bibliography.astro +14 -0
- package/src/tool/bloodUnitConverter/component.astro +915 -0
- package/src/tool/bloodUnitConverter/i18n/en.ts +227 -0
- package/src/tool/bloodUnitConverter/i18n/es.ts +250 -0
- package/src/tool/bloodUnitConverter/i18n/fr.ts +218 -0
- package/src/tool/bloodUnitConverter/index.ts +27 -0
- package/src/tool/bloodUnitConverter/seo.astro +14 -0
- package/src/tool/bloodUnitConverter/ui.ts +38 -0
- package/src/tool/bmiCalculator/bibliography.astro +14 -0
- package/src/tool/bmiCalculator/component.astro +415 -0
- package/src/tool/bmiCalculator/i18n/en.ts +217 -0
- package/src/tool/bmiCalculator/i18n/es.ts +221 -0
- package/src/tool/bmiCalculator/i18n/fr.ts +217 -0
- package/src/tool/bmiCalculator/index.ts +27 -0
- package/src/tool/bmiCalculator/seo.astro +14 -0
- package/src/tool/bmiCalculator/ui.ts +21 -0
- package/src/tool/breathingVisualizer/bibliography.astro +14 -0
- package/src/tool/breathingVisualizer/component.astro +636 -0
- package/src/tool/breathingVisualizer/i18n/en.ts +206 -0
- package/src/tool/breathingVisualizer/i18n/es.ts +206 -0
- package/src/tool/breathingVisualizer/i18n/fr.ts +206 -0
- package/src/tool/breathingVisualizer/index.ts +27 -0
- package/src/tool/breathingVisualizer/seo.astro +14 -0
- package/src/tool/breathingVisualizer/ui.ts +31 -0
- package/src/tool/caffeineTracker/bibliography.astro +14 -0
- package/src/tool/caffeineTracker/component.astro +1210 -0
- package/src/tool/caffeineTracker/i18n/en.ts +198 -0
- package/src/tool/caffeineTracker/i18n/es.ts +198 -0
- package/src/tool/caffeineTracker/i18n/fr.ts +198 -0
- package/src/tool/caffeineTracker/index.ts +27 -0
- package/src/tool/caffeineTracker/logic.ts +31 -0
- package/src/tool/caffeineTracker/seo.astro +14 -0
- package/src/tool/caffeineTracker/ui.ts +36 -0
- package/src/tool/daltonismSimulator/bibliography.astro +14 -0
- package/src/tool/daltonismSimulator/component.astro +383 -0
- package/src/tool/daltonismSimulator/i18n/en.ts +188 -0
- package/src/tool/daltonismSimulator/i18n/es.ts +218 -0
- package/src/tool/daltonismSimulator/i18n/fr.ts +168 -0
- package/src/tool/daltonismSimulator/index.ts +27 -0
- package/src/tool/daltonismSimulator/seo.astro +14 -0
- package/src/tool/daltonismSimulator/ui.ts +20 -0
- package/src/tool/digestionStopwatch/bibliography.astro +14 -0
- package/src/tool/digestionStopwatch/component.astro +627 -0
- package/src/tool/digestionStopwatch/i18n/en.ts +173 -0
- package/src/tool/digestionStopwatch/i18n/es.ts +173 -0
- package/src/tool/digestionStopwatch/i18n/fr.ts +173 -0
- package/src/tool/digestionStopwatch/index.ts +27 -0
- package/src/tool/digestionStopwatch/logic.ts +63 -0
- package/src/tool/digestionStopwatch/seo.astro +14 -0
- package/src/tool/digestionStopwatch/ui.ts +20 -0
- package/src/tool/epworthSleepinessScale/bibliography.astro +14 -0
- package/src/tool/epworthSleepinessScale/component.astro +528 -0
- package/src/tool/epworthSleepinessScale/i18n/en.ts +217 -0
- package/src/tool/epworthSleepinessScale/i18n/es.ts +217 -0
- package/src/tool/epworthSleepinessScale/i18n/fr.ts +217 -0
- package/src/tool/epworthSleepinessScale/index.ts +27 -0
- package/src/tool/epworthSleepinessScale/seo.astro +14 -0
- package/src/tool/epworthSleepinessScale/ui.ts +27 -0
- package/src/tool/hydrationCalculator/bibliography.astro +14 -0
- package/src/tool/hydrationCalculator/component.astro +694 -0
- package/src/tool/hydrationCalculator/i18n/en.ts +217 -0
- package/src/tool/hydrationCalculator/i18n/es.ts +222 -0
- package/src/tool/hydrationCalculator/i18n/fr.ts +199 -0
- package/src/tool/hydrationCalculator/index.ts +27 -0
- package/src/tool/hydrationCalculator/seo.astro +14 -0
- package/src/tool/hydrationCalculator/ui.ts +28 -0
- package/src/tool/pelliRobsonTest/bibliography.astro +14 -0
- package/src/tool/pelliRobsonTest/component.astro +653 -0
- package/src/tool/pelliRobsonTest/i18n/en.ts +205 -0
- package/src/tool/pelliRobsonTest/i18n/es.ts +205 -0
- package/src/tool/pelliRobsonTest/i18n/fr.ts +205 -0
- package/src/tool/pelliRobsonTest/index.ts +27 -0
- package/src/tool/pelliRobsonTest/seo.astro +14 -0
- package/src/tool/pelliRobsonTest/ui.ts +21 -0
- package/src/tool/peripheralVisionTrainer/bibliography.astro +14 -0
- package/src/tool/peripheralVisionTrainer/component.astro +678 -0
- package/src/tool/peripheralVisionTrainer/i18n/en.ts +224 -0
- package/src/tool/peripheralVisionTrainer/i18n/es.ts +224 -0
- package/src/tool/peripheralVisionTrainer/i18n/fr.ts +211 -0
- package/src/tool/peripheralVisionTrainer/index.ts +27 -0
- package/src/tool/peripheralVisionTrainer/seo.astro +14 -0
- package/src/tool/peripheralVisionTrainer/ui.ts +26 -0
- package/src/tool/readingDistanceCalculator/bibliography.astro +14 -0
- package/src/tool/readingDistanceCalculator/component.astro +588 -0
- package/src/tool/readingDistanceCalculator/i18n/en.ts +202 -0
- package/src/tool/readingDistanceCalculator/i18n/es.ts +215 -0
- package/src/tool/readingDistanceCalculator/i18n/fr.ts +193 -0
- package/src/tool/readingDistanceCalculator/index.ts +31 -0
- package/src/tool/readingDistanceCalculator/seo.astro +14 -0
- package/src/tool/readingDistanceCalculator/ui.ts +18 -0
- package/src/tool/screenDecompressionTime/bibliography.astro +14 -0
- package/src/tool/screenDecompressionTime/component.astro +671 -0
- package/src/tool/screenDecompressionTime/i18n/en.ts +225 -0
- package/src/tool/screenDecompressionTime/i18n/es.ts +247 -0
- package/src/tool/screenDecompressionTime/i18n/fr.ts +225 -0
- package/src/tool/screenDecompressionTime/index.ts +27 -0
- package/src/tool/screenDecompressionTime/seo.astro +14 -0
- package/src/tool/screenDecompressionTime/ui.ts +32 -0
- package/src/tool/tinnitusReliever/bibliography.astro +14 -0
- package/src/tool/tinnitusReliever/component.astro +581 -0
- package/src/tool/tinnitusReliever/i18n/en.ts +161 -0
- package/src/tool/tinnitusReliever/i18n/es.ts +161 -0
- package/src/tool/tinnitusReliever/i18n/fr.ts +161 -0
- package/src/tool/tinnitusReliever/index.ts +27 -0
- package/src/tool/tinnitusReliever/seo.astro +14 -0
- package/src/tool/tinnitusReliever/ui.ts +9 -0
- package/src/tool/ubeCalculator/bibliography.astro +14 -0
- package/src/tool/ubeCalculator/component.astro +683 -0
- package/src/tool/ubeCalculator/i18n/en.ts +200 -0
- package/src/tool/ubeCalculator/i18n/es.ts +200 -0
- package/src/tool/ubeCalculator/i18n/fr.ts +196 -0
- package/src/tool/ubeCalculator/index.ts +27 -0
- package/src/tool/ubeCalculator/seo.astro +14 -0
- package/src/tool/ubeCalculator/ui.ts +26 -0
- package/src/tool/waterPurifier/bibliography.astro +14 -0
- package/src/tool/waterPurifier/component.astro +628 -0
- package/src/tool/waterPurifier/i18n/en.ts +167 -0
- package/src/tool/waterPurifier/i18n/es.ts +167 -0
- package/src/tool/waterPurifier/i18n/fr.ts +167 -0
- package/src/tool/waterPurifier/index.ts +27 -0
- package/src/tool/waterPurifier/seo.astro +14 -0
- package/src/tool/waterPurifier/ui.ts +18 -0
- package/src/tools.ts +19 -0
- package/src/types.ts +72 -0
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { BinauralTunerUI } from './ui';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
ui?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const ui = (Astro.props.ui ?? {}) as BinauralTunerUI;
|
|
9
|
+
|
|
10
|
+
const presets = [
|
|
11
|
+
{ base: 174, beat: 1.5, label: ui.presetDeltaSleep },
|
|
12
|
+
{ base: 210, beat: 4.5, label: ui.presetLucidDream, active: true },
|
|
13
|
+
{ base: 396, beat: 10, label: ui.presetDeepAlpha },
|
|
14
|
+
{ base: 528, beat: 20, label: ui.presetActiveBeta },
|
|
15
|
+
{ base: 639, beat: 40, label: ui.presetSuperGamma },
|
|
16
|
+
];
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<div class="bt" id="bt-container" data-ui={JSON.stringify(ui)}>
|
|
20
|
+
<div class="bt__card">
|
|
21
|
+
|
|
22
|
+
<div class="bt__controls-grid">
|
|
23
|
+
<div class="bt__control-group">
|
|
24
|
+
<div class="bt__control-header">
|
|
25
|
+
<span class="bt__control-label">{ui.labelBaseFreq}</span>
|
|
26
|
+
<div class="bt__value-display" id="bt-base-val">200<span class="bt__value-unit">Hz</span></div>
|
|
27
|
+
</div>
|
|
28
|
+
<input type="range" id="bt-base-freq" min="100" max="800" step="1" value="200"
|
|
29
|
+
aria-label={ui.labelBaseFreq} class="bt__range" />
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div class="bt__control-group">
|
|
33
|
+
<div class="bt__control-header">
|
|
34
|
+
<span class="bt__control-label">{ui.labelBeatFreq}</span>
|
|
35
|
+
<div class="bt__value-display" id="bt-beat-val">4.0<span class="bt__value-unit">Hz</span></div>
|
|
36
|
+
</div>
|
|
37
|
+
<input type="range" id="bt-beat-freq" min="0.5" max="40" step="0.1" value="4"
|
|
38
|
+
aria-label={ui.labelBeatFreq} class="bt__range" />
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<div class="bt__presets-wrap">
|
|
43
|
+
<div class="bt__beat-desc" id="bt-beat-desc">{ui.waveTheta}</div>
|
|
44
|
+
<div class="bt__presets">
|
|
45
|
+
{presets.map((p) => (
|
|
46
|
+
<button
|
|
47
|
+
class={`bt__preset-btn${p.active ? ' bt__preset-btn--active' : ''}`}
|
|
48
|
+
data-base={p.base}
|
|
49
|
+
data-beat={p.beat}
|
|
50
|
+
>
|
|
51
|
+
{p.label}
|
|
52
|
+
</button>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<div class="bt__actions">
|
|
58
|
+
<button id="bt-toggle-audio" class="bt__play-btn" aria-label={ui.btnPlay}>
|
|
59
|
+
<svg id="bt-play-icon" viewBox="0 0 24 24" class="bt__play-svg">
|
|
60
|
+
<path d="M8,5.14V19.14L19,12.14L8,5.14Z" />
|
|
61
|
+
</svg>
|
|
62
|
+
<svg id="bt-stop-icon" viewBox="0 0 24 24" class="bt__play-svg bt__play-svg--hidden">
|
|
63
|
+
<path d="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M9,9H15V15H9V9Z" />
|
|
64
|
+
</svg>
|
|
65
|
+
</button>
|
|
66
|
+
|
|
67
|
+
<button id="bt-toggle-strobe" class="bt__strobe-btn">
|
|
68
|
+
{ui.btnVisualPulse}
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div class="bt__visualizer">
|
|
73
|
+
<div id="bt-strobe" class="bt__strobe"></div>
|
|
74
|
+
<canvas id="bt-canvas" class="bt__canvas"></canvas>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="bt__warning">
|
|
78
|
+
<strong class="bt__warning-title">{ui.warningTitle}</strong>
|
|
79
|
+
{ui.warningText}
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<script>
|
|
86
|
+
import type { BinauralTunerUI } from './ui';
|
|
87
|
+
|
|
88
|
+
interface WindowWithWebkitAudio extends Window {
|
|
89
|
+
webkitAudioContext: typeof AudioContext;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const container = document.getElementById('bt-container');
|
|
93
|
+
const ui = JSON.parse(container?.dataset.ui ?? '{}') as BinauralTunerUI;
|
|
94
|
+
|
|
95
|
+
const baseInput = container?.querySelector<HTMLInputElement>('#bt-base-freq');
|
|
96
|
+
const beatInput = container?.querySelector<HTMLInputElement>('#bt-beat-freq');
|
|
97
|
+
const baseVal = container?.querySelector<HTMLElement>('#bt-base-val');
|
|
98
|
+
const beatVal = container?.querySelector<HTMLElement>('#bt-beat-val');
|
|
99
|
+
const beatDesc = container?.querySelector<HTMLElement>('#bt-beat-desc');
|
|
100
|
+
const toggleBtn = container?.querySelector<HTMLElement>('#bt-toggle-audio');
|
|
101
|
+
const strobeBtn = container?.querySelector<HTMLElement>('#bt-toggle-strobe');
|
|
102
|
+
const strobeEl = container?.querySelector<HTMLElement>('#bt-strobe');
|
|
103
|
+
const playIcon = container?.querySelector<HTMLElement>('#bt-play-icon');
|
|
104
|
+
const stopIcon = container?.querySelector<HTMLElement>('#bt-stop-icon');
|
|
105
|
+
const canvas = container?.querySelector<HTMLCanvasElement>('#bt-canvas');
|
|
106
|
+
const ctx2d = canvas?.getContext('2d');
|
|
107
|
+
|
|
108
|
+
let audioCtx: AudioContext | null = null;
|
|
109
|
+
let oscL: OscillatorNode | null = null;
|
|
110
|
+
let oscR: OscillatorNode | null = null;
|
|
111
|
+
let isPlaying = false;
|
|
112
|
+
let isStrobeActive = false;
|
|
113
|
+
|
|
114
|
+
const WAVE_THRESHOLDS = [4, 8, 14, 30] as const;
|
|
115
|
+
|
|
116
|
+
function getBeatDescription(beat: number): string {
|
|
117
|
+
if (beat < WAVE_THRESHOLDS[0]) return ui.waveDelta;
|
|
118
|
+
if (beat < WAVE_THRESHOLDS[1]) return ui.waveTheta;
|
|
119
|
+
if (beat < WAVE_THRESHOLDS[2]) return ui.waveAlpha;
|
|
120
|
+
if (beat < WAVE_THRESHOLDS[3]) return ui.waveBeta;
|
|
121
|
+
return ui.waveGamma;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function updateLabels() {
|
|
125
|
+
const base = parseFloat(baseInput?.value ?? '200');
|
|
126
|
+
const beat = parseFloat(beatInput?.value ?? '4');
|
|
127
|
+
if (baseVal) baseVal.innerHTML = `${base}<span class="bt__value-unit">Hz</span>`;
|
|
128
|
+
if (beatVal) beatVal.innerHTML = `${beat.toFixed(1)}<span class="bt__value-unit">Hz</span>`;
|
|
129
|
+
if (beatDesc) beatDesc.textContent = getBeatDescription(beat);
|
|
130
|
+
updateAudio();
|
|
131
|
+
updateStrobe();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function createAudioContext(): AudioContext {
|
|
135
|
+
const Ctor = window.AudioContext ?? (window as WindowWithWebkitAudio).webkitAudioContext;
|
|
136
|
+
return new Ctor();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function buildOscillator(ctx: AudioContext, freq: number, pan: number): OscillatorNode {
|
|
140
|
+
const osc = ctx.createOscillator();
|
|
141
|
+
const gain = ctx.createGain();
|
|
142
|
+
const panner = ctx.createStereoPanner();
|
|
143
|
+
gain.gain.value = 0.5;
|
|
144
|
+
panner.pan.value = pan;
|
|
145
|
+
osc.connect(gain).connect(panner).connect(ctx.destination);
|
|
146
|
+
osc.type = 'sine';
|
|
147
|
+
osc.frequency.value = freq;
|
|
148
|
+
return osc;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function initAudio() {
|
|
152
|
+
const base = parseFloat(baseInput?.value ?? '200');
|
|
153
|
+
const beat = parseFloat(beatInput?.value ?? '4');
|
|
154
|
+
audioCtx = createAudioContext();
|
|
155
|
+
oscL = buildOscillator(audioCtx, base - beat / 2, -1);
|
|
156
|
+
oscR = buildOscillator(audioCtx, base + beat / 2, 1);
|
|
157
|
+
oscL.start();
|
|
158
|
+
oscR.start();
|
|
159
|
+
animate();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function updateAudio() {
|
|
163
|
+
if (!audioCtx || !oscL || !oscR) return;
|
|
164
|
+
const base = parseFloat(baseInput?.value ?? '200');
|
|
165
|
+
const beat = parseFloat(beatInput?.value ?? '4');
|
|
166
|
+
oscL.frequency.setTargetAtTime(base - beat / 2, audioCtx.currentTime, 0.1);
|
|
167
|
+
oscR.frequency.setTargetAtTime(base + beat / 2, audioCtx.currentTime, 0.1);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function updateStrobe() {
|
|
171
|
+
if (!strobeEl) return;
|
|
172
|
+
if (isStrobeActive) {
|
|
173
|
+
const beat = parseFloat(beatInput?.value ?? '4');
|
|
174
|
+
strobeEl.style.setProperty('--bt-strobe-duration', `${1 / beat}s`);
|
|
175
|
+
strobeEl.classList.add('bt__strobe--active');
|
|
176
|
+
} else {
|
|
177
|
+
strobeEl.classList.remove('bt__strobe--active');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function drawWave(color: string, freqMult: number, ampMod: number, time: number) {
|
|
182
|
+
if (!ctx2d || !canvas) return;
|
|
183
|
+
ctx2d.beginPath();
|
|
184
|
+
ctx2d.strokeStyle = color;
|
|
185
|
+
ctx2d.lineWidth = 2;
|
|
186
|
+
const beat = parseFloat(beatInput?.value ?? '4');
|
|
187
|
+
for (let x = 0; x < canvas.width; x++) {
|
|
188
|
+
const mod = ampMod * Math.sin(x * 0.02 + time * beat);
|
|
189
|
+
const y = canvas.height / 2 + Math.sin(x * 0.05 + time * freqMult) * (20 + mod);
|
|
190
|
+
if (x === 0) ctx2d.moveTo(x, y);
|
|
191
|
+
else ctx2d.lineTo(x, y);
|
|
192
|
+
}
|
|
193
|
+
ctx2d.stroke();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function animate() {
|
|
197
|
+
if (!ctx2d || !canvas) return;
|
|
198
|
+
ctx2d.clearRect(0, 0, canvas.width, canvas.height);
|
|
199
|
+
const time = Date.now() * 0.002;
|
|
200
|
+
const base = parseFloat(baseInput?.value ?? '200');
|
|
201
|
+
drawWave('rgba(112,0,255,0.8)', base / 100, 0, time);
|
|
202
|
+
drawWave('rgba(0,242,255,0.8)', base / 100, 40, time);
|
|
203
|
+
requestAnimationFrame(animate);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function setIconState(playing: boolean) {
|
|
207
|
+
toggleBtn?.classList.toggle('bt__play-btn--playing', playing);
|
|
208
|
+
playIcon?.classList.toggle('bt__play-svg--hidden', playing);
|
|
209
|
+
stopIcon?.classList.toggle('bt__play-svg--hidden', !playing);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function toggleAudio() {
|
|
213
|
+
if (!isPlaying) {
|
|
214
|
+
if (!audioCtx) initAudio();
|
|
215
|
+
else if (audioCtx.state === 'suspended') audioCtx.resume();
|
|
216
|
+
isPlaying = true;
|
|
217
|
+
} else {
|
|
218
|
+
audioCtx?.suspend();
|
|
219
|
+
isPlaying = false;
|
|
220
|
+
}
|
|
221
|
+
setIconState(isPlaying);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function applyPreset(btn: HTMLButtonElement) {
|
|
225
|
+
container?.querySelectorAll<HTMLButtonElement>('.bt__preset-btn').forEach((b) => {
|
|
226
|
+
b.classList.remove('bt__preset-btn--active');
|
|
227
|
+
});
|
|
228
|
+
btn.classList.add('bt__preset-btn--active');
|
|
229
|
+
if (baseInput && btn.dataset.base) baseInput.value = btn.dataset.base;
|
|
230
|
+
if (beatInput && btn.dataset.beat) beatInput.value = btn.dataset.beat;
|
|
231
|
+
updateLabels();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function resizeCanvas() {
|
|
235
|
+
if (!canvas) return;
|
|
236
|
+
canvas.width = canvas.parentElement?.clientWidth ?? 0;
|
|
237
|
+
canvas.height = canvas.parentElement?.clientHeight ?? 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
baseInput?.addEventListener('input', updateLabels);
|
|
241
|
+
beatInput?.addEventListener('input', updateLabels);
|
|
242
|
+
toggleBtn?.addEventListener('click', toggleAudio);
|
|
243
|
+
strobeBtn?.addEventListener('click', () => {
|
|
244
|
+
isStrobeActive = !isStrobeActive;
|
|
245
|
+
strobeBtn.classList.toggle('bt__strobe-btn--active', isStrobeActive);
|
|
246
|
+
updateStrobe();
|
|
247
|
+
});
|
|
248
|
+
container?.querySelectorAll<HTMLButtonElement>('.bt__preset-btn').forEach((btn) => {
|
|
249
|
+
btn.addEventListener('click', () => applyPreset(btn));
|
|
250
|
+
});
|
|
251
|
+
window.addEventListener('resize', resizeCanvas);
|
|
252
|
+
resizeCanvas();
|
|
253
|
+
</script>
|
|
254
|
+
|
|
255
|
+
<style>
|
|
256
|
+
|
|
257
|
+
.bt {
|
|
258
|
+
--bt-bg: #f5f0ff;
|
|
259
|
+
--bt-primary: #7000ff;
|
|
260
|
+
--bt-secondary: #0ad;
|
|
261
|
+
--bt-accent: #c0c;
|
|
262
|
+
--bt-text: #1a003d;
|
|
263
|
+
--bt-glass: rgba(112, 0, 255, 0.04);
|
|
264
|
+
--bt-glass-border: rgba(112, 0, 255, 0.18);
|
|
265
|
+
--bt-muted: rgba(26, 0, 61, 0.5);
|
|
266
|
+
--bt-range-track: rgba(112, 0, 255, 0.08);
|
|
267
|
+
--bt-range-track-border: rgba(112, 0, 255, 0.18);
|
|
268
|
+
--bt-preset-color: rgba(26, 0, 61, 0.7);
|
|
269
|
+
--bt-warning-bg: rgba(220, 38, 38, 0.05);
|
|
270
|
+
--bt-warning-border: rgba(220, 38, 38, 0.18);
|
|
271
|
+
--bt-warning-text: rgba(26, 0, 61, 0.6);
|
|
272
|
+
--bt-warning-strong: #dc2626;
|
|
273
|
+
--bt-strobe-border: rgba(112, 0, 255, 0.2);
|
|
274
|
+
--bt-strobe-color: #1a003d;
|
|
275
|
+
--bt-visualizer-bg: rgba(3, 4, 22, 0.88);
|
|
276
|
+
--bt-shadow: 0 8px 32px rgba(112, 0, 255, 0.15);
|
|
277
|
+
|
|
278
|
+
max-width: 56rem;
|
|
279
|
+
margin: 0 auto;
|
|
280
|
+
padding: 0 1rem;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
:global(.theme-dark) .bt {
|
|
285
|
+
--bt-bg: #030416;
|
|
286
|
+
--bt-secondary: #00f2ff;
|
|
287
|
+
--bt-accent: #f0f;
|
|
288
|
+
--bt-text: #fff;
|
|
289
|
+
--bt-glass: rgba(255, 255, 255, 0.03);
|
|
290
|
+
--bt-glass-border: rgba(255, 255, 255, 0.1);
|
|
291
|
+
--bt-muted: rgba(255, 255, 255, 0.5);
|
|
292
|
+
--bt-range-track: rgba(255, 255, 255, 0.05);
|
|
293
|
+
--bt-range-track-border: rgba(255, 255, 255, 0.1);
|
|
294
|
+
--bt-preset-color: rgba(255, 255, 255, 0.7);
|
|
295
|
+
--bt-warning-bg: rgba(255, 0, 0, 0.05);
|
|
296
|
+
--bt-warning-border: rgba(255, 0, 0, 0.1);
|
|
297
|
+
--bt-warning-text: rgba(255, 255, 255, 0.5);
|
|
298
|
+
--bt-warning-strong: rgba(255, 100, 100, 1);
|
|
299
|
+
--bt-strobe-border: rgba(255, 255, 255, 0.1);
|
|
300
|
+
--bt-strobe-color: #fff;
|
|
301
|
+
--bt-visualizer-bg: rgba(0, 0, 0, 0.3);
|
|
302
|
+
--bt-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
.bt__card {
|
|
307
|
+
background: var(--bt-bg);
|
|
308
|
+
border: 1px solid var(--bt-glass-border);
|
|
309
|
+
border-radius: 2rem;
|
|
310
|
+
padding: 2rem 1.5rem;
|
|
311
|
+
box-shadow: var(--bt-shadow);
|
|
312
|
+
display: flex;
|
|
313
|
+
flex-direction: column;
|
|
314
|
+
gap: 2.5rem;
|
|
315
|
+
position: relative;
|
|
316
|
+
overflow: hidden;
|
|
317
|
+
backdrop-filter: blur(20px);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@media (min-width: 768px) {
|
|
321
|
+
.bt__card {
|
|
322
|
+
padding: 3rem;
|
|
323
|
+
border-radius: 2.5rem;
|
|
324
|
+
gap: 3rem;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.bt__card::before {
|
|
329
|
+
content: '';
|
|
330
|
+
position: absolute;
|
|
331
|
+
top: -10%;
|
|
332
|
+
right: -10%;
|
|
333
|
+
width: 40%;
|
|
334
|
+
height: 40%;
|
|
335
|
+
background: radial-gradient(circle, rgba(112, 0, 255, 0.12) 0%, transparent 70%);
|
|
336
|
+
pointer-events: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
:global(.theme-dark) .bt__card::before {
|
|
340
|
+
background: radial-gradient(circle, rgba(112, 0, 255, 0.15) 0%, transparent 70%);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.bt__card::after {
|
|
344
|
+
content: '';
|
|
345
|
+
position: absolute;
|
|
346
|
+
bottom: -10%;
|
|
347
|
+
left: -10%;
|
|
348
|
+
width: 40%;
|
|
349
|
+
height: 40%;
|
|
350
|
+
background: radial-gradient(circle, rgba(0, 170, 221, 0.1) 0%, transparent 70%);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
:global(.theme-dark) .bt__card::after {
|
|
354
|
+
background: radial-gradient(circle, rgba(0, 242, 255, 0.1) 0%, transparent 70%);
|
|
355
|
+
pointer-events: none;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
.bt__controls-grid {
|
|
360
|
+
display: grid;
|
|
361
|
+
gap: 2rem;
|
|
362
|
+
position: relative;
|
|
363
|
+
z-index: 1;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
@media (min-width: 640px) {
|
|
367
|
+
.bt__controls-grid {
|
|
368
|
+
grid-template-columns: 1fr 1fr;
|
|
369
|
+
gap: 3rem;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.bt__control-group {
|
|
374
|
+
display: flex;
|
|
375
|
+
flex-direction: column;
|
|
376
|
+
gap: 1.5rem;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.bt__control-header {
|
|
380
|
+
display: flex;
|
|
381
|
+
justify-content: space-between;
|
|
382
|
+
align-items: flex-end;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.bt__control-label {
|
|
386
|
+
font-weight: 700;
|
|
387
|
+
font-size: 0.75rem;
|
|
388
|
+
text-transform: uppercase;
|
|
389
|
+
letter-spacing: 0.15em;
|
|
390
|
+
color: var(--bt-muted);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.bt__value-display {
|
|
394
|
+
font-size: 2.25rem;
|
|
395
|
+
font-weight: 900;
|
|
396
|
+
color: var(--bt-text);
|
|
397
|
+
line-height: 1;
|
|
398
|
+
text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
@media (min-width: 768px) {
|
|
402
|
+
.bt__value-display {
|
|
403
|
+
font-size: 2.5rem;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.bt__value-unit {
|
|
408
|
+
font-size: 1rem;
|
|
409
|
+
font-weight: 400;
|
|
410
|
+
margin-left: 0.25rem;
|
|
411
|
+
opacity: 0.6;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
.bt__range {
|
|
416
|
+
-webkit-appearance: none;
|
|
417
|
+
appearance: none;
|
|
418
|
+
width: 100%;
|
|
419
|
+
background: transparent;
|
|
420
|
+
cursor: pointer;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.bt__range::-webkit-slider-runnable-track {
|
|
424
|
+
height: 8px;
|
|
425
|
+
background: var(--bt-range-track);
|
|
426
|
+
border-radius: 4px;
|
|
427
|
+
border: 1px solid var(--bt-range-track-border);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.bt__range::-webkit-slider-thumb {
|
|
431
|
+
-webkit-appearance: none;
|
|
432
|
+
appearance: none;
|
|
433
|
+
height: 24px;
|
|
434
|
+
width: 24px;
|
|
435
|
+
background: var(--bt-text);
|
|
436
|
+
border-radius: 50%;
|
|
437
|
+
margin-top: -9px;
|
|
438
|
+
box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
|
|
439
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
.bt__range::-webkit-slider-thumb:hover {
|
|
443
|
+
transform: scale(1.1);
|
|
444
|
+
box-shadow: 0 0 20px var(--bt-secondary);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
.bt__range::-moz-range-track {
|
|
448
|
+
height: 8px;
|
|
449
|
+
background: var(--bt-range-track);
|
|
450
|
+
border-radius: 4px;
|
|
451
|
+
border: 1px solid var(--bt-range-track-border);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.bt__range::-moz-range-thumb {
|
|
455
|
+
height: 24px;
|
|
456
|
+
width: 24px;
|
|
457
|
+
background: var(--bt-text);
|
|
458
|
+
border-radius: 50%;
|
|
459
|
+
border: none;
|
|
460
|
+
box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
.bt__presets-wrap {
|
|
465
|
+
display: flex;
|
|
466
|
+
flex-direction: column;
|
|
467
|
+
gap: 1rem;
|
|
468
|
+
align-items: center;
|
|
469
|
+
position: relative;
|
|
470
|
+
z-index: 1;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.bt__beat-desc {
|
|
474
|
+
background: linear-gradient(90deg, var(--bt-primary), var(--bt-secondary));
|
|
475
|
+
-webkit-background-clip: text;
|
|
476
|
+
background-clip: text;
|
|
477
|
+
-webkit-text-fill-color: transparent;
|
|
478
|
+
font-weight: 600;
|
|
479
|
+
font-size: 1rem;
|
|
480
|
+
text-align: center;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.bt__presets {
|
|
484
|
+
display: flex;
|
|
485
|
+
flex-wrap: wrap;
|
|
486
|
+
gap: 0.75rem;
|
|
487
|
+
justify-content: center;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
.bt__preset-btn {
|
|
491
|
+
background: var(--bt-glass);
|
|
492
|
+
border: 1px solid var(--bt-glass-border);
|
|
493
|
+
color: var(--bt-preset-color);
|
|
494
|
+
padding: 0.625rem 1.25rem;
|
|
495
|
+
border-radius: 100px;
|
|
496
|
+
font-size: 0.85rem;
|
|
497
|
+
font-weight: 600;
|
|
498
|
+
cursor: pointer;
|
|
499
|
+
transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
@media (max-width: 640px) {
|
|
503
|
+
.bt__preset-btn {
|
|
504
|
+
padding: 0.5rem 0.75rem;
|
|
505
|
+
font-size: 0.75rem;
|
|
506
|
+
flex: 1 1 auto;
|
|
507
|
+
text-align: center;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.bt__preset-btn:hover {
|
|
512
|
+
border-color: var(--bt-secondary);
|
|
513
|
+
color: var(--bt-secondary);
|
|
514
|
+
background: rgba(0, 242, 255, 0.05);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.bt__preset-btn--active {
|
|
518
|
+
background: var(--bt-text);
|
|
519
|
+
color: var(--bt-bg);
|
|
520
|
+
border-color: var(--bt-text);
|
|
521
|
+
transform: scale(1.05);
|
|
522
|
+
box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
.bt__actions {
|
|
527
|
+
display: flex;
|
|
528
|
+
align-items: center;
|
|
529
|
+
justify-content: center;
|
|
530
|
+
gap: 2.5rem;
|
|
531
|
+
margin: 0.5rem 0;
|
|
532
|
+
position: relative;
|
|
533
|
+
z-index: 1;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
@media (max-width: 640px) {
|
|
537
|
+
.bt__actions {
|
|
538
|
+
flex-direction: column;
|
|
539
|
+
gap: 1rem;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.bt__play-btn {
|
|
544
|
+
width: 6rem;
|
|
545
|
+
height: 6rem;
|
|
546
|
+
border-radius: 50%;
|
|
547
|
+
background: var(--bt-text);
|
|
548
|
+
border: none;
|
|
549
|
+
display: flex;
|
|
550
|
+
align-items: center;
|
|
551
|
+
justify-content: center;
|
|
552
|
+
cursor: pointer;
|
|
553
|
+
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
554
|
+
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
|
555
|
+
flex-shrink: 0;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
@media (max-width: 640px) {
|
|
559
|
+
.bt__play-btn {
|
|
560
|
+
width: 5rem;
|
|
561
|
+
height: 5rem;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
.bt__play-btn:hover {
|
|
566
|
+
transform: scale(1.1);
|
|
567
|
+
box-shadow: 0 0 40px rgba(255, 255, 255, 0.4);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
.bt__play-btn--playing {
|
|
571
|
+
background: var(--bt-accent);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.bt__play-svg {
|
|
575
|
+
width: 2.5rem;
|
|
576
|
+
height: 2.5rem;
|
|
577
|
+
fill: var(--bt-bg);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.bt__play-btn--playing .bt__play-svg {
|
|
581
|
+
fill: white;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.bt__play-svg--hidden {
|
|
585
|
+
display: none;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
.bt__strobe-btn {
|
|
589
|
+
background: transparent;
|
|
590
|
+
border: 2px solid var(--bt-strobe-border);
|
|
591
|
+
color: var(--bt-strobe-color);
|
|
592
|
+
padding: 1rem 2rem;
|
|
593
|
+
border-radius: 100px;
|
|
594
|
+
font-weight: 700;
|
|
595
|
+
text-transform: uppercase;
|
|
596
|
+
letter-spacing: 0.05em;
|
|
597
|
+
cursor: pointer;
|
|
598
|
+
transition: all 0.3s ease;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
@media (max-width: 640px) {
|
|
602
|
+
.bt__strobe-btn {
|
|
603
|
+
padding: 0.75rem 1rem;
|
|
604
|
+
font-size: 0.85rem;
|
|
605
|
+
width: 100%;
|
|
606
|
+
box-sizing: border-box;
|
|
607
|
+
text-align: center;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
.bt__strobe-btn:hover {
|
|
612
|
+
border-color: var(--bt-secondary);
|
|
613
|
+
background: rgba(0, 242, 255, 0.05);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.bt__strobe-btn--active {
|
|
617
|
+
background: var(--bt-secondary);
|
|
618
|
+
border-color: var(--bt-secondary);
|
|
619
|
+
color: var(--bt-bg);
|
|
620
|
+
box-shadow: 0 0 25px rgba(0, 242, 255, 0.4);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
.bt__visualizer {
|
|
625
|
+
width: 100%;
|
|
626
|
+
height: 12rem;
|
|
627
|
+
background: var(--bt-visualizer-bg);
|
|
628
|
+
border-radius: 1.5rem;
|
|
629
|
+
position: relative;
|
|
630
|
+
overflow: hidden;
|
|
631
|
+
border: 1px solid rgba(255, 255, 255, 0.05);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
@media (max-width: 640px) {
|
|
635
|
+
.bt__visualizer {
|
|
636
|
+
height: 7.5rem;
|
|
637
|
+
border-radius: 1rem;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.bt__strobe {
|
|
642
|
+
position: absolute;
|
|
643
|
+
inset: 0;
|
|
644
|
+
background: white;
|
|
645
|
+
opacity: 0;
|
|
646
|
+
pointer-events: none;
|
|
647
|
+
z-index: 2;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.bt__strobe--active {
|
|
651
|
+
animation: bt-strobe var(--bt-strobe-duration, 0.25s) infinite;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
@keyframes bt-strobe {
|
|
655
|
+
0% { opacity: 0.9; }
|
|
656
|
+
2% { opacity: 0; }
|
|
657
|
+
100% { opacity: 0; }
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.bt__canvas {
|
|
661
|
+
width: 100%;
|
|
662
|
+
height: 100%;
|
|
663
|
+
filter: blur(2px);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
.bt__warning {
|
|
668
|
+
background: var(--bt-warning-bg);
|
|
669
|
+
border: 1px solid var(--bt-warning-border);
|
|
670
|
+
padding: 1.25rem;
|
|
671
|
+
border-radius: 1rem;
|
|
672
|
+
font-size: 0.8rem;
|
|
673
|
+
color: var(--bt-warning-text);
|
|
674
|
+
line-height: 1.6;
|
|
675
|
+
position: relative;
|
|
676
|
+
z-index: 1;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
.bt__warning-title {
|
|
680
|
+
color: var(--bt-warning-strong);
|
|
681
|
+
text-transform: uppercase;
|
|
682
|
+
letter-spacing: 0.05em;
|
|
683
|
+
display: block;
|
|
684
|
+
margin-bottom: 0.5rem;
|
|
685
|
+
font-size: 0.75rem;
|
|
686
|
+
}
|
|
687
|
+
</style>
|