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

@one-platform/opc-nav

v0.0.4-prerelease

Published

opc-nav is a nav bar component developed using lit elements for Red Hat One Platform.

Downloads

273

Readme

opc-nav Component 👋

Version Build Status Maintenance

Opc-Nav is a fully customizable web component developed using Lit elements for Red Hat One Platform. Its primarily used as the navigation bar that contains links, menu buttons, and logo.

Prerequisites

Opc-Nav is implement under Red Hat design guidelines. Therefore the component uses Red Hat official font. This can be easily imported with google cdn at the top of HTML document.

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
  href="https://fonts.googleapis.com/css2?family=Red+Hat+Display&display=swap"
  rel="stylesheet"
/>
<link
  href="https://fonts.googleapis.com/css2?family=Red+Hat+Text&display=swap"
  rel="stylesheet"
/>

Guidelines

Details

It is a mandatory slot component that contains the product logo, positioned at the left extreme. The best component would be an image component. The height of the image must be within 60px, which is the height of the navbar. It can be changed with the CSS variable --opc-nav-height.

Code

<opc-nav>
  <img slot="opc-nav-logo" />
  <opc-nav-search slot="opc-nav-search"></opc-nav-search>
</opc-nav>

Screenshot

Image of opc-nav-with logo

Details

Links are the quick reference links for easy navigation, positioned after the logo along the middle. By default, it could be added with the links attribute. We can also customize the entire links by using slot opc-nav-menu-links. This will replace the entire links component container.

Code

<opc-nav>
  <img slot="opc-nav-logo" src="" alt="logo" />
  <opc-nav-search slot="opc-nav-search"></opc-nav-search>
</opc-nav>
const links = [
  { name: 'Blog', href: '#' },
  { name: 'Documentation', href: '#' },
];
document.querySelector('opc-nav').links = links;

Screenshot

Image of opc-nav-with logo

Details

The nav buttons, enable utility actions that enhance the user experience. By default, opc-nav provides two buttons with there corresponding events. Menu buttons can be replaced with the slot opc-nav-btn. Icon buttons with size of 60px are prefered. activeMenu property provides active class styling to show users which one is selected. It accepts menu | notification as value.

| Name | Icon | Event | | ------------------- | --------- | ------------------------------ | | Notification Button | Bell Icon | opc-nav-btn-notification:click | | Menu Button | Grid Icon | opc-nav-btn-menu:click |

Code (Default)

<opc-nav>
  <img slot="opc-nav-logo" src="" alt="logo" />
  <opc-nav-search slot="opc-nav-search"></opc-nav-search>
</opc-nav>

Screenshot

Image of opc-nav-with logo

Code (Search hidden and custom button)

<opc-nav>
  <img slot="opc-nav-logo" src="" alt="logo" />
  <button slot="opc-nav-btn">R</button>
</opc-nav>

Screenshot

Image of opc-nav-with logo

Details

opc-nav-search is a search component for the opc-nav. It enables modular control on how the search works. It has events opc-nav-search:change on input change and opc-nav-search:search on search submit.

Code (Default)

<opc-nav>
  <opc-nav-search slot="opc-nav-search"></opc-nav-search>
</opc-nav>
document
  .querySelector('opc-nav-search')
  .addEventListener('opc-nav-search:change', function (event) {
    console.log(event.detail.value);
  });
document
  .querySelector('opc-nav-search')
  .addEventListener('opc-nav-search:submit', function (event) {
    console.log(event.detail.value);
  });

Slots

There are total 4 slots of which 3 are optional and one is mandatory

Mandatory Slots

  • opc-nav-logo: To set the logo of the application in navbar. Suggested component would be an <img/>

Optional Slots

  • opc-nav-menu-links: Container component that contains various nav links. If not given and links attribute will be shown.

  • opc-nav-search: Container component that contains the search component.

  • opc-nav-btn: The buttons at end of the navbar used for various actions. If not provided by default Notification Bell Button and Menu Button will be shown with corresponding events.

Attributes

opc-nav

  • links
    • Type: Array
    • Default value: [ ]
document.querySelector('opc-nav').links = [{ name: 'Blog', href: '#' }];
  • activeButton
    • Type: menu | notification
    • Default value: null
document.querySelector('opc-nav').activeMenu = 'menu';

opc-nav-search

  • value
    • Type: String
    • Default value: ""
document.querySelector('opc-nav-search').value = 'Search';
  • placeholder
    • Type: String
    • Default value: Search application, documents, contents etc
document.querySelector('opc-nav-search').placeholder = 'Search';

Events

opc-nav

There are two events emitted by opc-nav both are dispatched on click of navbar notification(bell icon) and menu(grid icon) button.

  1. opc-nav-btn-menu:click

Dispatched on menu(grid icon) button click.

Example:

document
  .querySelector('opc-nav')
  .addEventListener('opc-nav-btn-menu:click', function (event) {
    alert('menu got clicked');
  });
  1. opc-nav-btn-notification:click

Dispatched on notification(bell icon) button click.

Example:

document
  .querySelector('opc-nav')
  .addEventListener('opc-nav-btn-notification:click', function (event) {
    alert('notification got clicked');
  });

opc-nav-search

  1. opc-nav-search:change

Dispatched on input change of search.

Example:

document
  .querySelector('opc-nav-search')
  .addEventListener('opc-nav-search:change', function (event) {
    console.log(event.detail.value);
  });
  1. opc-nav-btn-notification:click

Dispatched on notification(bell icon) button click.

Example:

document
  .querySelector('opc-nav')
  .addEventListener('opc-nav-search:submit', function (event) {
    alert(event.detail.value);
  });

CSS Variables

opc-nav

| CSS Variable name | Value | | ------------------------------- | ----------------- | | --opc-nav-height | 60px | | --opc-nav-width | 100% | | --opc-nav-position-top | 0 | | --opc-nav-position-left | 0 | | --opc-nav-transition--defaul | 120ms ease-in-out | | --opc-nav-menu__spacing-size | 24px | | --opc-nav-menu__link-color | #151515 | | --opc-nav-container__z-index | 9 | | --opc-nav-btn__padding | 16px | | --opc-nav-display | block | | --opc-nav-btn__hover-color | #316dc11a | | --opc-nav-link__hover-color | #0066cc |

opc-nav-search

| CSS Variable name | Value | | --------------------------------- | --------- | | --opc-nav-search-bg | #f3f3f3 | | --opc-nav-search__padding | 12px 17px | | --opc-nav-search__border-radius | 8px |

Install

npm install

Usage

Install opc-nav

npm install --save @one-platform/opc-nav

For VanillaJS

  • Import component
import '@one-platform/opc-nav/dist/opc-nav';
  • Add component in html
<opc-nav> </opc-nav>

For Angular

  • In your app.module include the CUSTOM_ELEMENTS_SCHEMA and import the component
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@one-platform/opc-nav/dist/opc-nav';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}
  • Add component in any component html template
<opc-nav> </opc-nav>

For React

  • Import the component in App.js
import '@one-platform/opc-nav/dist/opc-nav';
  • Add component in any component html render
<opc-nav> </opc-nav>

Development server

  • Run development server
npm run dev opc-nav

Build

npm run build opc-nav

Run tests

npm run test

🤝 Contributors

👤 akhilmhdh