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

@nice-digital/nds-in-page-nav

v4.0.15

Published

In page navigation component for the NICE Design System

Downloads

658

Readme

@nice-digital/nds-in-page-nav

In page navigation component for the NICE Design System

Installation

Install Node, and then:

npm i @nice-digital/nds-in-page-nav --save

Usage

React

Import the InPageNav component from the package and use with JSX:

import React from "react";
import { Link } from "react-router-dom";
import { InPageNav } from "@nice-digital/nds-in-page-nav";

<InPageNav />;

Note: The React component automatically imports the SCSS, so there's no need to import the SCSS directly yourself.

Props

className

  • Type: string

Any additional classes you would like applied to the container.

headingsContainerSelector

  • Type: string
  • Default: "body"

A selector for the container in which to look for headings.

headingsSelector

  • Type: string
  • Default: "h2, h3"

A selector for headings to use for the navigation.

headingsExcludeSelector

  • Type: string
  • Default: ""

A selector for any headings to exclude from the navigation.

headingsExcludeContainer

  • Type: string
  • Default: ""

A selector for a container that will be completely ignored, i.e. all headings within that container will be excluded. Useful in cases where it's not easy to exclude or select individual headings.

scrollTolerance

  • Type: number
  • Default: 50

The number of pixels from the top of the screen that's used to determine if a heading is considered to current/active.

noScroll

  • Type: boolean
  • Default: false

If true, the in-page-nav will no longer scroll along with the user's current position (i.e. it won't be sticky).

twoColumns

  • Type: boolean
  • Default: false

If true, the in-page-nav will render as two columns instead of just one. This will only work if noScroll is set to true.

Other props

Any additional props will be spread across the container.

<InPageNav data-track="track-this">
	...
</InPageNav>

SCSS

If you're not using React, then import the SCSS directly into your application by:

@forward '@nice-digital/nds-in-page-nav/scss/in-page-nav';

HTML

If you're not using React, then include the SCSS as above but you'll have to provide your own implentation. The exception to this is within niceorg client (NOC):

niceorg client

niceorg client (NOC) is a library of front-end assets (both CSS and JS) shared between Guidance Web and the 'corporate' website (front-end of Orchard). Load the NOC JavaScript (see NOC readme) to include a wrapper around the in-page-nav react component. This allows the in page nav component to be loaded declaratively, for example:

<div data-in-page-nav></div>

The data-in-page-nav attribute is all that's needed to render a default in page nav. This will look inside main for h2 and h3 headings by default. Use data attributes to configiure the props to be passed in. For example data-in-page-nav-headings-container-selector maps to the headingsContainerSelector prop.

Note: This renders a React component under the hood and parses kebab-case data attributes into a props object.

A basic customisation might be to change the target element:

<div data-in-page-nav data-in-page-nav-headings-container-selector="main"></div>

Or with all possible options:

<div
	data-in-page-nav
	data-in-page-nav-headings-container-selector="main"
	data-in-page-nav-headings-selector="h2, h3"
	data-in-page-nav-headings-exclude-selector=".js-ignore"
	data-in-page-nav-scroll-tolerance="50"></div>