@arraypress/waveform-player 1.13.0 → 1.14.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/dist/waveform-player.cjs +10 -0
- package/dist/waveform-player.cjs.map +2 -2
- package/dist/waveform-player.css +1 -1
- package/dist/waveform-player.esm.js +3 -2
- package/dist/waveform-player.esm.js.map +3 -3
- package/dist/waveform-player.js +10 -0
- package/dist/waveform-player.min.js +3 -2
- package/dist/waveform-player.min.js.map +3 -3
- package/index.d.ts +7 -0
- package/package.json +1 -1
- package/src/css/waveform-player.css +22 -13
- package/src/js/core.js +1 -0
- package/src/js/themes.js +5 -0
- package/src/js/utils.js +6 -0
package/index.d.ts
CHANGED
|
@@ -139,6 +139,13 @@ export interface WaveformPlayerOptions {
|
|
|
139
139
|
* @default 'circle'
|
|
140
140
|
*/
|
|
141
141
|
buttonStyle?: 'circle' | 'minimal';
|
|
142
|
+
/**
|
|
143
|
+
* Play/pause button size. A number is treated as px; a string (e.g. `'4rem'`)
|
|
144
|
+
* is used verbatim. Sets the `--wfp-btn-size` CSS variable, scaling both the
|
|
145
|
+
* `circle` and `minimal` styles — box and glyph — proportionally.
|
|
146
|
+
* @default null
|
|
147
|
+
*/
|
|
148
|
+
buttonSize?: number | string | null;
|
|
142
149
|
/** Show transport controls. @default true */
|
|
143
150
|
showControls?: boolean;
|
|
144
151
|
/** Show the info (title/subtitle) block. @default true */
|
package/package.json
CHANGED
|
@@ -27,11 +27,15 @@
|
|
|
27
27
|
position: relative;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/* Play button
|
|
30
|
+
/* Play button.
|
|
31
|
+
Size knob: set `--wfp-btn-size` (via the `buttonSize` option /
|
|
32
|
+
`data-button-size`) to scale BOTH button styles — box AND glyph —
|
|
33
|
+
proportionally. Defaults to 36px; every dimension below derives from it so
|
|
34
|
+
there is a single source of truth (no per-style magic numbers to drift). */
|
|
31
35
|
.waveform-btn {
|
|
32
|
-
width: 36px;
|
|
33
|
-
height: 36px;
|
|
34
|
-
min-width: 36px;
|
|
36
|
+
width: var(--wfp-btn-size, 36px);
|
|
37
|
+
height: var(--wfp-btn-size, 36px);
|
|
38
|
+
min-width: var(--wfp-btn-size, 36px);
|
|
35
39
|
border-radius: 50%;
|
|
36
40
|
border: 2px solid currentColor;
|
|
37
41
|
background: transparent;
|
|
@@ -58,10 +62,12 @@
|
|
|
58
62
|
/* A FIXED box is essential: toggling the play glyph (which is optically
|
|
59
63
|
nudged 1px) for the pause glyph would otherwise change the button's
|
|
60
64
|
auto width, shifting the adjacent waveform — and re-sampling its bars —
|
|
61
|
-
on every play/pause. Fixed width keeps the canvas (and bars) stable.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
on every play/pause. Fixed width keeps the canvas (and bars) stable.
|
|
66
|
+
Sized (1.1×) so the bare glyph reads at the same visual weight as the
|
|
67
|
+
circle button — the glyph, not a ring, is the whole control here. */
|
|
68
|
+
width: calc(var(--wfp-btn-size, 36px) * 1.1);
|
|
69
|
+
height: calc(var(--wfp-btn-size, 36px) * 1.1);
|
|
70
|
+
min-width: calc(var(--wfp-btn-size, 36px) * 1.1);
|
|
65
71
|
border: none;
|
|
66
72
|
border-radius: 0;
|
|
67
73
|
opacity: 0.7;
|
|
@@ -72,9 +78,12 @@
|
|
|
72
78
|
transform: none;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
/* NOTE: must out-specify `.waveform-btn svg { width:16px }` below — that rule
|
|
82
|
+
has equal specificity but later source order, so it was pinning the minimal
|
|
83
|
+
glyph to 16px. The compound `.waveform-btn.waveform-btn-minimal` wins. */
|
|
84
|
+
.waveform-btn.waveform-btn-minimal svg {
|
|
85
|
+
width: calc(var(--wfp-btn-size, 36px) * 0.94);
|
|
86
|
+
height: calc(var(--wfp-btn-size, 36px) * 0.94);
|
|
78
87
|
}
|
|
79
88
|
|
|
80
89
|
.waveform-btn:disabled {
|
|
@@ -92,8 +101,8 @@
|
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
.waveform-btn svg {
|
|
95
|
-
width:
|
|
96
|
-
height:
|
|
104
|
+
width: calc(var(--wfp-btn-size, 36px) * 0.45);
|
|
105
|
+
height: calc(var(--wfp-btn-size, 36px) * 0.45);
|
|
97
106
|
fill: currentColor;
|
|
98
107
|
display: block;
|
|
99
108
|
}
|
package/src/js/core.js
CHANGED
|
@@ -246,6 +246,7 @@ export class WaveformPlayer {
|
|
|
246
246
|
<button class="waveform-btn${this.options.buttonStyle === 'minimal' ? ' waveform-btn-minimal' : ''}" aria-label="Play/Pause" style="
|
|
247
247
|
border-color: ${this.options.buttonColor};
|
|
248
248
|
color: ${this.options.buttonColor};
|
|
249
|
+
${this.options.buttonSize != null ? `--wfp-btn-size: ${typeof this.options.buttonSize === 'number' ? `${this.options.buttonSize}px` : this.options.buttonSize};` : ''}
|
|
249
250
|
">
|
|
250
251
|
<span class="waveform-icon-play">${this.options.playIcon}</span>
|
|
251
252
|
<span class="waveform-icon-pause" style="display:none;">${this.options.pauseIcon}</span>
|
package/src/js/themes.js
CHANGED
|
@@ -181,6 +181,11 @@ export const DEFAULT_OPTIONS = {
|
|
|
181
181
|
// 'minimal' = a bare play/pause glyph with no circle — the look sample-pack
|
|
182
182
|
// and beat stores use in their preview grids.
|
|
183
183
|
buttonStyle: 'circle',
|
|
184
|
+
// Play/pause button size. null = the stylesheet default (36px circle /
|
|
185
|
+
// proportional minimal). A number is treated as px; a string (e.g. '4rem')
|
|
186
|
+
// is used verbatim. Sets the `--wfp-btn-size` CSS var, which scales BOTH
|
|
187
|
+
// styles — box and glyph — proportionally.
|
|
188
|
+
buttonSize: null,
|
|
184
189
|
|
|
185
190
|
// Default waveform style
|
|
186
191
|
waveformStyle: 'mirror',
|
package/src/js/utils.js
CHANGED
|
@@ -139,6 +139,12 @@ export function parseDataAttributes(element) {
|
|
|
139
139
|
if (element.dataset.buttonAlign) options.buttonAlign = element.dataset.buttonAlign;
|
|
140
140
|
if (element.dataset.layout) options.layout = element.dataset.layout;
|
|
141
141
|
if (element.dataset.buttonStyle) options.buttonStyle = element.dataset.buttonStyle;
|
|
142
|
+
// buttonSize: a bare number is px (data-button-size="64"); a unit string
|
|
143
|
+
// (e.g. "4rem") is kept verbatim.
|
|
144
|
+
if (element.dataset.buttonSize) {
|
|
145
|
+
const bs = element.dataset.buttonSize;
|
|
146
|
+
options.buttonSize = /^\d+(\.\d+)?$/.test(bs.trim()) ? parseFloat(bs) : bs;
|
|
147
|
+
}
|
|
142
148
|
|
|
143
149
|
// Color preset
|
|
144
150
|
if (element.dataset.colorPreset) options.colorPreset = element.dataset.colorPreset;
|