@dsebastien/music-notation 0.13.0 → 0.15.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.
@@ -14,6 +14,11 @@ export interface KeyboardOptions {
14
14
  playAs?: 'chord' | 'scale';
15
15
  /** Which hand plays each key (MIDI → left or right): a bracket and LH or RH under each hand's keys. */
16
16
  hands?: Map<number, 'left' | 'right'>;
17
+ /**
18
+ * The pick layer (Music Practice #73): every key is a target with its note and pitch, drawn
19
+ * above the keys and labels; `attachPick` makes it live. Off by default.
20
+ */
21
+ pick?: boolean;
17
22
  }
18
23
  /** "C3-B4" → MIDI range; null when invalid. */
19
24
  export declare function parseKeyRange(text: string): [number, number] | null;
@@ -22,6 +22,10 @@
22
22
  mid-grey black key, in every theme. */
23
23
  --mn-key-white-faint: #d4d4d8;
24
24
  --mn-key-black-faint: #8c8c8c;
25
+ /* Marks of the pick layer (Music Practice #73): right and wrong, dark enough for a white check
26
+ or cross in light and dark themes; the shape tells them apart too. */
27
+ --mn-right: #15803d;
28
+ --mn-wrong: #b91c1c;
25
29
  font-family: var(--font-interface, system-ui, sans-serif);
26
30
  }
27
31
 
@@ -84,14 +88,38 @@
84
88
  stroke-width: 2;
85
89
  }
86
90
 
87
- /* Playback: a compact strip at the bottom of the diagram, shown on hover, keyboard focus or a
88
- tap. Host styles (Obsidian's buttons, selects and sliders) are reset inside it. */
91
+ /* Playback (#58): a playable diagram is a button (a click plays it); one bar below the block
92
+ plays its diagrams. Host styles (Obsidian's buttons, selects and sliders) are reset inside the
93
+ bars. */
89
94
  .mn-playable {
90
95
  position: relative;
91
96
  display: inline-block;
97
+ /* No line-box gap under the drawing, before the bar. */
98
+ vertical-align: top;
92
99
  max-width: 100%;
100
+ border-radius: 6px;
101
+ }
102
+
103
+ /* The selected diagram of a row (the one the bar plays and names) and the focused one: outlines
104
+ drawn inside the edge (the block's scroll box, overflow-x, never cuts them) and over the
105
+ drawing (keys and chips reach the edge), kept in forced-colors mode. */
106
+ .mn-playable.mn-selected {
107
+ outline: 2px solid color-mix(in srgb, var(--mn-accent) 45%, transparent);
108
+ outline-offset: -2px;
109
+ }
110
+
111
+ .mn-playable:focus-visible {
112
+ outline: 2px solid var(--mn-accent);
113
+ outline-offset: -2px;
93
114
  }
94
115
 
116
+ /* A mouse click focuses the diagram too: only the selection shows then. */
117
+ .mn-playable:focus:not(:focus-visible):not(.mn-selected) {
118
+ outline: none;
119
+ }
120
+
121
+ /* The tab and score bar (#82 gives it the block bar's look): a strip at the bottom of the score,
122
+ shown on hover, keyboard focus or a tap. */
95
123
  .mn-play {
96
124
  position: absolute;
97
125
  left: 2px;
@@ -114,13 +142,6 @@
114
142
  transition: opacity 120ms ease;
115
143
  }
116
144
 
117
- .mn-playable:hover .mn-play,
118
- .mn-playable:focus-within .mn-play,
119
- .mn-playable.mn-play-open .mn-play {
120
- opacity: 1;
121
- pointer-events: auto;
122
- }
123
-
124
145
  .mn-play button,
125
146
  .mn-play select {
126
147
  all: unset;
@@ -134,9 +155,80 @@
134
155
  font-size: 10px;
135
156
  color: inherit;
136
157
  border-radius: 4px;
158
+ }
159
+
160
+ /* The hand on everything that plays or sets something (#81), with a class in every selector so it
161
+ outranks host element rules such as Obsidian's `button { cursor: var(--cursor) }`, and again
162
+ under `.mn-block` for hosts with class rules; no !important. Without playback there is no
163
+ .mn-playable: diagrams and notes keep the arrow. */
164
+ .mn-playable,
165
+ .mn-playable *,
166
+ .mn-play button,
167
+ .mn-play select,
168
+ .mn-play input[type='range'],
169
+ .mn-svg .mn-pick[role='button'],
170
+ .mn-block .mn-pick[role='button'],
171
+ .mn-block .mn-playable,
172
+ .mn-block .mn-playable *,
173
+ .mn-block .mn-play button,
174
+ .mn-block .mn-play select,
175
+ .mn-block .mn-play input[type='range'] {
137
176
  cursor: pointer;
138
177
  }
