@arraypress/waveform-player 1.13.1 → 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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arraypress/waveform-player",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "Lightweight, customizable audio player with waveform visualization",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -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;
@@ -59,11 +63,11 @@
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
65
  on every play/pause. Fixed width keeps the canvas (and bars) stable.
62
- Sized so the bare glyph reads at the same visual weight as the 36px
63
- circle button (the glyph, not a ring, is the whole control here). */
64
- width: 2.5rem;
65
- height: 2.5rem;
66
- min-width: 2.5rem;
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);
67
71
  border: none;
68
72
  border-radius: 0;
69
73
  opacity: 0.7;
@@ -74,9 +78,12 @@
74
78
  transform: none;
75
79
  }
76
80
 
77
- .waveform-btn-minimal svg {
78
- width: 36px;
79
- height: 36px;
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);
80
87
  }
81
88
 
82
89
  .waveform-btn:disabled {
@@ -94,8 +101,8 @@
94
101
  }
95
102
 
96
103
  .waveform-btn svg {
97
- width: 16px;
98
- height: 16px;
104
+ width: calc(var(--wfp-btn-size, 36px) * 0.45);
105
+ height: calc(var(--wfp-btn-size, 36px) * 0.45);
99
106
  fill: currentColor;
100
107
  display: block;
101
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;