You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/ui/src/utils/bodygraph-render.ts
+70-2Lines changed: 70 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,8 @@ interface CenterGeometry {
36
36
label: string;
37
37
color: CenterColor;
38
38
points: Point[];
39
+
/** Where the centre name sits, when the shape's middle is taken by a gate number. Defaults to the centroid. */
40
+
labelAt?: Point;
39
41
}
40
42
41
43
/** Traditional center color group: gold for Head and G, green for Ajna, red for the Heart and Sacral motors, brown for the rest. A defined center is filled with it; an open one takes the card surface so the wiring passes behind. */
/** Gate circle and number size, in grid units. Bounded by the closest pair on the chart (Throat 12 and 45, 2.3 apart) and by fitting two digits inside the circle. */
66
68
exportconstGATE_RADIUS=1.02*UNIT;
67
69
exportconstGATE_FONT_SIZE=1.35*UNIT;
70
+
/** The centre name behind the numbers. Smaller than a gate number so it reads as ground rather than as another value. */
71
+
exportconstCENTER_NAME_FONT_SIZE=1.15*UNIT;
68
72
69
73
/** The three x offsets from {@link AXIS} a central-column gate sits on: the inner triples, the outer column of the square centers, and the G's wider waist pair. Named so they cannot drift apart one edit at a time. */
// Drawn with the shapes, so the gate numbers paint over it. Hidden from
493
+
// the accessibility tree because the polygon `<title>` above already
494
+
// names this centre, and announcing it twice is worse than once.
495
+
renderCenterName(label,at,isDefined,c.points),
496
+
];
486
497
});
487
498
}
488
499
500
+
/**
501
+
* The centre name as ground behind the gate numbers.
502
+
*
503
+
* @remarks
504
+
* A multi-word name stacks one word per line rather than running past the shape: the two side triangles taper to a point, so `Solar Plexus` on one line overruns its own outline while `SOLAR` over `PLEXUS` sits inside it. Splitting on whitespace is one rule for every language rather than a width measured per label, and a name that is one long word in some language simply stays one line.
/** Advance width of one uppercase character at the label weight, as a fraction of the font size. Approximate on purpose: it only has to keep a name inside its own outline, and it is applied with room to spare. */
530
+
constUPPERCASE_EM=0.66;
531
+
532
+
/** Horizontal span of a convex polygon at height `y`: how much room a line of text has there. */
Copy file name to clipboardExpand all lines: packages/ui/tests/e2e/parts.e2e.ts
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -229,3 +229,35 @@ test('a component renders no part name the catalog does not publish', async ({
229
229
230
230
expect(surprises).toEqual([]);
231
231
});
232
+
233
+
/**
234
+
* Every centre name stays inside the shape it names.
235
+
*
236
+
* @remarks
237
+
* The names are ground behind the gate numbers, so a name wider than its own outline reads as text spilling onto the chart rather than as a label. It cannot be checked without a browser: the width depends on the rendered font, and the names come from the response, so a translation is a different length in every language. The renderer shrinks a name to the room the shape has at that height, and this is the assertion that makes that non-vacuous.
238
+
*/
239
+
test('no centre name spills outside the centre it names',async({ page })=>{
0 commit comments