139
178
 
179
+ /* The pick layer (Music Practice #73): a live target (role button, set by attachPick) shows only
180
+ when hovered (a faint fill) or focused by the keyboard (a ring inside its cell); white-key
181
+ targets sit under the black keys, so neither covers a black key. Marks are a disc with a check
182
+ or a cross. */
183
+ .mn-svg .mn-pick[role='button'] {
184
+ outline: none;
185
+ }
186
+
187
+ .mn-svg .mn-pick[role='button']:hover {
188
+ fill: color-mix(in srgb, var(--mn-accent) 16%, transparent);
189
+ }
190
+
191
+ .mn-svg .mn-pick[role='button']:focus-visible {
192
+ fill: color-mix(in srgb, var(--mn-accent) 20%, transparent);
193
+ outline: 2px solid var(--mn-accent);
194
+ outline-offset: -2px;
195
+ }
196
+
197
+ .mn-svg .mn-pick-disc {
198
+ stroke: var(--mn-bg);
199
+ stroke-width: 1.5;
200
+ }
201
+
202
+ .mn-svg .mn-pick-right .mn-pick-disc {
203
+ fill: var(--mn-right);
204
+ }
205
+
206
+ .mn-svg .mn-pick-wrong .mn-pick-disc {
207
+ fill: var(--mn-wrong);
208
+ }
209
+
210
+ .mn-svg .mn-pick-check,
211
+ .mn-svg .mn-pick-cross {
212
+ stroke: #fff;
213
+ }
214
+
215
+ @media (forced-colors: active) {
216
+ .mn-svg .mn-pick[role='button']:focus-visible {
217
+ outline-color: Highlight;
218
+ }
219
+
220
+ .mn-svg .mn-pick-right .mn-pick-disc,
221
+ .mn-svg .mn-pick-wrong .mn-pick-disc {
222
+ fill: Canvas;
223
+ stroke: CanvasText;
224
+ }
225
+
226
+ .mn-svg .mn-pick-check,
227
+ .mn-svg .mn-pick-cross {
228
+ stroke: CanvasText;
229
+ }
230
+ }
231
+
140
232
  /* The opened list is a native popup on the page's background, not the bar's: its options take
141
233
  the page's colors, not the bar's inherited text color (light text on white in dark themes). */
142
234
  .mn-play select option {
@@ -162,7 +254,7 @@
162
254
  }
163
255
 
164
256
  .mn-play-icon-loop,
