Skip to content

Commit 0d9ab1e

Browse files
committed
fix: cleanup and fix mobile view
1 parent 349711f commit 0d9ab1e

7 files changed

Lines changed: 70 additions & 26 deletions

File tree

packages/audiodocs/src/audio/Equalizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class Equalizer {
1414
const filter = audioContext.createBiquadFilter();
1515
filter.type = frequencies[i].type;
1616
filter.frequency.value = frequencies[i].frequency;
17-
// filter.Q.value = 1;
17+
filter.Q.value = 1;
1818
filter.gain.value = 0;
1919
return filter;
2020
});

packages/audiodocs/src/canvasUtils/drawEQControlPoints.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,31 @@ export default function drawEQControlPoints(
1818
const controlPointSize = 48;
1919
const halfSize = controlPointSize / 2;
2020

21-
// Draw control points for each equalizer band
2221
frequencies.forEach((freqConfig, index) => {
2322
if (AudioManager.equalizer && AudioManager.equalizer.bands[index]) {
2423
const band = AudioManager.equalizer.bands[index];
2524
const frequency = freqConfig.frequency;
26-
27-
// Get current gain value in dB
2825
const gainValue = band.gain.value;
2926

30-
// Calculate X position based on frequency (logarithmic scale)
3127
const logFreq = Math.log10(frequency);
3228
const normalizedPos = (logFreq - logMin) / (logMax - logMin);
3329
let posX = x + (normalizedPos * width);
3430

35-
// Apply custom positioning:
36-
// Points 1,2,5 keep their current positions, point 3 goes to center + 96px, point 4 reflects point 2
3731
if (index === 0) {
38-
posX += 96; // Point 1 (index 0) - keep current position
32+
posX += 96;
3933
} else if (index === 1) {
40-
posX += 66; // Point 2 (index 1) - keep current position
34+
posX += 66;
4135
} else if (index === 2) {
42-
posX = x + width / 2 + 59; // Point 3 (index 2) - center + 86px to the right
36+
posX = x + width / 2 + 59;
4337
} else if (index === 3) {
44-
// Point 4 (index 3) - reflect point 2's position
45-
posX -= 18; // Reflect point 2's position
38+
posX -= 18;
4639
} else {
47-
posX -= 96; // Point 5 (index 4) - keep current position
40+
posX -= 96;
4841
}
4942

50-
// Calculate Y position based on gain value
51-
// Assuming ±12dB range for display
52-
const normalizedGain = gainValue / 12; // -1 to 1 range
43+
const normalizedGain = gainValue / 12;
5344
const posY = y + height / 2 - (normalizedGain * height / 2);
5445

55-
// Draw outer circle (border)
5646
ctx.beginPath();
5747
ctx.arc(posX, posY, halfSize, 0, Math.PI * 2);
5848
ctx.fillStyle = fillColor;

packages/audiodocs/src/components/LandingWidget/SoundButton/styles.module.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,13 @@
5252
[data-theme='dark'] .soundButtonActive .soundButtonName {
5353
color: var(--swm-navy-dark-100);
5454
}
55+
56+
57+
@media (max-width: 768px) {
58+
.soundButtonInactive,
59+
.soundButtonActive,
60+
.soundButtonDisabled {
61+
padding: 15px 12px;
62+
margin: 0;
63+
}
64+
}

packages/audiodocs/src/components/LandingWidget/Toolbar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Toolbar: React.FC<ToolbarProps> = (props) => {
3939

4040
return (
4141
<div className={styles.toolbar}>
42-
<div>
42+
<div className={styles.soundButtons}>
4343
{soundButtons.map(renderButton)}
4444
</div>
4545
<div>

packages/audiodocs/src/components/LandingWidget/Toolbar/styles.module.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@
44
margin-bottom: 12px;
55
}
66

7-
87
.eqButton {
98
padding: 15px 16px;
109
border: none;
1110
margin-right: 8px;
1211
cursor: pointer;
1312
}
1413

14+
@media (max-width: 768px) {
15+
.eqButton {
16+
display: none;
17+
}
18+
19+
.toolbar {
20+
width: 100%;
21+
}
22+
23+
.soundButtons {
24+
display: flex;
25+
justify-content: space-between;
26+
width: 100%;
27+
margin-top: 12px;
28+
}
29+
}
30+
1531
.eqButtonText {
1632
font-size: 16px;
1733
font-weight: 400;

packages/audiodocs/src/components/LandingWidget/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,31 @@ const LandingWidget: React.FC = () => {
9292

9393
return (
9494
<div className={styles.container}>
95-
<Toolbar
96-
isLoading={isLoading}
97-
soundButtons={buttons}
98-
onPlaySound={onPlaySound}
99-
displayType={displayType}
100-
onSetDisplayType={setDisplayType}
101-
/>
95+
<div className={styles.toolbarDesktop}>
96+
<Toolbar
97+
isLoading={isLoading}
98+
soundButtons={buttons}
99+
onPlaySound={onPlaySound}
100+
displayType={displayType}
101+
onSetDisplayType={setDisplayType}
102+
/>
103+
</div>
102104

103105
{displayType === 'equalizer' ? (
104106
<Equalizer />
105107
) : (
106108
<Spectrogram />
107109
)}
110+
111+
<div className={styles.toolbarMobile}>
112+
<Toolbar
113+
isLoading={isLoading}
114+
soundButtons={buttons}
115+
onPlaySound={onPlaySound}
116+
displayType={displayType}
117+
onSetDisplayType={setDisplayType}
118+
/>
119+
</div>
108120
</div>
109121
);
110122
}

packages/audiodocs/src/components/LandingWidget/styles.module.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,19 @@
22
.container {
33
position: relative;
44
}
5+
6+
.toolbarMobile {
7+
display: none;
8+
}
9+
10+
@media (max-width: 768px) {
11+
.toolbarMobile {
12+
display: flex;
13+
justify-content: space-between;
14+
margin-bottom: 12px;
15+
}
16+
17+
.toolbarDesktop {
18+
display: none;
19+
}
20+
}

0 commit comments

Comments
 (0)