0.0.35 • Published 7 years ago

navgroups v0.0.35

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

NavGroups

In Development

NavGroup is a flexible and powerful react component for creating ui navigation base around big screen TV's. It allows you to quickly map out a web layout that can be controlled via a keyboard, similar to the type of experience you might find on TV's.

Built With

React: A JavaScript library for building user interfaces

TypeScript: JavaScript that scales.

Setup

For production use install NavGroups using NPM and include it in your own React build process using webpack.

bash $ npm install -save NavGroups

import * as React from "react";
import * as ReactDOM from "react-dom";
import { NgController, NavGroup, NavItem } from "nav-groups";

Development

$ git clone https://github.com/Devine-Davies/NavGroups.git
$ cd NavGroups
$ npm install
$ npm run dev        - Deployment environment
$ npm run start      - Deployment environment
$ npm run prepublish - Deployment environment

HTML Markup & Props

Below illustrates the type of markup used to construct the navgroups react componant. The exsample is given in the from of TSX

index.tsx

import * as React from "react";
import * as ReactDOM from "react-dom";
import { NgController, NavGroup, NavItem } from "nav-groups";

const App = () => (
    <div className='window' >
        <NavGroup name="main-menu" direction="vertical" onLeft="" onRight="ng:last"  >
            <NavItem>Movies</NavItem>
            <NavItem>Music</NavItem>
            <NavItem>Profile</NavItem>
            <NavItem >Setting</NavItem>
        </NavGroup>
        <NavGroup name="movie-list" onLeft="ng:main-menu" onLeft="" >
            <NavItem>Movie .01</NavItem>
            <NavItem>Movie .02</NavItem>
            <NavItem>Movie .03</NavItem>
            <NavItem>Movie .04</NavItem>
        </NavGroup>
    </div>
);

ReactDOM.render(<App />, document.getElementById("example") );

Setting Props for NavGroup && NavItem

Setting propsAvalableTypeDescription
nameNG & NIStringThe name you wish to give the navitem/navgroup. If none given a random one will be generated.
activeClassNameNG & NIStringClass name given to an active navgroup/navitem
directionNGStringCan except "horizontal" or "vertical" the key binding will the change depending on the direction specified
indicateActiveItemNGBooleanWhen decleard on a group attr, the group will add the class of the item name to it's self
historyItemNGBooleanTells the navgroup to remember to remember the last selected navitem and use that as the first selected navitem when entering.
startingPointNIBooleanIs the main item that will be select when first entering the group.
entryPointNIBooleanUse this navitem as the first selected item wehn entering a navgroup, takes priority over historyItem.

Action Props & Instructions

Action props define what type of interaction you want the navgroup/navitem and every action needs an instruction. The Example below show's how these actions are binded to either the NavGroup and NavItem components.

<NavGroup name="movie-list" onLeft="" >
    <NavItem onLeft="" onDown="" >Movie .01</NavItem>
</NavGroup>

Action Props

Action propAvalableDescription
onEnterNG & NIInvoked via the enterkey (↵)
onBackNG & NIInvoked via the backkey (←) is invoked
onUpNG & NIInvoked via the up arrow key (▲) or W
onRightNG & NIInvoked via the right arrow key(►) or D
onDownNG & NIInvoked via the down arrow key(▼) or S
onLeftNG & NIInvoked via the left aorrow key(◄) or A

Default actions are applied and change occordadly depending on the direction of navgroup.

Action propVerticalHorizontal
onUpni:prevng:prev
onRightng:nextni:next
onDownni:nextng:next
onLeftng:prevni:prev

Action instructions

Instructions contain infromation on how the navgroup/navitem should respond when an action has been invoked.

Navgroup instructions

Instructionsis defaultDescription
ng:nextdefaultnext navgroup
ng:prevdefaultprevious navgroup
ng:lastGo to last selected navgroup
ng:{{#}}Go to the given navgroup by index
ng:{{name}}Go to the navgroup by name
hook:{{name}}add the name of your custom hook (must be set up in custom methods )

Navitem instructions

Instructionsis defaultDescription
ni:nextdefaultnext navitem
ni:prevdefaultprevious navitem
ni:lastGo to last item
ni:firstGo to first item
ni:{{#}}Go to the given index of an item
ni:{{name}}Go to the item with that name

It's important to note that NavItem's take priority over NavGroup's instructions.

Instructions can be concatenated together by using the pipe operator (|) For example ng:{{#}}|ni:{{#}}

Programmatically run instruction

Instructions can be invoke via the NgController by calling the run_instructions() methord and then passing the instruction string.

import { NgController, NavGroup, NavItem } from "navgroups";

NgController.run_instructions( 'ng:menu|ni:profile' )

Authors

Rhys Devine-Davies - Profile

License

This project is licensed under the MIT License - see the LICENSE.md file for details`

0.0.35

7 years ago

0.0.34

7 years ago

0.0.33

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago