Skip to content

feat(core): Standardize API for named text areas/zones across CardBase, Slider, and Elbow (multi-zone system) #321

@snootched

Description

@snootched

Motivation

  • Multiple card types (slider, elbow, button SVG presets) now want named text zones for text field routing (e.g., left border, right border, vertical/horizontal arm in elbows, center area, etc).
  • The current implementation only supports named text areas in sliders (zones), and component SVG presets in buttons (via componentTextAreas). There's no unified API at the LCARdSCard base.

Proposal

1. Extend LCARdSCard base class with zone support

  • Add a _zones: Map property (empty by default) to LCARdSCard.
  • Add a common _injectTextFieldsToElement() supporting text area routing by zone.
  • Define new interface method: _calculateZones(width, height) (to be implemented by concrete subclasses if support is desired).

2. Implement named zones by card type

  • Slider:
    • Populate _zones using same border/center logic as now, migrated to the base interface.
  • Elbow:
    • Add _calculateZonesFromElbowGeometry(width, height) to define zones for horizontal/vertical arms, outer/inner segmented bars, body, etc.
    • Zones: horizontal_bar, vertical_bar, outer_horizontal_bar, inner_vertical_bar, body, etc., as per geometry.
  • Button (component SVG presets):
    • Migrate current componentTextAreas to populate _zones, so text area routing is consistent.

3. Routing and Editor

  • All cards with zones expose them as text_area dropdowns for each text field in the editor.
  • Only valid/present zones for the current config are enabled in the editor UI.
  • Default to body (central area) if unspecified.

4. Consistency and Extensibility

  • All zone routing uses the same property/interface (text_area) and naming conventions, for DRY code and user consistency.
  • Later, custom user-defined zones can be added to the API (not initial scope).

5. Documentation

  • Update dev docs to cover new zone system, example zone maps for each card type, migration paths, and how to add zones for third-party cards.

Benefits

  • Unified, extensible multi-text placement system for all LCARS card types
  • Zones become a first-class citizen; easy extensibility for future features
  • Consistent WYSIWYG routing and predictability for users; visually aligned text between cards
  • Path to user-defined custom zones in the future

Reference: see #317 for slider text area overhaul.

/cc @snootched

Metadata

Metadata

Assignees

Labels

core-textRelated to text fieldslcards-buttonRelated to lcards-button cardlcards-elbowRelated to lcards-elbow cardlcards-sliderRelated to lcards-slider card

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions