@barmark/render 0.2.0 → 0.2.1

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 CHANGED
@@ -6,6 +6,24 @@ package uses [semantic versioning](https://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2026-11-01
10
+
11
+ Two fixes found while moving barmark.dev to the element. Depends on
12
+ `barmark` ^0.3.0, which warns when a chart has no bar lines.
13
+
14
+ ### Fixed
15
+
16
+ - **Triplet brackets work on any paper.** The bracket is drawn either
17
+ side of its number, leaving a gap, instead of under it with the number
18
+ painted over in the paper colour. A see-through `--barmark-paper` used
19
+ to show the number in a box.
20
+ - **A chart from `renderChart` keeps its options when the element
21
+ loads.** The `<barmark-chart>` it wraps the chart in now carries them as
22
+ attributes (`theme`, `bar-numbers="off"`, `rehearsal-letters`). Before,
23
+ a page that rendered a dark chart on the server and imported
24
+ `@barmark/render/element` saw it switch to the system theme, and lose
25
+ its rehearsal letters once given new `text`.
26
+
9
27
  ## [0.2.0] - 2026-11-01
10
28
 
11
29
  Easier to read, and the bar numbers easier to scan. Every size below was
@@ -99,6 +117,7 @@ that needs no script or as the `<barmark-chart>` web component. Requires
99
117
  zoom without sideways scrolling, the element renders and re-renders, and
100
118
  a screen reader hears "bar 9: D". Run them with `bun run test:browser`.
101
119
 
102
- [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.0...HEAD
120
+ [Unreleased]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.1...HEAD
121
+ [0.2.1]: https://github.com/kevinpeckham/barmark/compare/render-v0.2.0...render-v0.2.1
103
122
  [0.2.0]: https://github.com/kevinpeckham/barmark/compare/render-v0.1.0...render-v0.2.0
104
123
  [0.1.0]: https://github.com/kevinpeckham/barmark/releases/tag/render-v0.1.0
package/dist/html.js CHANGED
@@ -5,7 +5,16 @@ import { layoutChart } from "./model.js";
5
5
  import { speakBar } from "./speech.js";
6
6
  import { FIT_STEPS, MIN_BAR, stylesheet } from "./styles.js";
7
7
  export function renderChart(text, options = {}) {
8
- return `${fontStyle(options)}<barmark-chart><template shadowrootmode="open">${shadowContent(text, options)}</template></barmark-chart>`;
8
+ return `${fontStyle(options)}<barmark-chart${elementAttributes(options)}><template shadowrootmode="open">${shadowContent(text, options)}</template></barmark-chart>`;
9
+ }
10
+ /** The options as the element's attributes, so it keeps them when it loads or takes new text. */
11
+ function elementAttributes(options) {
12
+ const theme = themeOf(options);
13
+ return [
14
+ theme === "auto" ? "" : ` theme="${theme}"`,
15
+ options.barNumbers === false ? ' bar-numbers="off"' : "",
16
+ options.rehearsalLetters ? " rehearsal-letters" : "",
17
+ ].join("");
9
18
  }
10
19
  export const THEMES = ["auto", "light", "dark"];
11
20
  /** Only a known theme reaches the markup: hosts may pass any string through. */
package/dist/styles.js CHANGED
@@ -31,6 +31,12 @@ const SIZES = {
31
31
  const GUTTER = 2.06;
32
32
  export const MIN_BAR = 4.68;
33
33
  const HEADING_GAP = 0.645;
34
+ /**
35
+ * The triplet bracket, in chord sizes: its line sits this far below the top
36
+ * of the number, with hooks this long, drawn either side of the number so
37
+ * nothing is painted over it and any paper shows through.
38
+ */
39
+ const BRACKET = { top: 0.6, hook: 0.3, line: 0.06 };
34
40
  /** The single note's ring, in its own em: padding, and the border it spills past. */
35
41
  const RING = { y: 0.21, x: 0.5, border: 0.07 };
36
42
  const em = (n) => `${Number(n.toFixed(3))}em`;
@@ -99,8 +105,10 @@ const css = `
99
105
  .bm-notes{display:inline-flex;gap:.3em;align-items:baseline}
100
106
  .bm-notes u{text-decoration-thickness:.08em;text-underline-offset:.15em}
101
107
  .bm-group{position:relative;display:inline-flex;gap:.45em;align-items:baseline}
102
- .bm-group::before{content:"";position:absolute;left:0;right:0;top:-.45em;height:.3em;border:.06em solid var(--bm-muted);border-bottom:none}
103
- .bm-tuplet{position:absolute;left:50%;top:-1.25em;transform:translateX(-50%);font:italic 600 ${em(SIZES.tuplet)}/1 Georgia,serif;color:var(--bm-muted);background:var(--bm-paper);padding:0 .3em}
108
+ .bm-tuplet{position:absolute;left:0;right:0;top:-1.25em;display:flex;justify-content:center;font:italic 600 ${em(SIZES.tuplet)}/1 Georgia,serif;color:var(--bm-muted)}
109
+ .bm-tuplet::before,.bm-tuplet::after{content:"";flex:1;align-self:flex-start;margin-top:${at(SIZES.tuplet, BRACKET.top)};height:${at(SIZES.tuplet, BRACKET.hook)};border:${at(SIZES.tuplet, BRACKET.line)} solid var(--bm-muted);border-bottom:none}
110
+ .bm-tuplet::before{border-right:none;margin-right:.3em}
111
+ .bm-tuplet::after{border-left:none;margin-left:.3em}
104
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)}
105
113
  .bm-fermata-glyph{display:block;color:var(--bm-ink)}
106
114
  .bm-bar[data-cut]{outline:.08em dashed var(--bm-muted);outline-offset:-.25em}
@@ -113,7 +121,7 @@ const css = `
113
121
  .bm-diagnostics .bm-error{color:var(--bm-accent)}
114
122
  @media (forced-colors:active){
115
123
  .bm-bar,.bm-row>div.bm-bar:first-of-type,.bm-row>div.bm-bar[data-repeat-start],.bm-row>div.bm-bar[data-repeat-end]{border-color:CanvasText}
116
- .bm-ring,.bm-group::before{border-color:CanvasText}
124
+ .bm-ring,.bm-tuplet::before,.bm-tuplet::after{border-color:CanvasText}
117
125
  .bm-silence{background:CanvasText;forced-color-adjust:none}
118
126
  .bm-bar[data-cut]{outline-color:CanvasText}
119
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barmark/render",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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.2.0"
50
+ "barmark": "^0.3.0"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "rm -rf dist && tsc -p tsconfig.build.json",