npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

navbar_chsm

v1.4.0

Published

A customizable React Navbar component with support for Bootstrap, routing, and WebSocket notifications. Includes support for dynamic notifications via WebSocket or other backends.

Downloads

338

Readme

Navbar Component

A customizable and responsive navigation bar component for React applications. It includes support for Bootstrap styling, routing, and real-time notifications via WebSocket or other backends (like Socket.io).

Installation

Install required dependencies

To install the dependencies required for the Navbar component, run the following command:

npm install react react-router-dom dompurify bootstrap bootstrap-icons

Install navbar_chsm component

To install the navbar_chsm component, run the following command:

npm install navbar_chsm

Usage

Import the Navbar component into your application and use it as follows:

import React from 'react';
import Navbar from 'navbar_chsm'; // Import the navbar_chsm component
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap-icons/font/bootstrap-icons.css';

const App = () => {
  const links = [
    { path: '/', label: 'Home' },
    { path: '/about', label: 'About' },
    { path: '/contact', label: 'Contact' },
  ];

  return (
    <div>
      <Navbar
        title="Amazing Blog"
        links={links}
        showNotifications={true} // Toggle notifications
        websocketUrl="wss://example.com/websocket" // WebSocket URL for notifications
        socketLibrary="websocket" // Use "socket.io" if using Socket.io instead of WebSocket
        customStyles={{
          navbar: { backgroundColor: '#333' },
          title: { color: '#fff' },
        }}
      />
      {/* Other components */}
    </div>
  );
};

export default App;

Props

The Navbar component accepts the following props:

  • title (string): The title of the navbar. Default is 'Amazing Blog'.
  • links (array): An array of link objects with path and label properties.
  • showNotifications (bool): Whether to show the notifications icon. Default is true.
  • websocketUrl (string): The WebSocket URL for receiving notifications. Default is null. If you're using Socket.io, pass the appropriate URL.
  • socketLibrary (string): The library used for real-time communication. Options include 'websocket' (default) and 'socket.io' for Socket.io connections.
  • customStyles (object): Custom styles for the navbar and title.

Example

Here’s an example of how you can use the Navbar component with your custom links, notifications, and WebSocket configuration:

const links = [
  { path: '/', label: 'Home' },
  { path: '/about', label: 'About' },
  { path: '/contact', label: 'Contact' },
];

<Navbar
  title="Amazing Blog"
  links={links}
  showNotifications={true} // Toggle notification icon visibility
  websocketUrl="wss://example.com/websocket" // WebSocket URL for receiving notifications
  socketLibrary="websocket" // Option to switch to Socket.io if required
  customStyles={{
    navbar: { backgroundColor: '#333' },
    title: { color: '#fff' },
  }}
/>

Dependencies

  • react: React library for building the UI.
  • react-router-dom: For routing.
  • dompurify: To ensure content security when using dynamic content.
  • bootstrap: For the default styling.
  • bootstrap-icons: For including Bootstrap's icon library.
  • WebSocket or Socket.io: Depending on your backend, the component can use either WebSocket or Socket.io for real-time notifications. * Socket.io support is optional and can be toggled with the socketLibrary prop.

License

This project is licensed under the MIT License.

Key Changes:

  1. Updated Description: The README now reflects the new support for both WebSocket and Socket.io, as well as the ability to toggle notifications and customize styling.
  2. Props Documentation: Added socketLibrary to specify whether to use WebSocket or Socket.io for real-time communication.
  3. Installation Instructions: Clearer installation commands for both the component and its dependencies.
  4. Usage Example: Demonstrates the use of both showNotifications and socketLibrary props.

This README will help users understand how to integrate your component into their projects and take full advantage of the new features!