# @scripty/react-navigations

> lightweight react navigation components.

Latest version **0.4.13** (published 2020-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @scripty/react-navigations
pnpm add @scripty/react-navigations
yarn add @scripty/react-navigations
bun add @scripty/react-navigations
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.13 |
| Published | 2020-07-27 |
| First published | 2020-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 430.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Danijel Garic |
| Maintainers | garic |
| Keywords | react, navigations, react navigations, react components, react-breadcrumbs, breadcrumbs, user navigation, user menu |

## Links

- npm: https://www.npmjs.com/package/@scripty/react-navigations
- Repository: https://github.com/scripty08/react-navigations
- Homepage: https://garic.biz
- Issues: https://github.com/scripty08/react-navigations/issues
- npm.io page: https://npm.io/package/@scripty/react-navigations

## Dependencies (7)

- [react](https://npm.io/package/react.md) 16.11.0
- [react-dom](https://npm.io/package/react-dom.md) 16.11.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.10.4
- [@scripty/styles](https://npm.io/package/@scripty/styles.md) ^0.1.2
- [react-router-dom](https://npm.io/package/react-router-dom.md) ^5.2.0
- [@ant-design/icons](https://npm.io/package/@ant-design/icons.md) ^4.2.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.4.13 (latest) — 2020-07-27
- 0.4.12 — 2020-07-27
- 0.4.11 — 2020-07-24
- 0.4.10 — 2020-07-20
- 0.4.9 — 2020-07-12
- 0.4.8 — 2020-07-12
- 0.4.7 — 2020-07-12
- 0.4.6 — 2020-07-12
- 0.4.5 — 2020-07-12
- 0.4.4 — 2020-07-12
- 0.4.3 — 2020-07-12
- 0.4.2 — 2020-07-12
- 0.4.1 — 2020-07-12
- 0.4.0 — 2020-07-12
- 0.3.0 — 2020-07-12
- … 11 more at https://npm.io/package/@scripty/react-navigations/versions

## README

# @scripty/react-navigations

# Description

lightweight react navigation components.

![alt text](./navigations1.png "@scripty/react-navigations")

# Usage
```bash
npm install -s @scripty/react-navigations
```

The navigation components are powered by Antd-Design-Icons:
https://ant.design/components/icon/

Just add the name of the desired icon as a string property (see example).

#####if you want a leightweighter version, use "Flyout"-Component instead of "FlyoutWithIcons"-Component.

##### Client: Example.jsx

```javascript
import React, { useState } from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { FlyoutWithIcons } from '@scripty/react-navigations/lib/FlyoutWithIcons';
import { Breadcrumbs } from '@scripty/react-navigations/lib/Breadcrumbs';
import { FlyoutUser } from '@scripty/react-navigations/lib/FlyoutUser';
import { FlyoutUserWithIcons } from '@scripty/react-navigations/lib/FlyoutUserWithIcons';

export const Example = () => {

    const [ selectedKeys, setSelectedKeys ] = useState([])

    const onClick = (key, selectedKeys) => {
        setSelectedKeys(selectedKeys);
    }

    const routes = [
        {
            "key" : "Dashboard",
            "label" : "Dashboard",
            "icon" : "DashboardOutlined",
            "path" : "/",
            "exact" : true
        },
        {
            "key" : "Example",
            "label" : "Example",
            "icon" : "BankOutlined",
            "path" : "/example",
            "submenu" : [
                {
                    "key" : "Sub-1",
                    "label" : "Sub 1",
                    "path" : "/sub1",
                    "icon" : "CloudServerOutlined",
                    "submenu" : [
                        {
                            "key" : "Sub-1-1",
                            "label" : "Sub-1-1",
                            "path" : "/sub-1-1",
                            "icon" : "CreditCardFilled",
                        }
                    ]
                },
                {
                    "key" : "Sub-2",
                    "label" : "Sub-2",
                    "path" : "/sub-2",
                    "icon" : "InsuranceOutlined",
                    "submenu" : [
                        {
                            "key" : "Sub-2-1",
                            "label" : "Sub-2-1",
                            "path" : "/sub-2-1",
                            "icon" : "ProfileTwoTone",
                        }
                    ]
                },
                {
                    "key" : "Sub-3",
                    "label" : "Sub-3",
                    "path" : "/sub-3",
                    "icon" : "ShakeOutlined",
                },
                {
                    "key" : "Sub-4",
                    "label" : "Sub-4",
                    "path" : "/sub-4",
                    "icon" : "SnippetsTwoTone",
                    "submenu" : [
                        {
                            "key" : "Sub-4-1",
                            "label" : "Sub-4-1",
                            "path" : "/sub-4-1",
                            "icon" : "ThunderboltFilled",
                        },
                        {
                            "key" : "Sub-4-2",
                            "label" : "Sub-4-2",
                            "path" : "/sub-4-2",
                            "icon" : "VerticalLeftOutlined",
                        }
                    ]
                }
            ]
        }
    ];

    const userMenuRoutes = [
        {
            "key" : "UserMenu",
            "label" : "Login",
            "path" : "/login",
            "exact" : true,
            "submenu" : [
                {
                    "key" : "Profile",
                    "label" : "Profile",
                    "path" : "/profile",
                    "icon" : "UserOutlined",
                },
                {
                    "key" : "Settings",
                    "label" : "Settings",
                    "path" : "/settings",
                    "icon" : "SettingOutlined",
                }
            ]
        }
    ];

    const loggedInUser = {
        username: 'Danijel',
        loggedIn: true,
        avatar: {
            url: 'https://s.gravatar.com/avatar/d363403799aa4b4de34c36bc290ebe12?size=50&default=retro'
        }
    };

    const loggedOutUser = {
        loggedIn: false,
    };

    return (
        <Router>
            <h2>Breadcrumbs</h2>
            <Breadcrumbs onClick={onClick} routes={[ ...routes, ...userMenuRoutes ]} selectedKeys={selectedKeys} />

            <h2>Flyout</h2>
            <FlyoutWithIcons onClick={onClick} routes={routes} selectedKeys={selectedKeys} />

            <h2>Flyout logged in user</h2>
            <FlyoutUser loginPath={'/login'} user={loggedInUser} onClick={onClick} routes={userMenuRoutes} selectedKeys={selectedKeys} />

            <h2>Flyout logged in user with icons</h2>
            <FlyoutUserWithIcons user={loggedInUser} onClick={onClick} routes={userMenuRoutes} selectedKeys={selectedKeys} />

            <h2>Flyout logged out user</h2>
            <FlyoutUser loginPath={'/login'} user={loggedOutUser} onClick={onClick} routes={userMenuRoutes} selectedKeys={selectedKeys} />
        </Router>
    );
};
```
# Components

Name              | Description                                         |
----------------- |---------------------------------------------------- |
Flyout            |  3 Level Flyout Navigation                          |
FlyoutWithIcons   |  3 Level Flyout Navigation with Antd-Icons library  |
Breadcrumbs       |  Breadcrumbs based on given routes                  |

# Flyout / WithIcons Properties

Property           | Type     |  Default  |
------------------ |--------- |-----------
onClick            | Function |
routes             | Array    |
selectedKeys       | Array    |

# Route Properties

Property           | Type     |  Description             |
------------------ |--------- |--------------------------|
key                | String   | unique id key (required) |
label              | String   | (required)               |
path               | String   | (required)               |
icon               | String   | (optional)               |

# Breadcrumbs Properties

Property           | Type     |  Default  |
------------------ |--------- |-----------
onClick            | Function |
routes             | Array    |
selectedKeys       | Array    |

# FlyoutUser / WithIcons Properties

Property           | Type     |  Default  |
------------------ |--------- |-----------
onClick            | Function |
routes             | Array    |
selectedKeys       | Array    |
user               | Object   | {loggedIn: false}
loginPath          | String   | /login

---
_Source: https://npm.io/package/@scripty/react-navigations · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
