v0.13.3
Step 3 of docs/elevation-rebuild.md — responsive axes with client-side rendering.
The Elevation chart now mounts client-side under the WordPress Interactivity API and draws two responsive axis lines whose margins are derived from the eventual tick-label widths.
What changed
- Pure geometry helpers under
src/blocks/elevation/geometry/—format.ts(locale-aware label formatting, m/km switch),ticks.ts(nice-tick generation[1,2,5]×10^n),margins.ts(thewLeft = widest(niceYLabels) + 0.5em/wRight = last(niceXLabels)/2 + 0.5em/h = measure("-0,123456789").height + 0.5emformulas), andmeasure.ts(SVG<text>+getBBox()measurer). Fully unit-testable; margins.test.ts injects a mock measurer for a DOM-free run. - Editor preview:
chart.tsxmounts the SVG host, runs the margin algorithm viauseLayoutEffect, and observes resize viaResizeObserver. Loading state returnsnullso the wrapper retains itsmin-height: 15vhslot. - Frontend:
view.tsregisterscallbacks.initElevationon the sharedkntnt-gpx-blocksInteractivity store. It awaitsdocument.fonts.ready, mounts SVG, computes margins, draws axes, and listens forloadingdoneto re-measure when late-loaded webfonts arrive. No store writes yet — Step 6 adds the cursor + fraction wiring. - PHP:
Render_Elevationdropsrender_info(); the Step 2 info box is replaced by the chart wrapper with the documented Interactivity directives +<noscript>fallback. Two new warning reasons land:no-elevation-data(Case A) andzero-distance(Case C). The healthy state emitswp_interactivity_state('kntnt-gpx-blocks', [ $map_id => [ 'statistics' => […] ] ]). - Wrapper sizing:
Dimensions_Defaultsnow injectsmin-height: 15vhon Elevation wheneverminHeightis blank (regardless ofaspectRatio). The SCSS baseline matches. - Editor preview state union grows two warning kinds (
no-elevation-data,zero-distance) plus an editor-onlypayload-errorkind; the healthy branch dispatches to<Chart>.
Acceptance
All five gates green: npm run build, composer test (480 tests, 1565 assertions), phpstan analyse, npm run test:js (341 tests across 28 suites), wp-scripts lint-js src/blocks/.