@barmark/render 0.2.1 → 0.3.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/CHANGELOG.md +15 -1
- package/dist/html.js +14 -2
- package/dist/model.js +7 -2
- package/dist/styles.js +1 -0
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,19 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.3.0] - 2026-11-01
|
|
10
|
+
|
|
11
|
+
Draws gradual tempo changes. Depends on `barmark` ^0.5.0, which reads
|
|
12
|
+
them.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Gradual tempo changes. A `tempo: rit. to 90` line reads
|
|
17
|
+
"→ Tempo rit. to ♩ = 90" (`a tempo` reads as itself), and every bar
|
|
18
|
+
played inside a rit. or accel. has a dashed line along its top, in
|
|
19
|
+
the directive colour, with `data-tempo-change="rit"` or `"accel"`.
|
|
20
|
+
Uses barmark 0.5.0's `tempoChange`.
|
|
21
|
+
|
|
9
22
|
## [0.2.1] - 2026-11-01
|
|
10
23
|
|
|
11
24
|
Two fixes found while moving barmark.dev to the element. Depends on
|
|
@@ -117,7 +130,8 @@ that needs no script or as the `<barmark-chart>` web component. Requires
|
|
|
117
130
|
zoom without sideways scrolling, the element renders and re-renders, and
|
|
118
131
|
a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
|
|
119
132
|
|
|
120
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.
|
|
133
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.3.0...HEAD
|
|
134
|
+
[0.3.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.1...render-v0.3.0
|
|
121
135
|
[0.2.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.0...render-v0.2.1
|
|
122
136
|
[0.2.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.1.0...render-v0.2.0
|
|
123
137
|
[0.1.0]: https://github.com/kevinpeckham/barmark/releases/tag/render-v0.1.0
|
package/dist/html.js
CHANGED
|
@@ -41,16 +41,27 @@ function headerHtml(model) {
|
|
|
41
41
|
return "";
|
|
42
42
|
return `<header class="bm-header">${title}${meta ? `<p class="bm-meta" part="meta">${meta}</p>` : ""}</header>`;
|
|
43
43
|
}
|
|
44
|
+
/** "rit. to ♩ = 90", "accel.", "a tempo". */
|
|
45
|
+
function tempoChangeText(c) {
|
|
46
|
+
if (c.kind === "a tempo")
|
|
47
|
+
return c.kind;
|
|
48
|
+
return `${c.kind}.${c.to === null ? "" : ` to ♩ = ${c.to}`}`;
|
|
49
|
+
}
|
|
44
50
|
/** "D major · 4/4 · ♩ = 145 · swing", escaped; labelled, "Key D major · Time 4/4 · …". */
|
|
45
51
|
function metaText(d, labelled = false) {
|
|
46
52
|
return [
|
|
47
53
|
["Key", d.key ? `${glyphs(d.key.tonic)} ${d.key.mode}` : ""],
|
|
48
54
|
["Time", d.time ? `${d.time.n}/${d.time.d}` : ""],
|
|
49
55
|
["Tempo", d.tempo ? `♩ = ${d.tempo}` : ""],
|
|
56
|
+
// "a tempo" names itself; "Tempo a tempo" would stutter.
|
|
57
|
+
[
|
|
58
|
+
d.tempoChange?.kind === "a tempo" ? "" : "Tempo",
|
|
59
|
+
d.tempoChange ? tempoChangeText(d.tempoChange) : "",
|
|
60
|
+
],
|
|
50
61
|
["Feel", d.feel ?? ""],
|
|
51
62
|
]
|
|
52
63
|
.filter(([, value]) => value)
|
|
53
|
-
.map(([label, value]) => escapeHtml(labelled ? `${label} ${value}` : (value ?? "")))
|
|
64
|
+
.map(([label, value]) => escapeHtml(labelled && label ? `${label} ${value}` : (value ?? "")))
|
|
54
65
|
.join(" · ");
|
|
55
66
|
}
|
|
56
67
|
function blockHtml(block, settings) {
|
|
@@ -158,7 +169,8 @@ function cellHtml(cell, barNumber, marks) {
|
|
|
158
169
|
? `<span class="bm-meter"><span>${cell.meter.n}</span><span>${cell.meter.d}</span></span>`
|
|
159
170
|
: "";
|
|
160
171
|
const cut = cell.cut ? `<span class="bm-cut">cut</span>` : "";
|
|
161
|
-
|
|
172
|
+
const change = cell.tempoChange ? ` data-tempo-change="${cell.tempoChange}"` : "";
|
|
173
|
+
return `<div class="bm-bar" part="bar"${cell.cut ? " data-cut" : ""}${change}${marks}>${spoken}<span class="bm-bar-body" aria-hidden="true">${meter}${cell.slots.map(slotHtml).join("")}${cut}</span></div>`;
|
|
162
174
|
}
|
|
163
175
|
const FERMATA = `<svg class="bm-fermata-glyph" viewBox="0 0 24 14" width="1.4em" height="0.8em"><path d="M2 13 A10 10 0 0 1 22 13" fill="none" stroke="currentColor" stroke-width="1.8"/><circle cx="12" cy="11" r="1.8" fill="currentColor"/></svg>`;
|
|
164
176
|
function slotHtml(slot) {
|
package/dist/model.js
CHANGED
|
@@ -239,10 +239,15 @@ function layoutCell(cell, played, previous) {
|
|
|
239
239
|
if (cell.kind === "fermata")
|
|
240
240
|
return { kind: "fermata" };
|
|
241
241
|
const from = cell.kind === "slots" ? cell : previous;
|
|
242
|
-
return {
|
|
242
|
+
return withTempoChange({
|
|
243
243
|
kind: "slots",
|
|
244
244
|
meter: from?.meter ?? null,
|
|
245
245
|
slots: played?.slots ?? (cell.kind === "slots" ? cell.slots : []),
|
|
246
246
|
cut: false,
|
|
247
|
-
};
|
|
247
|
+
}, played);
|
|
248
|
+
}
|
|
249
|
+
/** Marks a bar played inside a rit. or accel. */
|
|
250
|
+
function withTempoChange(cell, played) {
|
|
251
|
+
const change = played?.tempoChange?.kind;
|
|
252
|
+
return change ? { ...cell, tempoChange: change } : cell;
|
|
248
253
|
}
|
package/dist/styles.js
CHANGED
|
@@ -111,6 +111,7 @@ const css = `
|
|
|
111
111
|
.bm-tuplet::after{border-left:none;margin-left:.3em}
|
|
112
112
|
.bm-meter{display:inline-flex;flex-direction:column;align-items:center;align-self:center;font:700 ${em(SIZES.meter)}/.95 ${SANS};color:var(--bm-muted)}
|
|
113
113
|
.bm-fermata-glyph{display:block;color:var(--bm-ink)}
|
|
114
|
+
.bm-bar[data-tempo-change]::before{content:"";position:absolute;inset:.15em 0 auto;border-top:.08em dashed var(--barmark-directive,var(--bm-muted))}
|
|
114
115
|
.bm-bar[data-cut]{outline:.08em dashed var(--bm-muted);outline-offset:-.25em}
|
|
115
116
|
.bm-cut{position:absolute;top:.3em;right:.45em;font:${em(SIZES.cut)}/1 ${SANS};color:var(--bm-muted)}
|
|
116
117
|
.bm-text{grid-column:1/-1;margin:.2em 0 .5em ${at(SIZES.text, GUTTER)};font-family:${TEXT};font-size:${em(SIZES.text)}}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Render barmark chord charts as a clean, accessible bar grid: HTML with Declarative Shadow DOM, or the <barmark-chart> web component.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"url": "https://github.com/kevinpeckham/barmark/issues"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"barmark": "^0.
|
|
50
|
+
"barmark": "^0.5.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|