@miragon/slidev-validator 0.5.0 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miragon/slidev-validator",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "The Miragon Slidev deck validator: a configurable design-system linter (stable rule IDs, off/warn/error severities, extends/overrides/exceptions) shipped as a versioned CLI so central guardrail improvements reach decks over npm instead of a frozen copy.",
6
6
  "keywords": [
@@ -72,6 +72,8 @@ export function measureSafeArea({ n, overlaySel, canvas }) {
72
72
  const cs = getComputedStyle(el)
73
73
  if (cs.visibility === 'hidden' || cs.display === 'none' || parseFloat(cs.opacity) < 0.05) continue
74
74
  if (cs.position === 'fixed') continue // the overlays themselves / other chrome
75
+ if (cs.pointerEvents === 'none') continue
76
+ if (el.getAttribute('aria-hidden') === 'true' || el.closest('[aria-hidden="true"]')) continue
75
77
  const c = toCanvas(r)
76
78
  const nearBottom = c.bottom > canvas.height - 80
77
79
  const nearTop = c.top < 80
@@ -5,27 +5,50 @@ import { toRel } from '../../helpers.mjs'
5
5
  /**
6
6
  * Content headings (frontmatter `title` → `<h2 class="*-title">`) must stay on one
7
7
  * line; a wrap shrinks the content area below. Statement headings (`hero`/`section`/
8
- * `subsection`/`cover`, markdown `#` → `<h1>`) may wrap and are not checked.
8
+ * `subsection`/`cover`/`closing` and the full-bleed `default`, markdown `#` → `<h1>`)
9
+ * may wrap and are the only layouts exempt from the budget.
10
+ *
11
+ * Every other title-bearing layout is budgeted — including any deck-local
12
+ * `deck/layouts/*.vue`. An unknown layout defaults to the BASE limit rather than
13
+ * silently passing; a layout with no `title:` frontmatter never triggers a check.
9
14
  *
10
15
  * Two checks: an explicit break (`<br>`/newline/trailing `\`) is always flagged; the
11
16
  * char budget is a heuristic ("WWW" and "iii" differ in width).
12
17
  */
13
18
 
14
19
  /**
15
- * Max heading chars per layout, derived from each layout's container width + font
16
- * size (~0.5em advance) with headroom over the longest real heading (38).
17
- * `content-image`'s title sits in one narrow grid column.
20
+ * Base single-line budget for a content title. Calibrated against the rendered
21
+ * heading, not guessed: limit ≈ floor(titleWidthPx / advancePerChar) minus a ~12%
22
+ * margin, where advancePerChar is measured once in the brand font at the title's
23
+ * size/weight/letter-spacing (Geist, weight 800, ~33.7px, letter-spacing -0.02em →
24
+ * ~17.3px/char over an ~820px title column ⇒ ~47-char wrap point ⇒ 44 with margin).
25
+ * The margin keeps limits clear of the pixel boundary where a few px of
26
+ * kerning/hinting flips a heading onto a second line in the presenter's browser.
27
+ */
28
+ const BASE_LIMIT = 44
29
+
30
+ /**
31
+ * Statement layouts whose heading is a markdown `#` → `<h1>` that may legitimately
32
+ * wrap; never budget-checked. Everything not listed here is budgeted.
33
+ */
34
+ const STATEMENT_LAYOUTS = new Set(['hero', 'section', 'subsection', 'cover', 'closing', 'default'])
35
+
36
+ /**
37
+ * Per-layout budget where the title area differs from the base content column.
38
+ * `content-image`'s title sits in one narrow grid column; the wide diagram/showcase
39
+ * layouts give the title the full slide width. Layouts absent here use BASE_LIMIT.
40
+ * Same re-calibration formula as BASE_LIMIT, per layout's title width.
18
41
  */
19
42
  const HEADING_LIMITS = {
20
- content: 50,
21
- compare: 50,
22
- 'content-image': 28,
23
- showcase: 56,
24
- goodbad: 56,
25
- excalidraw: 56,
26
- bpmn: 56,
27
- dmn: 56,
28
- mermaid: 56,
43
+ content: 44,
44
+ compare: 44,
45
+ 'content-image': 24,
46
+ showcase: 49,
47
+ goodbad: 49,
48
+ excalidraw: 49,
49
+ bpmn: 49,
50
+ dmn: 49,
51
+ mermaid: 49,
29
52
  }
30
53
 
31
54
  /** Off-by-default per-slide opt-out from both checks. */
@@ -44,14 +67,14 @@ function hasExplicitBreak(title) {
44
67
  /** Pure per-heading check (fixture-testable). Returns reasons; [] = ok. */
45
68
  export function scanHeading(title, layout, optOut = false) {
46
69
  if (optOut) return []
47
- if (!layout || !(layout in HEADING_LIMITS)) return []
70
+ if (!layout || STATEMENT_LAYOUTS.has(layout)) return []
48
71
  if (typeof title !== 'string' || !title.trim()) return []
49
72
 
50
73
  const reasons = []
51
74
  if (hasExplicitBreak(title)) {
52
75
  reasons.push('content heading contains an explicit line break; write it as a single-line heading')
53
76
  }
54
- const limit = HEADING_LIMITS[layout]
77
+ const limit = HEADING_LIMITS[layout] ?? BASE_LIMIT
55
78
  const len = visibleLength(title)
56
79
  if (len > limit) {
57
80
  reasons.push(`content heading is ${len} characters; the ${layout} layout allows up to ${limit}. Shorten it or use a shorter heading`)