165
- .mn-play-icon-volume {
257
+ .mn-play-icon-line {
166
258
  fill: none;
167
259
  stroke: currentColor;
168
260
  stroke-width: 1.6;
@@ -176,11 +268,34 @@
176
268
  gap: 2px;
177
269
  }
178
270
 
271
+ .mn-play-field[hidden] {
272
+ display: none;
273
+ }
274
+
275
+ /* The tab bar's glyph before a slider. */
179
276
  .mn-play-label {
180
277
  display: inline-flex;
181
278
  opacity: 0.8;
182
279
  }
183
280
 
281
+ /* A slider's value after it ("90 BPM", "12 ms"), in digits of one width so the bar doesn't move
282
+ while it changes. */
283
+ .mn-play-value {
284
+ min-width: 7ch;
285
+ font-variant-numeric: tabular-nums;
286
+ white-space: nowrap;
287
+ opacity: 0.85;
288
+ }
289
+
290
+ /* The selected diagram's name on the bar of a row. */
291
+ .mn-play-name {
292
+ max-width: 16ch;
293
+ overflow: hidden;
294
+ text-overflow: ellipsis;
295
+ white-space: nowrap;
296
+ font-weight: 600;
297
+ }
298
+
184
299
  .mn-play input[type='range'] {
185
300
  all: unset;
186
301
  appearance: none;
@@ -190,7 +305,6 @@
190
305
  height: 9px;
191
306
  margin: 0;
192
307
  background: linear-gradient(var(--mn-faint), var(--mn-faint)) center / 100% 3px no-repeat;
193
- cursor: pointer;
194
308
  }
195
309
 
196
310
  .mn-play input[type='range']::-webkit-slider-runnable-track {
@@ -233,11 +347,6 @@
233
347
  background: var(--mn-accent);
234
348
  }
235
349
 
236
- .mn-playable [data-midi],
237
- .mn-playable .mn-hit {
238
- cursor: pointer;
239
- }
240
-
241
350
  /* A playable mark's hit area: invisible, but it takes clicks and taps (an open string's circle is
242
351
  only a ring), centered on the mark. */
243
352
  .mn-svg .mn-hit {
@@ -251,30 +360,6 @@
251
360
  pointer-events: none;
252
361
  }
253
362
 
254
- /* The bar's empty space lets clicks through to the dots under it; its controls take them. */
255
- .mn-playable:hover .mn-play,
256
- .mn-playable:focus-within .mn-play,
257
- .mn-playable.mn-play-open .mn-play {
258
- pointer-events: none;
259
- }
260
-
261
- .mn-playable:hover .mn-play > *,
262
- .mn-playable:focus-within .mn-play > *,
263
- .mn-playable.mn-play-open .mn-play > * {
264
- pointer-events: auto;
265
- }
266
-
267
- /* Touch screens: hover sticks after a tap, so only a tap opens the bar. */
268
- @media (hover: none) {
269
- .mn-playable:hover:not(.mn-play-open) .mn-play {
270
- opacity: 0;
271
- }
272
-
273
- .mn-playable:hover:not(.mn-play-open) .mn-play > * {
274
- pointer-events: none;
275
- }
276
- }
277
-
278
363
  /* Tabs and scores: the player bar stays at the bottom of the screen while the score scrolls. */
279
364
  .mn-tab {
280
365
  position: relative;
@@ -818,12 +903,12 @@
818
903
 
819
904
  /* Following a strumming pattern: the slot that plays gets a band and its strum the playing
820
905
  color (the band keeps it visible for a muted strum and in any theme). */
821
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-cell {
906
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-cell {
822
907
  fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
823
908
  }
824
909
 
825
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-arrow,
826
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-mute {
910
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-arrow,
911
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-mute {
827
912
  stroke: var(--mn-fg);
828
913
  stroke-width: 3;
829
914
  }
@@ -1017,16 +1102,33 @@
1017
1102
  white-space: pre-wrap;
1018
1103
  }
1019
1104
 
1020
- /* Progressions and charts in time (#46): the bar sits above the chords, always shown. */
1105
+ /* Every bar but the tab bar (#58): below what it plays, in the flow, always shown, at the left
1106
+ of the block even when a wide row scrolls. */
1021
1107
  .mn-play.mn-play-static {
1022
- position: static;
1023
- display: inline-flex;
1108
+ position: sticky;
1109
+ left: 0;
1110
+ right: auto;
1111
+ bottom: auto;
1112
+ display: flex;
1113
+ width: fit-content;
1114
+ max-width: 100%;
1115
+ box-sizing: border-box;
1024
1116
  justify-content: flex-start;
1025
- margin: 0 0 6px;
1117
+ gap: 4px 8px;
1118
+ margin: 6px 0 0;
1119
+ padding: 3px 6px;
1120
+ font-size: 11px;
1026
1121
  opacity: 1;
1027
1122
  pointer-events: auto;
1028
1123
  }
1029
1124
 
1125
+ .mn-timed {
1126
+ display: inline-flex;
1127
+ flex-direction: column;
1128
+ align-items: flex-start;
1129
+ max-width: 100%;
1130
+ }
1131
+
1030
1132
  .mn-progression-chord.mn-playing {
1031
1133
  border-radius: 6px;
1032
1134
  background: color-mix(in srgb, var(--mn-playing) 22%, transparent);
@@ -1075,15 +1177,15 @@
1075
1177
  stroke: none;
1076
1178
  }
1077
1179
 
1078
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
1180
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
1079
1181
  fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
1080
1182
  }
1081
1183
 
1082
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
1184
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
1083
1185
  fill: var(--mn-playing);
1084
1186
  }
1085
1187
 
1086
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
1188
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
1087
1189
  fill: var(--mn-on-playing);
1088
1190
  }
1089
1191