@ugfoundation/swaralipi-js 0.8.0 → 0.8.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.
@@ -414,16 +414,20 @@ function renderNote(note, kind, opts, ctx) {
414
414
  }
415
415
  function renderArc(arc, offset) {
416
416
  const open = arc.line === true;
417
- const cls = [
418
- "sw-arc",
419
- arc.openLeft || open ? "sw-arc--openl" : "",
420
- arc.openRight || open ? "sw-arc--openr" : ""
421
- ].filter(Boolean).join(" ");
422
- const left = open || arc.openLeft ? "" : '<i class="sw-arc-l">w</i>';
423
- const right = open || arc.openRight ? "" : '<i class="sw-arc-r">x</i>';
424
- const from = offset + arc.start + COL_BASE;
425
- const to = offset + arc.end + COL_BASE + 1;
426
- return `<span class="${cls}" style="grid-column:${from} / ${to}">${left}<i class="sw-arc-m"></i>${right}</span>`;
417
+ const openL = arc.openLeft || open;
418
+ const openR = arc.openRight || open;
419
+ const fill = '<i class="sw-arc-m"></i>';
420
+ const hookL = openL ? "" : '<i class="sw-arc-l">w</i>';
421
+ const hookR = openR ? "" : '<i class="sw-arc-r">x</i>';
422
+ const piece = (col, cls, inner) => `<span class="sw-arc${cls}" style="grid-column:${col}">${inner}</span>`;
423
+ const f = offset + arc.start + COL_BASE;
424
+ const t = offset + arc.end + COL_BASE;
425
+ const openCls = (openL ? " sw-arc--openl" : "") + (openR ? " sw-arc--openr" : "");
426
+ if (t === f) return piece(`${f}`, openCls, hookL + fill + hookR);
427
+ const head = piece(`${f}`, openL ? " sw-arc--openl" : " sw-arc--head", hookL + fill);
428
+ const tail = piece(`${t}`, openR ? " sw-arc--openr" : " sw-arc--tail", fill + hookR);
429
+ const mid = t > f + 1 ? piece(`${f + 1} / ${t}`, " sw-arc--mid", fill) : "";
430
+ return head + mid + tail;
427
431
  }
428
432
  function renderRow(row, partIdx, rowIdx, offset, ctx) {
429
433
  const cells = groupRowIntoCells(row.notes);
@@ -734,9 +738,26 @@ ${FONT_FACES}
734
738
  align-items: baseline;
735
739
  line-height: 1;
736
740
  font-family: Swarabitan, var(--sw-font, sans-serif);
737
- font-size: 0.9em;
741
+ /* The 0.9em sits on the children, not here: the end pieces below size
742
+ themselves off the block's own column-gap, which is in the block's em. */
738
743
  }
744
+ .sw-arc > i, .sw-arc::before { font-size: 0.9em; }
739
745
  .sw-arc-l, .sw-arc-r { flex: none; font-style: normal; }
746
+ /* Every piece needs the same baseline \u2014 the fill rides it, so a piece holding
747
+ only fill would otherwise drop to the bottom of the row. A zero-width copy
748
+ of the hook glyph is the strut (same font, same metrics). */
749
+ .sw-arc::before { content: 'w'; flex: none; width: 0; overflow: hidden; }
750
+ /* The ends hang from the two notes' CENTRES, as the print sets them, so the
751
+ arc is three grid items: each end piece takes half of its own column plus
752
+ the column-gap it has to bridge, and the negative margin on the same side
753
+ lets that bridge overhang the grid area instead of shifting the piece. */
754
+ .sw-arc--head, .sw-arc--tail {
755
+ --sw-arc-gap: calc(var(--sw-cell-gap, 0.4em) * var(--sw-tight, 1));
756
+ width: calc(50% + var(--sw-arc-gap));
757
+ }
758
+ .sw-arc--head { justify-self: end; margin-right: calc(var(--sw-arc-gap) * -1); }
759
+ .sw-arc--tail { justify-self: start; margin-left: calc(var(--sw-arc-gap) * -1);
760
+ justify-content: flex-end; }
740
761
  /* The fill's geometry is measured off the font's own 'y' glyph: ink 0.11em
741
762
  tall whose bottom sits 0.01em above the baseline. An empty inline-block
742
763
  takes its bottom margin edge as its baseline, so -0.01em lifts the bar to