How jamesplease/lrud works
Main Components
• Focus Management Core – At the heart is the FocusStore which maintains the state including focus hierarchy, current focused node, active node, and event propagation. This connects to all functions that update or retrieve state.
• Focus Components – Your “View Layer” represented by React components such as:
• <FocusRoot>: The top-level node that sets global orientation, wrapping, and serves as the anchor of the focus tree.
• <FocusNode>: Represents individual focusable nodes. They encapsulate properties like focusId, orientation, grid navigation details, event callbacks (e.g., onArrow, onSelected) and CSS classes.
• Utilities and Internal Functions – Helpers found in “src/utils” and in the “src/focus-store,” which are responsible for computations and state validations (e.g., creating, updating, or deleting nodes).
Architectural Patterns
• Component-Based Architecture:
• Separation of concerns: UI components are “dumb” wrappers (FocusRoot/FocusNode) that delegate to internal logic.
• The Focus Management pattern is intermediary between user inputs and DOM updates, ensuring that focus changes propagate through the component tree.
• Event Propagation:
• Hook Abstraction:
• Focus hooks encapsulate logic for interacting with the focus tree. Illustrate how these hooks (mounted in the consuming application) access FocusStore state and trigger imperative commands (like setFocus).
Technologies and Frameworks
• React is the key framework.
Detail Without Overcomplicating
• A side section summarizing “Examples” and “Guides” that show practical use cases.