@formicoidea/labre-framework-ddd-core-domain 0.42.0 → 0.43.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.
@@ -31,8 +31,13 @@ import { CORE_DOMAIN_ROLE } from '../roles.js';
31
31
  /**
32
32
  * The authoring reference space, kept as documentation of where every ratio
33
33
  * below comes from: the chart was drawn at 900 × 820 with its plot inset by the
34
- * margins declared in {@link CORE_DOMAIN_BACKGROUND}, so the plot is 786 × 746
35
- * and `(absolute - origin) / span` is the conversion.
34
+ * ORIGINAL margins `{ top: 24, right: 54, bottom: 50, left: 60 }`, so the plot
35
+ * is 786 × 746 and `(absolute - origin) / span` is the conversion.
36
+ *
37
+ * These numbers are the conversion and nothing else: they are NOT the margins
38
+ * the chart is drawn with any more (see {@link CORE_DOMAIN_MARGIN}). The ratios
39
+ * below therefore still describe the same picture — the picture simply fills a
40
+ * tighter frame.
36
41
  */
37
42
  const PLOT = { x0: 60, y0: 24, width: 786, height: 746 };
38
43
  /** An absolute X of the reference drawing, as a ratio of the plot. */
@@ -364,6 +369,53 @@ const CORE_DOMAIN_AXES = [
364
369
  ],
365
370
  },
366
371
  ];
372
+ /**
373
+ * The margins, each one the ink it actually hosts — not a round number.
374
+ *
375
+ * The chart used to be inset by `{ top: 24, right: 54, bottom: 50, left: 60 }`,
376
+ * drawn when the frame was authored and never measured since. Measured on the
377
+ * canvas at the authoring size, the ink of a default chart stopped 24.1 units
378
+ * short of the top edge, 50.7 short of the right one, 20.1 short of the bottom
379
+ * and 17.2 short of the left: about a tenth of the element was empty on every
380
+ * side, which is exactly what makes a chart hard to grab — a background is
381
+ * caught by its border (`framework-background/hit-test.ts`), and that border
382
+ * was nowhere near the drawing.
383
+ *
384
+ * So each margin is now the reach of what it hosts, plus room to breathe:
385
+ *
386
+ * - `top` hosts the tip of the vertical arrowhead and nothing else — the tip IS
387
+ * the top of the plot — so 4 units of gutter is the whole of it;
388
+ * - `right` hosts the tip of the horizontal arrowhead — which, like the top
389
+ * one, IS the edge of the plot — and the right half of the "High" tick, which
390
+ * is centred 1.02 % of the plot inside that end and reaches 3.3 units past it
391
+ * in English. 8 covers the tick on a chart of the usual width; a locale whose
392
+ * word is half again as wide overruns the edge by a few units on a narrow
393
+ * chart, which paints fine (the surface clips nothing) and is the same thing
394
+ * the arrowheads already do;
395
+ * - `bottom` hosts the horizontal axis title, whose baseline is 30 below the
396
+ * axis (`dy: 30`), plus a descender the English wording happens not to have
397
+ * (≈ 3.4 at 14px) and a gutter;
398
+ * - `left` hosts the rotated vertical title, written 32 left of the axis
399
+ * (`dx: -32`); rotated, a word reaches into the margin by its ASCENT, not by
400
+ * its length — ≈ 10.8 at 14px, more for an accented capital — hence 48.
401
+ *
402
+ * Nothing about the drawing changed: every ratio above is untouched, so the
403
+ * chart is the same chart. What changed is that the frame now sits on it.
404
+ */
405
+ const CORE_DOMAIN_MARGIN = {
406
+ top: 4,
407
+ right: 8,
408
+ bottom: 37,
409
+ left: 48,
410
+ };
411
+ /**
412
+ * The birth size, chosen so that a NEW chart's plot is the 786 × 746 it has
413
+ * always been: the tighter margins take room off the element, not off the
414
+ * drawing. A chart created before this change keeps its `xywh` and sees its
415
+ * plot grow into the margins instead — the deliberate half of this fix.
416
+ */
417
+ const BIRTH_WIDTH = PLOT.width + CORE_DOMAIN_MARGIN.left + CORE_DOMAIN_MARGIN.right;
418
+ const BIRTH_HEIGHT = PLOT.height + CORE_DOMAIN_MARGIN.top + CORE_DOMAIN_MARGIN.bottom;
367
419
  export const CORE_DOMAIN_BACKGROUND = {
368
420
  type: 'coreDomain',
369
421
  // The chart is a first-class role: validation rules position artefacts
@@ -371,14 +423,14 @@ export const CORE_DOMAIN_BACKGROUND = {
371
423
  role: CORE_DOMAIN_ROLE.chart,
372
424
  variantProp: 'variant',
373
425
  geometry: {
374
- width: 900,
375
- height: 820,
426
+ width: BIRTH_WIDTH,
427
+ height: BIRTH_HEIGHT,
376
428
  lockAspectRatio: true,
377
429
  // The chart has always offered its handles (`resizeEnabled` defaults to
378
430
  // true on the model); the declaration says so, and the toolbar toggle takes
379
431
  // over from there.
380
432
  resizable: true,
381
- margin: { top: 24, right: 54, bottom: 50, left: 60 },
433
+ margin: CORE_DOMAIN_MARGIN,
382
434
  },
383
435
  chrome: {
384
436
  fontFamily: FONT_FAMILY,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formicoidea/labre-framework-ddd-core-domain",
3
3
  "description": "Labre ddd-core-domain framework for @formicoidea/labre-core.",
4
- "version": "0.42.0",
4
+ "version": "0.43.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "author": "lajola",
@@ -31,8 +31,8 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@formicoidea/labre-core": "0.42.0",
35
- "@formicoidea/labre-ddd-shared": "0.42.0",
34
+ "@formicoidea/labre-core": "0.43.1",
35
+ "@formicoidea/labre-ddd-shared": "0.43.1",
36
36
  "lit": "^3.2.0"
37
37
  }
38
38
  }