All Projects → oklas → React Breadcrumbs Dynamic

oklas / React Breadcrumbs Dynamic

Licence: mit
🏡 > breadcrumbs > extremely flexible > and > easy to use

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Breadcrumbs Dynamic

SemanticBreadcrumbLinks
Provides in-page navigation by building breadcrumb links from an attributive property filter.
Stars: ✭ 15 (-87.07%)
Mutual labels:  breadcrumbs
Loaf
Manages and displays breadcrumb trails in Rails app - lean & mean.
Stars: ✭ 360 (+210.34%)
Mutual labels:  breadcrumbs
Wordpress Seo
Yoast SEO for WordPress
Stars: ✭ 1,301 (+1021.55%)
Mutual labels:  breadcrumbs
gatsby-simple-blog
an easily configurable gatsby-starter-blog with overreacted looking and tags, breadcrumbs, disqus, i18n, eslint, algolia supported
Stars: ✭ 48 (-58.62%)
Mutual labels:  breadcrumbs
React Router Breadcrumbs Hoc
tiny, flexible, HOC for rendering route breadcrumbs with react-router v4 & 5
Stars: ✭ 276 (+137.93%)
Mutual labels:  breadcrumbs
Wp Structuring Markup
🔌 WordPress: Plug-in Markup (JSON-LD) structured in schema.org
Stars: ✭ 26 (-77.59%)
Mutual labels:  breadcrumbs
joplin-note-tabs
Allows to open several notes at once in tabs and pin them.
Stars: ✭ 150 (+29.31%)
Mutual labels:  breadcrumbs
Xng Breadcrumb
A lightweight, configurable and reactive breadcrumbs for Angular 2+
Stars: ✭ 106 (-8.62%)
Mutual labels:  breadcrumbs
Django Sitetree
Reusable application for Django introducing site tree, menu and breadcrumbs navigation elements.
Stars: ✭ 330 (+184.48%)
Mutual labels:  breadcrumbs
Vue 2 Breadcrumbs
Vue breadcrumbs
Stars: ✭ 76 (-34.48%)
Mutual labels:  breadcrumbs
raygun4ruby
The Ruby & Ruby on Rails provider for Raygun
Stars: ✭ 37 (-68.1%)
Mutual labels:  breadcrumbs
m2.Breadcrumbs
Magento2. Extension add breadcrumbs to pages in Magento2 that by default do not have breadcrumbs.
Stars: ✭ 17 (-85.34%)
Mutual labels:  breadcrumbs
Grav Plugin Breadcrumbs
Grav Breadcrumbs Plugin
Stars: ✭ 15 (-87.07%)
Mutual labels:  breadcrumbs
vue-crumbs
a simple and useful breadcrumb for Vue2.js
Stars: ✭ 16 (-86.21%)
Mutual labels:  breadcrumbs
Bootstrap Breadcrumbs
Django template tags for easy breadcrumbs using twitter bootstrap css classes or custom template
Stars: ✭ 91 (-21.55%)
Mutual labels:  breadcrumbs
DNTBreadCrumb.Core
DNTBreadCrumb.Core Creates custom bread crumb definitions, based on Twitter Bootstrap 3.x features for ASP.NET Core applications.
Stars: ✭ 32 (-72.41%)
Mutual labels:  breadcrumbs
React Tunnels
🚇 Render React components in placeholders that are placed somewhere else in the component tree.
Stars: ✭ 398 (+243.1%)
Mutual labels:  breadcrumbs
Smartbreadcrumbs
A utility library for ASP.NET Core (both MVC and Razor Pages) websites to easily add and customize breadcrumbs.
Stars: ✭ 113 (-2.59%)
Mutual labels:  breadcrumbs
Magento 2 Seo
Magento 2 SEO extension will do perfectly for your better SEO. This is a bundle of outstanding features that are auto-active when you install it from Mageplaza without any code modifications. It is also friendly with your store if you need to insert meta keywords and meta descriptions for your product.
Stars: ✭ 99 (-14.66%)
Mutual labels:  breadcrumbs
Ng2 Breadcrumbs
A breadcrumb service for the Angular 7 router
Stars: ✭ 61 (-47.41%)
Mutual labels:  breadcrumbs

react-breadcrumbs-dynamic

Npm package Npm downloads Travis build status Test Coverage Dependency Status Dependency Status Dependency Status


🏠 > React dynamic breadcrumbs > extremely flexible > and > easy to use

This is completely router-independent solution. You can use it with any version of React Router (2 or 3 or 4) or any other routing library for React or without routing at all. All what you need is just to specify components for breadcrumbs items and its props. However props and components should be specified separately. Props should be specified in intermediator component BreadcrumbsItem anywhere in your hierarchy of components and routes.

Visit live DEMO (source code of demo in example folder)

Synopsis

const Profile = ({user}) => (
  <div>

    <BreadcrumbsItem
      to=`/user/${user.login}`
      icon='account-box'
    >
      {user.firstName} {user.lastName}
    </BreadcrumbsItem>

    <h1>
      {user.firstName} {user.lastName}
    </h1>
  </div>
)

Installation

npm install --save react-through react-breadcrumbs-dynamic

