1.1.4 • Published 6 years ago

rb-navbar v1.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Navbar - React Basics

A React Basics Navbar component. Stateless, fully optimized with css animations, highly customizable, SEO support with Schemas.org and Mobile tap support.

Installation

Into your project's root directory run the following command:

npm

npm i -P rb-navbar

Yarn

yarn add rb-navbar

This package only has 3 dependencies:

  • react@16.2.0
  • font-awesome@4.7.0
  • react-device-detect@1.0.0

Example

Navbar is one of the components inside React Basics, so if you want test it, go https://edgravill.github.io/react-basics and see it working.

The website is under construction

Usage

Component takes 100% of the parent's width.

import React from 'react';
import Nav from 'rb-navbar';

const Index = () => (
  <div>
    <Nav
      backgroundColor="#ecf0f1"
      color="#34495e"
      links={[{
        href: '/',
        title: 'Home',
        icon: 'home'
      }, {
        href: '/about',
        title: 'About Us',
      }, {
        href: '/work',
        title: 'Our Work',
      }]}
    />
  </div>
);

Dropdown elements also are supported

See in work section below

import React from 'react';
import Nav from 'rb-navbar';

const Index = () => (
  <div>
    <Nav
      backgroundColor="#ecf0f1"
      color="#34495e"
      links={[{
        href: '/',
        title: 'Home',
        icon: 'home'
      }, {
        href: '/about',
        title: 'About Us',
      }, {
        href: '/work',
        title: 'Our Work',
        links: [{
          href: '/work/web',
          title: 'Web',
        }, {
          href: '/work/mobile',
          title: 'Mobile',
        }]
      }]}
    />
  </div>
);

API

PropRequiredTypeDefaultDescription
AnchorComponentfalseReact$Element<any>undefinedCustom anchor component, this is useful when integrates a react router.
backgroundColorfalsestring'#4A5459'Background of the Navbar.
brandfalseObjectundefinedObject with the brand or company basic information. It just display the info. See Object definition below.
colorfalsestring'#ecf0f1'Color of all fonts in Navbar.
heightfalsenumber48Height of the Navbar.
linksfalseArray<Object>[{ href: '/', title: 'Home', icon: 'home' }]Array of the links object. See Object definition below.
searchfalseObjectundefinedObject with the search options, this enables a searchbar inside Navbar. See Object definition below.
stylefalseObject{}Styles object.
userBoxfalseObjectundefinedObject with userBox options, this enables a box where can add a login/user info. See Object definition below.

Object definitions

brand

KeyRequiredTypeDefaultDescription
nametruestringundefinedDisplay name
iconfalsestringundefinedFont Awesome Icon Name
Example
const brand = {
  name: 'React',
  icon: 'react',
};

links

KeyRequiredTypeDefaultDescription
hreftruestringundefinedURL.
titletruestringundefinedDisplay Link Name.
iconfalsestringundefinedFont Awesome Icon Name.
linksfalseArray<Object>undefinedEnables dropdown taking same Object definition as links object.
Example
const links = {
  href: '/',
  title: 'Home',
  icon: 'home',
  links: [{
    href: '/about',
    title: 'About',
    icon: 'help',
  }],
};

search

KeyRequiredTypeDefaultDescription
mediumPlaceholderfalsestringSearchPlaceholder to show in medium size if size is "medium" and is not active
sizefalseEnum: 'big' | 'medium' | 'small''medium'Size and style of the search bar
placeholderfalsestring'Type something to search'Placeholder to show in size big or if actiive
onChangefalseFunctionundefinedFunction dispatch on type something and pass as param current value.
onSubmittrueFunctionundefinedFunction dispatch on enter and pass as param current value.
widthfalsestring20remWidth of the searchbar in size big
const search = {
  mediumPlaceholder: 'Search',
  size: 'medium',
  placeholder: 'Type something to search',
  onChange: value => prepareSearch(value),
  onSubmit: value => search(value),
  width: '20rem',
};

userBox

KeyRequiredTypeDefaultDescription
iconfalsestringundefinedFont Awesome icon name to display aside the text.
texttruestringundefinedTex to display in navbar.
boxtrueReact$ElementundefinedDisplay Element inside the box when user hover the text.
Example
import Button from 'rb-buttons'; // <- Good package ;)

const userBox = {
  icon: user.isLogged ? 'user' : 'sign-in-alt',
  text: user.isLogged ? user.username : 'Sign In',
  box: user.isLogged ? () => (
    <div>
      <h3>Sign In</div>
      <form id="navbarSignIn">
        <input name="username" placeholder="Username" />
        <input type="password" name="password" placeholder="Password" />
        <Button text="Enter" loading={user.siging} />
      </form>
    </div>
  ) : () => (
    <div>
      <h3>Hello again {user.name}</h3>
    </div>
  ),
};

Goals

  • Mobile tap to open dropdown (Since v1.0.0)
  • SEO support with Schemas.org (Since v1.0.0)
  • Support custom anchor tag. For routers (Since v1.1.0)
  • Integration of other icons (Under develop)
  • Mobile responsive (Under develop)

looking for more? - Do a pull request with your proposals ;)

Collaborators

  • Eduardo Grajales Villanueva @EdGraVill

If you want to collaborate with this or another exist or new component inside React Basics, first do a pull request and then email me: edgravill@gmail.com

If you want pull request some changes, don't forget build it firt with the following command:

npm

npm run build

Yarn

yarn build

Once you're a collaborator don't forget 3 rules:

  1. Version are Mayor (If APIs are deleted or create new one) . Medium (If APIs changes without changing name) . Minimum (If do some hotfix, change Documentation or develop configurations). This is because all 1.x.x are compatible, but are incompatible with 2.x.x
  2. Build a great components and do the best documentation as you can.
  3. Share with your developer friends. It would be useful for them.

Don't forget join discussion on Slack

License

MIT License

Copyright (c) 2018 Eduardo Grajales Villanueva

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

1.1.4

6 years ago

1.1.3

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago