Consolidate UI constants and add accessibility labels - #50
Merged
Conversation
- Extract overlay constants (drag speed, touch dilation, label panel styling) and control panel constants to TrackLabConstants.ts - Add new shared colors (overlay label background/stroke, graph colors) to TrackLabColors.ts - Add localized accessibility strings for all interactive elements across overlays, control panel, measurement tools, info dialog, and graph - Update AngleToolNode, CalibrationToolNode, MeasuringTapeNode, ControlPanel, MeasurementToolsPanel, InfoDialogNode, ConfigurableGraph, and KinematicsGraphNode to use shared constants and a11y strings - Update CLAUDE.md with documentation for new constants and a11y conventions https://claude.ai/code/session_01QY96Kv94K89iT4fHoUbSLi
- Remove stale peer flags in package-lock.json - Fix trailing whitespace and comma in bouncingBallToSVG.ts https://claude.ai/code/session_01QY96Kv94K89iT4fHoUbSLi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR consolidates repeated UI constants into centralized locations and adds comprehensive accessibility labels throughout the application. It improves code maintainability by eliminating duplication and enhances accessibility for screen reader users.
Key Changes
Constants Consolidation
TrackLabConstants.ts: Added new shared constants for overlay interactions and control panels:
CONTROL_ICON_SIZE(20px) — replaces localICON_SIZEdefinitionsCONTROL_PANEL_ROWS_SPACING,CONTROL_PANEL_X_MARGIN,CONTROL_PANEL_Y_MARGIN— shared panel layoutOVERLAY_DRAG_SPEED,OVERLAY_SHIFT_DRAG_SPEED— keyboard drag speeds for all draggable overlaysLABEL_PANEL_*— label panel styling (corner radius, margins, scale)OVERLAY_TOUCH_DILATION— touch target expansion for overlay endpointsInfoDialogNode.ts, ControlPanel.ts, MeasurementToolsPanel.ts: Replaced local icon size and layout constants with imports from
TrackLabConstants.tsIcon geometry constants: Extracted repeated icon dimension calculations into named constants (e.g.,
ICON_ORIGIN_FRACTION,ICON_ARROW_HEAD_SIZE,ICON_DOT_RADIUS) for better readability and maintainabilityColor Consolidation
TrackLabColors.ts: Added new color properties for overlays and tools:
measuringTapeColorProperty,measuringTapeShadowPropertyangleToolColorProperty,angleToolShadowPropertyoverlayHandleOutlineProperty— shared outline color for all overlay endpointsiconShadowProperty— shadow color for measurement tool panel iconscalibrationWarningColorProperty— warning color for overlapping calibration endpointsReplaced hardcoded color strings (e.g.,
"rgb(240, 185, 55)","rgba(0, 0, 0, 0.65)") with color property references throughout view filesAccessibility Enhancements
String additions (strings_en.json, strings_fr.json): Added 23 new a11y strings for:
StringManager.ts: Extended
getA11y()return type with new string propertiesView files: Added
accessibleNameproperties to interactive elements:ControlPanel.ts: Checkbox rows now have accessible namesMeasurementToolsPanel.ts: Checkbox rows now have accessible namesAngleToolNode.ts: Vertex and arm endpoints have accessible namesMeasuringTapeNode.ts: Endpoint handles have accessible namesConfigurableGraph.ts: Graph buttons (rescale, zoom, pan) have accessible namesKinematicsGraphNode.ts: Graph container has accessible nameCode Quality Improvements
Colorfrom CalibrationToolNode.ts)Implementation Details
profileColor()function for automatic dark/light theme supportStringManager.getInstance().getA11y()and passed to componentshttps://claude.ai/code/session_01QY96Kv94K89iT4fHoUbSLi