# definitions may be installed if typescript is used
# ( worked for 1.0.10, leave feedback if any )
npm install --save @types/react-breadcrumbs-dynamic

Base configuration

Do you already use declarative communications through react tree with react-through? Just add <ThroughProvider/> to the root of your React component tree:

import {ThroughProvider} from 'react-through'

const theApp = (
  <ThroughProvider>
    <App />
  </ThroughProvider>
)

ReactDOM.render(theApp, document.getElementById('root'))

Instance configuration

In this example the react-router v4 <NavLink> is used as breadcrumbs item:

import {Breadcrumbs} from 'react-breadcrumbs-dynamic'

const Page = (props) => (
  return (
    <div className="App">
      <Header>

        <Breadcrumbs
          separator={<b> / </b>}
          item={NavLink}
          finalItem={'b'}
          finalProps={{
            style: {color: 'red'}
          }}
        />

      </Header>

      {props.children}

      <Footer>
        <Breadcrumbs/>
      </Footer>
    </div>
  )
}

Please note that item and finalItem require react component (class) instead of react element. However separator requires react element.

By default order of items is based on URL length. You can override the sort order as you like just specify comparision function in compare prop which receive pair of objects containing props of breadcrumbs item. For example: <Breadcrumbs compare={(a,b)=>a.weight-b.weight} removeProps={{weight: true}} />.

If you use <a> tag based items then you will find renameProps or duplicateProps useful to map prop to on prop href like this: <Breadcrumbs renameProps={{to:"href"}} />.

Adding items to breadcrumbs

Each routed component in your react tree is generally associated with route and with correspondent breadcrumbs. Each component may add its breadcrumbs item by rendering <BreadcrumbsItem> with any props and children.

Example tree of routed components with breadcrumbs items:

import {BreadcrumbsItem} from 'react-breadcrumbs-dynamic'

const App = (props) => (
  <div>
    <BreadcrumbsItem to='/'>Main Page</BreadcrumbsItem>
    {props.children}
    <Route exact path="/user" component={User} />
  </div>
)

const User = (props) => (
  <div>
    <BreadcrumbsItem to='/user'>Home</BreadcrumbsItem>
    <h2>Home</h2>
    {props.children}
    <Route exact path="/user/contacts" component={Contacts} />
  </div>
)

const Contacts = (props) => (
  <div>
    <BreadcrumbsItem to='/user/contacts'>Contacts</BreadcrumbsItem>
    <h2>Contacts</h2>
    ...
  </div>
)

You can declaratively pass props with any data, functions, components and so on through react tree in any direction because react-through allows to do that.

Result

The result of above code will represent breadcrumbs like this:

  <NavLink to='/'>Main Page</NavLink>
  <b> / </b>
  <NavLink to='/user'>Home</NavLink>
  <b> / </b>
  <b to='/user/contacts'>Contacts</b>

If you use library or if you think that it is good for use - let people know about that - click the star.


The components and functions

Breadcrumbs component props

The breadcrumbs instance is implemented in the Breadcrumbs component, which is the through container in terms of react-through.

property type default description
separator element undefined separator between breadcrumbs items
item component a component of breadcrumbs items
finalItem component value of item prop component of final breadcrumbs item
finalProps object {} final item props - will override specified in BreadcrumbsItem
container component span wrapper component
containerProps object {} props for container component
compare function (a,b)=>a.to.length-b.to.length comparision function for sorting items
hideIfEmpty boolean false show or hide breadcrumbs container if items exist or not
renameProps object {} rename props passed from item BreadcrumbsItem to item
duplicateProps object {} duplicate props passed from item BreadcrumbsItem to item
removeProps object {} props aren't passed from item BreadcrumbsItem to item

BreadcrumbsItem component props

The BreadcrumbsItem component is the through agent with bearing key in prop to in terms of react-through.

The BreadcrumbsItem component may have any prop and may have children. Each prop for BreadcrumbsItem will be passed to correspondent breadcrumb component specified in item or finalItem prop of Breadcrumbs. Only one prop is mandatory.

property type default description
to string required mandatory required bearing key with URL
... any any properties - will be mapped to correspondent breadcrumb item

withBreadcrumbsItem() function

Advanced usage higher order component function. It acquire one argument with your custom react component and return appropriate component which will have breadcrumbs in its props with methods item() and items() like throughAgent from react-through.

this.props.breadcrumbs.item() and this.props.breadcrumbs.items()

Advanced usage methods to configure breadcrumbs item of your react component. These methods will be added to props by HOC of withBreadcrumbsItem function. The function item() accepts one react component with props and the functions items() accepts react component with children which may contain any number of components to create correspondent number of breadcrumbs item. The breadcrumbs item for these functions may be any react component and only props is significant. The Dummy and the Item components is exported by library for this case. Each function accepts null to reset breadcrumbs items to none if current component is no more needed to represent any breadcrumbs items.

constants

The through area name used by this library is defined in breadcrumbsThroughArea variable.

The prop name which contain bearing key is defined in breadcrumbsBearingKey.

import { breadcrumbsThroughArea } from 'react-breadcrumbs-dynamic'
import { breadcrumbsBearingKey } from 'react-breadcrumbs-dynamic'

LICENSE

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].