@barmark/render 0.5.0 → 0.7.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 +24 -1
- package/README.md +6 -4
- package/dist/chord.d.ts +2 -1
- package/dist/chord.js +7 -3
- package/dist/element.js +22 -1
- package/dist/html.d.ts +5 -0
- package/dist/html.js +2 -1
- package/dist/styles.js +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ package uses [semantic versioning](https://semver.org/).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.7.0] - 2026-11-02
|
|
10
|
+
|
|
11
|
+
Power chords in the numerals views. Requires `barmark` 0.7.0.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **A power chord's 5 is raised in the numerals views:** D5 in D shows as
|
|
16
|
+
1⁵ (Nashville) and I⁵ (Roman), G5(7) as 4⁵⁽⁷⁾. On the baseline the
|
|
17
|
+
Nashville 5 joined the number and read as 15. Chord names are
|
|
18
|
+
unchanged (D5).
|
|
19
|
+
|
|
20
|
+
## [0.6.0] - 2026-11-02
|
|
21
|
+
|
|
22
|
+
Charts that scroll instead of wrapping. barmark.dev's home page uses it.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **`wrap: false`** (attribute `wrap="off"`, property `wrap`): a section
|
|
27
|
+
wider than the chart's box keeps its rows and columns rather than
|
|
28
|
+
wrapping them, and the chart overflows for its page to scroll.
|
|
29
|
+
|
|
9
30
|
## [0.5.0] - 2026-11-02
|
|
10
31
|
|
|
11
32
|
The spoken name of a chord, for other tools. barmark.dev's /try page
|
|
@@ -169,7 +190,9 @@ that needs no script or as the `<barmark-chart>` web component. Requires
|
|
|
169
190
|
zoom without sideways scrolling, the element renders and re-renders, and
|
|
170
191
|
a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
|
|
171
192
|
|
|
172
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.
|
|
193
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.7.0...HEAD
|
|
194
|
+
[0.7.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.6.0...render-v0.7.0
|
|
195
|
+
[0.6.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.5.0...render-v0.6.0
|
|
173
196
|
[0.5.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.4.0...render-v0.5.0
|
|
174
197
|
[0.4.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.3.0...render-v0.4.0
|
|
175
198
|
[0.3.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.1...render-v0.3.0
|
package/README.md
CHANGED
|
@@ -76,6 +76,7 @@ the element loads, with `<style data-barmark-font>` holding
|
|
|
76
76
|
| `barNumbers` | `bar-numbers="off"` (`barNumbers`) | `true` | bar numbers at the start of each row |
|
|
77
77
|
| `rehearsalLetters` | `rehearsal-letters` (`rehearsalLetters`) | `false` | boxed A, B, C… on each section as played |
|
|
78
78
|
| `numerals` | `numerals` (`numerals`) | none | `"nashville"` (6m⁷) or `"roman"` (vi⁷): each chord as its degree in its bar's key |
|
|
79
|
+
| `wrap` | `wrap="off"` (`wrap`) | `true` | wrap a section's rows when it is wider than the chart's box; off, rows keep their columns and the chart overflows, for its page to scroll |
|
|
79
80
|
| `diagnostics` | | `false` | list the chart's errors and warnings below it |
|
|
80
81
|
| `fontUrl` | | none | emit Edwin's `@font-face` rule before the chart |
|
|
81
82
|
| (the `text` argument) | (`text`) | `null` | the chart to draw; wins over `src` and the script child |
|
|
@@ -87,10 +88,11 @@ played in, so a modulation renumbers from its next bar. Degrees count
|
|
|
87
88
|
from the key's tonic against the major scale, in every mode: in `key:
|
|
88
89
|
Am`, Am is 1m and C is ♭3. Nashville keeps the chord's quality and
|
|
89
90
|
superscript after the number (Bm7 in D is 6m⁷, D/F♯ is 1/3); Roman
|
|
90
|
-
shows minor and diminished in lower case (ii, vii°, ♭VII).
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
shows minor and diminished in lower case (ii, vii°, ♭VII). Both raise a
|
|
92
|
+
power chord's 5 into the superscript (D5 in D is 1⁵ and I⁵, never 15).
|
|
93
|
+
A bar with no key, note sets, N.C., `?` and `--` look as they always
|
|
94
|
+
do, and a screen reader hears both: "bar 5: five, A seven". Numbered
|
|
95
|
+
chords carry `data-numeral`. It's a view: the music and bar numbers don't change.
|
|
94
96
|
|
|
95
97
|
### Spoken names
|
|
96
98
|
|
package/dist/chord.d.ts
CHANGED
|
@@ -17,7 +17,8 @@ export declare const NUMERALS: readonly Numerals[];
|
|
|
17
17
|
/**
|
|
18
18
|
* A chord as its degree in `key`: Nashville keeps the chord's quality and
|
|
19
19
|
* superscript after the number; Roman shows minor and diminished in lower
|
|
20
|
-
* case.
|
|
20
|
+
* case. Both raise a power chord's 5 into the superscript (1⁵, I⁵). A
|
|
21
|
+
* slash bass is a number in both. Null if the root has no degree.
|
|
21
22
|
*/
|
|
22
23
|
export declare function typesetNumeral(parts: ChordParts, key: Key, style: Numerals): ChordPieces | null;
|
|
23
24
|
/** A note set's label (`E1`, `F#`) as name and octave. */
|
package/dist/chord.js
CHANGED
|
@@ -27,21 +27,25 @@ const ROMAN_QUALITY = {
|
|
|
27
27
|
m: "",
|
|
28
28
|
dim: "°",
|
|
29
29
|
aug: "+",
|
|
30
|
-
|
|
30
|
+
// Raised into the superscript with the other numerals (raisePower).
|
|
31
|
+
"5": "",
|
|
31
32
|
};
|
|
33
|
+
/** A power chord's 5 goes up with the superscript: on the baseline it joins the number (1 and 5 read as 15). */
|
|
34
|
+
const raisePower = (p) => p.quality === "5" ? { ...p, quality: "", superscript: `5${p.superscript}` } : p;
|
|
32
35
|
const accidentals = (alter) => (alter < 0 ? "b" : "#").repeat(Math.abs(alter));
|
|
33
36
|
/** `{ degree: 7, alter: -1 }` → `♭7`. */
|
|
34
37
|
const degreeText = (d) => glyphs(`${accidentals(d.alter)}${d.degree}`);
|
|
35
38
|
/**
|
|
36
39
|
* A chord as its degree in `key`: Nashville keeps the chord's quality and
|
|
37
40
|
* superscript after the number; Roman shows minor and diminished in lower
|
|
38
|
-
* case.
|
|
41
|
+
* case. Both raise a power chord's 5 into the superscript (1⁵, I⁵). A
|
|
42
|
+
* slash bass is a number in both. Null if the root has no degree.
|
|
39
43
|
*/
|
|
40
44
|
export function typesetNumeral(parts, key, style) {
|
|
41
45
|
const degree = degreeOf(parts.root, key);
|
|
42
46
|
if (!degree)
|
|
43
47
|
return null;
|
|
44
|
-
const pieces = typesetChord(parts);
|
|
48
|
+
const pieces = raisePower(typesetChord(parts));
|
|
45
49
|
const bass = parts.bass ? degreeOf(parts.bass, key) : null;
|
|
46
50
|
const withBass = { ...pieces, bass: bass ? degreeText(bass) : pieces.bass };
|
|
47
51
|
if (style === "nashville")
|
package/dist/element.js
CHANGED
|
@@ -14,6 +14,7 @@ export function optionsFromAttributes(el) {
|
|
|
14
14
|
theme: THEMES.find((t) => t === theme) ?? "auto",
|
|
15
15
|
barNumbers: el.getAttribute("bar-numbers") !== "off",
|
|
16
16
|
rehearsalLetters: el.hasAttribute("rehearsal-letters"),
|
|
17
|
+
wrap: el.getAttribute("wrap") !== "off",
|
|
17
18
|
...(numerals ? { numerals } : {}),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
@@ -48,7 +49,14 @@ async function fetchText(src) {
|
|
|
48
49
|
}
|
|
49
50
|
function defineElement() {
|
|
50
51
|
class BarmarkChart extends HTMLElement {
|
|
51
|
-
static observedAttributes = [
|
|
52
|
+
static observedAttributes = [
|
|
53
|
+
"src",
|
|
54
|
+
"theme",
|
|
55
|
+
"bar-numbers",
|
|
56
|
+
"rehearsal-letters",
|
|
57
|
+
"numerals",
|
|
58
|
+
"wrap",
|
|
59
|
+
];
|
|
52
60
|
#observer = new MutationObserver(() => this.#schedule());
|
|
53
61
|
#renders = 0;
|
|
54
62
|
#scheduled = false;
|
|
@@ -103,6 +111,15 @@ function defineElement() {
|
|
|
103
111
|
else
|
|
104
112
|
this.setAttribute("bar-numbers", "off");
|
|
105
113
|
}
|
|
114
|
+
get wrap() {
|
|
115
|
+
return optionsFromAttributes(this).wrap ?? true;
|
|
116
|
+
}
|
|
117
|
+
set wrap(v) {
|
|
118
|
+
if (v)
|
|
119
|
+
this.removeAttribute("wrap");
|
|
120
|
+
else
|
|
121
|
+
this.setAttribute("wrap", "off");
|
|
122
|
+
}
|
|
106
123
|
get rehearsalLetters() {
|
|
107
124
|
return this.hasAttribute("rehearsal-letters");
|
|
108
125
|
}
|
|
@@ -167,6 +184,10 @@ function defineElement() {
|
|
|
167
184
|
chart?.setAttribute("data-bar-numbers", "off");
|
|
168
185
|
else
|
|
169
186
|
chart?.removeAttribute("data-bar-numbers");
|
|
187
|
+
if (options.wrap === false)
|
|
188
|
+
chart?.setAttribute("data-wrap", "off");
|
|
189
|
+
else
|
|
190
|
+
chart?.removeAttribute("data-wrap");
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
193
|
customElements.define("barmark-chart", BarmarkChart);
|
package/dist/html.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export type RenderOptions = {
|
|
|
9
9
|
fontUrl?: string;
|
|
10
10
|
/** Show each chord as its degree in the bar's key, where the chart names one. Off by default. */
|
|
11
11
|
numerals?: Numerals;
|
|
12
|
+
/**
|
|
13
|
+
* Wrap a section's rows when it is wider than the chart's box (the default).
|
|
14
|
+
* With `false` rows keep their columns, and the page scrolls the chart instead.
|
|
15
|
+
*/
|
|
16
|
+
wrap?: boolean;
|
|
12
17
|
};
|
|
13
18
|
export declare function renderChart(text: string, options?: RenderOptions): string;
|
|
14
19
|
export declare const THEMES: readonly ["auto", "light", "dark"];
|
package/dist/html.js
CHANGED
|
@@ -15,6 +15,7 @@ function elementAttributes(options) {
|
|
|
15
15
|
options.barNumbers === false ? ' bar-numbers="off"' : "",
|
|
16
16
|
options.rehearsalLetters ? " rehearsal-letters" : "",
|
|
17
17
|
numeralsOf(options) ? ` numerals="${numeralsOf(options)}"` : "",
|
|
18
|
+
options.wrap === false ? ' wrap="off"' : "",
|
|
18
19
|
].join("");
|
|
19
20
|
}
|
|
20
21
|
export const THEMES = ["auto", "light", "dark"];
|
|
@@ -35,7 +36,7 @@ function chartHtml(text, options) {
|
|
|
35
36
|
barNumbers: options.barNumbers ?? true,
|
|
36
37
|
numerals: numeralsOf(options),
|
|
37
38
|
};
|
|
38
|
-
return `<div class="bm-chart" data-theme="${themeOf(options)}"${settings.barNumbers ? "" : ' data-bar-numbers="off"'}>${headerHtml(model)}${model.blocks.map((b) => blockHtml(b, settings)).join("")}${options.diagnostics ? diagnosticsHtml(model) : ""}</div>`;
|
|
39
|
+
return `<div class="bm-chart" data-theme="${themeOf(options)}"${settings.barNumbers ? "" : ' data-bar-numbers="off"'}${options.wrap === false ? ' data-wrap="off"' : ""}>${headerHtml(model)}${model.blocks.map((b) => blockHtml(b, settings)).join("")}${options.diagnostics ? diagnosticsHtml(model) : ""}</div>`;
|
|
39
40
|
}
|
|
40
41
|
function headerHtml(model) {
|
|
41
42
|
const title = model.title
|
package/dist/styles.js
CHANGED
|
@@ -84,6 +84,7 @@ const css = `
|
|
|
84
84
|
.bm-times{font:italic 1.2em/1 Georgia,serif;text-transform:none;letter-spacing:0;color:var(--bm-muted)}
|
|
85
85
|
.bm-grid{display:grid;grid-template-columns:${em(GUTTER)} repeat(var(--bm-cols),auto) auto;width:max-content;max-width:100%}
|
|
86
86
|
.bm-chart[data-bar-numbers="off"] .bm-grid{grid-template-columns:repeat(var(--bm-cols),auto) auto}
|
|
87
|
+
.bm-chart[data-wrap="off"] .bm-grid{max-width:none}
|
|
87
88
|
.bm-row{display:contents}
|
|
88
89
|
.bm-row+.bm-row>*{margin-top:${em(ROW_GAP)}}
|
|
89
90
|
.bm-row+.bm-row>.bm-bar-number{margin-top:${at(SIZES.barNumber, ROW_GAP)}}
|
|
@@ -131,7 +132,7 @@ const css = `
|
|
|
131
132
|
.bm-bar[data-cut]{outline-color:CanvasText}
|
|
132
133
|
}
|
|
133
134
|
${FIT_STEPS.map((w) => {
|
|
134
|
-
const g = `.bm-grid[data-fit="${w}"]`;
|
|
135
|
+
const g = `.bm-chart:not([data-wrap="off"]) .bm-grid[data-fit="${w}"]`;
|
|
135
136
|
return `@container bm (max-width:${w}em){${g}{display:block}${g}>.bm-row{display:flex;flex-wrap:wrap;row-gap:${em(ROW_GAP)}}${g} .bm-empty{display:none}${g} .bm-bar{flex:0 1 auto;max-width:100%;border-left:.075em solid var(--bm-rule);margin-left:-.075em}${g} :is(.bm-bar-body,.bm-group,.bm-notes){flex-wrap:wrap}${g} .bm-bar-body>*{flex:1 1 auto;min-width:auto}}`;
|
|
136
137
|
}).join("\n")}
|
|
137
138
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barmark/render",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.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.7.0"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|