npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reactive-compass

v0.0.5

Published

React mixin and focus controller for navigation using arrow keys

Downloads

2

Readme

Reactive-Compass

Reactive compass is a navigation controller for keyboard navigation based systems. Initially developed for Smart TV and embedded devices utilizing IR Remote.

Grid example

Navigation

You navigate the app using Arrow keys. The proper element gets 'focused', and then you can perform actions on that element using different keyboard keys.

Navigation map

Whole navigation is built into a navigation tree. The leafs are focusable elements, the tree nodes are holding those focusable elements or other nodes. Navigation nodes can act as:

  • Grids - navigation in both directions
  • Horizontal lists - navigation using arrow_down and arrow_up
  • Vertical lists - navigation using arrow_left and arrow_right
  • Leaves - focusable elements

Reactive Compass architecture.

Reactive compass is composed of two elements:

  • navigation.controller - a singleton holding root of navigation tree and listening on key events in the application
  • navigation.mixin - a mixin to include into all navigable nodes.

Adding navigation to application

  1. Every element in your navigation tree needs to have navigation.mixin mixed in,
  2. Every element in your navigation tree needs to call this.navInit() in render() method. This properly registers element in navigation tree,
  3. Every parent node in your navigation tree needs to call navEach on children elements. This adds two properties: navParent property, which is parent.navSelf returning self.
  4. Focusable items (leaves in the tree) will receive focused state. You can translate it into class, attribute or whatever works for you. I just add the focused className.
  5. Every element can specify navHandleKey method, which can capture ENTER or any other key

Lists

Node can be a Horizontal list or a vertical lists.

  • Horizontal lists are traversed using LEFT and RIGHT arrows. To make a node a horizontal list, just add navType='horizontal' attribute to it.
  • Vertical lists are traversed using UP and DOWN arrows. To make a node a vertical list, just add navType='vertical' attribute to it. If you want to wrap a list, add navWrap="wrap" to a list.

Grids

Node in navigation tree can be a grid. You can traverse grids using both up, down, left and right keys. To make node a grid:

  • Add navType="grid" attribute to it,
  • Add navGridCols attribute specifying number of columns you want in your grid,
  • For grid children it is important to call navEach for each of its children, because grid logic is a little bit more complicated
  • If you want to wrap a grid, you can set navWrap="wrapX", navWrap="wrapY" or navWrap="wrap" to wrap it in both dimensions.

Focusable elements

As mentioned, ocusable items (leaves in the tree) will receive focused state. You can translate it into class, attribute or whatever works for you. I just add the focused className.

Examples

All example are on branch "example" in "examples" directory. This is by design. When you clone the repository or use it as submodule probably you dont want to have examples in your working app. To run any of these examples, checkout example branch, go to folder containing the example, install npm modules (npm install), build (npm run build) and you can open the example in your browser.

Current examples include: