• Stars
    star
    221
  • Rank 179,773 (Top 4 %)
  • Language
    TypeScript
  • Created over 3 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A visual hierarchy approach to navigate through selectable elements on a page.

Spatial keyboard navigation

A visual hierarchy approach to navigate through selectable elements on a page.

spatia keyboard navigatio example

Example: Use the arrow keys to navigate. See full video bellow.

Motivation

The following project is an experiment and it's still under exploration.

The current way to navigate through selectable elements in a page hasn't changed much, and we are used to considering it the right way to navigate in a DOM document, but I'd like to bring a fresh perspective on this approach.

Human beings generally use visualization methods to memorize and understand the space they are surrounded by. Still, for some reason, the browsers don't use these methods in favor of user experience. The TAB key has been great for a long time and it solves many problems, so what's wrong with using it to navigate in a DOM document?

  • It follows the order of the DOM elements and not the visual position of these elements on the page, which means that it uses the HTML structure (not user-friendly), but it should go after the layout position (spatial position);
  • There is no easy way to jump long distances in the interface: TAB key navigation obligates you to go through all elements between your starting point and the target point;
  • It's hard to memorize the path to select an element on the page because the DOM document doesn't follow a human-friendly order.

Spatial sensitive keyboard navigation

Graphical User Interface has already been using analogies from the real world on the computer universe (e.g., floppy disk for saving files). Bringing a spatial navigation approach might also improve the navigation in a DOM document.

That said, putting all selectable elements in a visual hierarchy structure and using the arrow keys to navigate through them might be the easiest way to introduce this new concept, which would work just like a spreadsheet.

spatial.navigation.mp4

This approach makes it easier and faster to navigate through the selectable elements, plus it doesn't introduce any new aspects and it doesn't require any new learnings from the users.

The memory journey

However, to make navigation even faster and make it even easier to memorize the "paths" the users take on the page, we need to picture that these selectable items belong to a group of items, or that there are "paths" to get to them. These issues lead to the following concepts:

  • Areas: in the real world, you'd expect to see a refrigerator in a kitchen. Just like in the kitchen, Areas gather the things that belong to the same place, putting them together in a big selectable element;
  • Paths: storing and reproducing the finding the shortest path from one point to another, which is often unnoticed by us, is essential to make navigation snappier and more natural.

Usage

To get started, install the package and wrap the whole application using the following Provider component:

import { Provider } from "spatial-keyboard-navigation";

const App = ({ children }) => <Provider>{children}</Provider>;
Prop name Description Type Default value
areaClassName ClassName when the area is selected string area-selected
strictArea It doesn't allow the user navigate beyond the area boundaries. boolean false

Components

Spatial navigation introduces two main components to make the items selectable: Anchor and Area

import { Area, Anchor } from "spatial-keyboard-navigation";

const Sidebar = () => {
  return (
    <Area>
      <section>
        <Anchor>
          <a href="">Item</a>
        </Anchor>
        <Anchor>
          <a href="">Item</a>
        </Anchor>
        <Anchor>
          <button>Item</button>
        </Anchor>
      </section>
    </Area>
  );
};

Reference

Zeh Fernandes

https://en.wikipedia.org/wiki/Method_of_loci

More Repositories

1

react-content-loader

βšͺ SVG-Powered component to easily create skeleton loadings.
TypeScript
13,628
star
2

react-atomic-design

πŸ”¬ How the Atomic Design methodology can create a great design system from scratch and make better developers.
JavaScript
1,771
star
3

create-content-loader

✏️ Tool to create your own react-content-loader easily.
JavaScript
1,224
star
4

coverify

🎧 Web tool that creates album artworks for Spotify playlists, where different fonts, colors, and a ton of images can be applied.
TypeScript
222
star
5

wipe.css

🚿 Stop suffering and resetting styles for every new project. This is a library to reset default styles with some opinionated changes, that you might love (or not).
CSS
113
star
6

I-don-t-know-how-to-name-my-function

πŸ€” Development can be more challenging than you think. It is not about algorithms or data structures, but about naming functions and variables!
TypeScript
75
star
7

gatsby-advanced-blog-system

πŸ“° This repository is a demo from the article about how to build our own blog using Gatsby.
JavaScript
66
star
8

create-vue-content-loader

✏️ Tool to create your own content loader easily in Vue.
JavaScript
60
star
9

react-native-styl

πŸ’… Micro-library that writes stylesheets with a non-opinionated approach, free of dependencies, and in the easiest way possible.
TypeScript
41
star
10

danilowoz.com

Astro
36
star
11

ts-gql-jsx

https://danilowoz.com/blog/generating-typescript-types-and-react-hooks-based-on-graphql-endpoint
TypeScript
27
star
12

sandpack-tsserver

Created with CodeSandbox
TypeScript
14
star
13

my-styled-component

πŸ’… My own implementation of styled-components within 100 lines of code.
JavaScript
9
star
14

hype-todolist

πŸ”¦ A todo list using Redux, GraphQL, Apollo, Webpack and Postcss from scratch
JavaScript
5
star
15

ide-concept

Created with CodeSandbox
TypeScript
4
star
16

Vuesualizen

🎯 The Vuesualizen will be a Chrome Extension that helps you attract your life goals by automatically showing it to you every day as a new tab in the browser.
JavaScript
4
star
17

myzshrc

2
star
18

create-react-content-loader

HTML
2
star
19

JavaScript-Design-Patterns

HTML
2
star
20

barcode-playground

HTML
2
star
21

fileupload-react

Just another playground in React
JavaScript
2
star
22

reason-movie-app

Reason
2
star
23

talkey

My version of ReactJs
JavaScript
1
star
24

monorepo-semantic-release

TypeScript
1
star
25

github-block-examples

1
star
26

github-actions-for-packages

JavaScript
1
star