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

@bitovi/scrolling-nav

v0.0.1-pre.9

Published

Just drop it in to enable quick navigation to sections of your page.

Downloads

15

Readme

scrolling-nav

A web component for navigating to sections of your page that can stick as you scroll.

Setup

If you are using a module loader, you can install the web component with NPM like:

npm install @bitovi/scrolling-nav

Import the web component:

import "../../node_modules/@bitovi/scrolling-nav";

Use

To use, just insert the HTML element tag created by the package.

<scrolling-nav></scrolling-nav>

That's it.

Changing Default Configuration

You can optionally provide attributes to the component to customize your experience. Here are the default attribute values.

<scrolling-nav 
    scrollable-container-selector="window"
    heading-selector="h2"
></scrolling-nav>

Attributes

scrollable-container-selector

  • required: false
  • type: string
  • default: "window"

The scrollable-container-selector attribute is the tag (HTML element, class, or ID) contains the section headings that you want to scroll to. By default, it will be the window.

<scrolling-nav scrollable-container-selector=".header"></scrolling-nav>

heading-selector

  • required: false
  • type: string
  • default: "h2"

The heading-selector attribute is the tag (HTML element, class, or ID) that will be used to create the navbar items. By default, it will scour the <body> for H2 tags.

<scrolling-nav heading-selector="h3"><scrolling-nav>

Custom Styles

You can override or modify the default styles by using the provided IDs and classes. The component is structured like the following:

    <scrolling-nav>
        <ul class="scrolling-nav-inner">
            ...
            <ul class="scrolling-nav-item">
                <a>Heading Example 1</a>
            </ul>
            ...
            <ul class="scrolling-nav-item">
                <a>Heading Example 2</a>
            </ul>
            ...
        </div>
    </scrolling-nav>

Navbar Wrapper

To customize the styles of the navbar container, use the following tag in your styles:

    scrolling-nav {}

Navbar Inner Container

To customize the styles of the navbar inner container (which is scrolled by the outer container), use the following ID in your styles:

    scrolling-nav > ul {}

Navbar Items

To customize the styles of the navbar's items, use the following class in your styles:

    scrolling-nav > ul > li {}

If you want to customize the active state of a nav item, use the following class in your styles:

    scrolling-nav > ul > li.scrolling-nav-active {}

The scrolling-nav-active class is added whenever the section represented by the nav item is in or below the top 1/3 of the page and above of the next section in the page. The scrolling-nav-active class will only be applied to one item at a time.

Notes

Using TypeScript + TSX

You may get the following linting error on the web component: Property 'scrolling-nav' does not exist on type 'JSX.IntrinsicElements'. To fix this, add the following snippet to your declarations.d.ts file.

// In ~/declarations.d.ts

declare namespace JSX {
    // ...
  interface IntrinsicElements {
      // ...
    "scrolling-nav": any;
  }
}