You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-navbar

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-navbar

React.js component rendering a translatable menu bar with Twitter Bootstrap Navbar HTML markup

3.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Build Status

Overview

React.js component rendering a translatable menu bar with Twitter Bootstrap Navbar HTML markup. For example, for a menu structure like the that:

+-------------+--------+--------+---------------+-------------+--------+
|             |        |        |               |             |        |
| Drop-down-1 | Item-1 | Item-2 |               | Drop-down-2 | Item-3 |
|             |        |        |               |             |        |
+-------------+--------+--------+---------------+--+----------+--------+
                                                   |          |
                                                   | Item-2-1 |
                                                   |          |
                                                   +----------+
                                                   |          |
                                                   | Item-2-2 |
                                                   |          |
                                                   +----------+

one would have to initialize a Navbar component instance in the following way:

import * as React from 'react'
import * as ReactDOM from 'react-dom'
import {IntlProvider} from 'react-intl'
import {default as Navbar, MenuElementKind} from 'react-navbar'

const {ITEM, DROPDOWN} = MenuElementKind

const menuItems = [{
    kind: DROPDOWN,
    title: 'menu.dd1',

    items: [
        {kind: ITEM, title: 'menu.i11', href: '/resource-1-1', target: '_blank'},
        {kind: ITEM, title: 'menu.i12', href: '/resource-1-2'}
    ]
},
{kind: ITEM, title: 'menu.i1', href: '/resource-1'},
{kind: ITEM, title: 'menu.i2', href: '/resource-2'}]

const secondaryMenuItems = [{
    kind: DROPDOWN,
    title: 'menu.dd2',

    items: [
        {kind: ITEM, title: 'menu.i21', href: '/resource-2-1'},
        {kind: ITEM, title: 'menu.i22', href: '/resource-2-2'}
    ]
},
{title: 'menu.i3', href: '/resource-3'}]

const localeSpecificIcuMessagesForTheWholeAppCompiledOnTheServer = {
    'menu.dd1': 'Drop-down-1',
    'menu.i11': 'Item-1-1',
    'menu.i12': 'Item-1-2',
    'menu.i1': 'Item-1',
    'menu.i2': 'Item-2',
    'menu.i3': 'Item-3',
    'menu.dd2': 'Drop-down-2',
    'menu.i21': 'Item-2-1',
    'menu.i22': 'Item-2-2'

    // ...
}

ReactDOM.render(
    <IntlProvider
    locale='en'
    messages={localeSpecificIcuMessagesForTheWholeAppCompiledOnTheServer}>
        <Navbar {...{menuItems, secondaryMenuItems}}/>
    </IntlProvider>,

    document.getElementById('root')
)

The secondaryMenuItems are optional.

Internationalization

Navbar is react-intl-based. The i18n message keys are the values of title-s of menuItems and secondaryMenuItems.

react-intl foundation allows using react-navbar uniformly in bigger applications, and passing all the translations, from the root, down the React components hierarchy, — automatically, with the help of the IntlProvider.

Keywords

TypeScript

FAQs

Package last updated on 14 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts