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

rwt-reading-summary

v1.0.15

Published

Display reader's experience points and reading history, a standards-based DOM Component

Downloads

4

Readme

Open Source DOM Component

Reading Summary

Display a visitor's reading history

Motivation

As the user moves from page to page within a website, the rwt-reading-points component tracks which pages have been visited, what percentage has been read, and how much time was spent reading each page. This information is kept in the user's local storage.

The rwt-reading-summary DOM component displays the information in summary form.

In the wild

To see an example of this component in use, visit the READ WRITE SERVE website and press F4 "Reading Summary". To understand what's going on under the hood, use the browser's inspector to view the HTML source code and network activity, and follow along as you read this documentation.

Installation

Prerequisites

The rwt-reading-summary DOM component works in any browser that supports modern W3C standards. Templates are written using BLUEPHRASE notation, which can be compiled into HTML using the free Read Write View desktop app. It has no other prerequisites. Distribution and installation are done with either NPM or via Github.

Download

Using the DOM component

After installation, you need to add several things to your HTML page to make use of it.

  • Add a script tag to load the component's rwt-reading-summary.js file:
<script src='/node_modules/rwt-reading-summary/rwt-reading-summary.js' type=module></script>             
  • Add the component tag somewhere on the page.

    • For scripting purposes, apply an id attribute.
    • Optionally, apply a shortcut attribute with something like F1, F2, etc. for hotkey access.
    • And for WAI-ARIA accessibility apply a role=contentinfo attribute.
<rwt-reading-summary id=reading-summary role=contentinfo shortcut=F4></rwt-reading-summary>
  • Add a button to allow the visitor to show the dialog. Here the button contains the number '0' as its text. This will be replaced with the user's experience points when the rwt-reading-summary-data event is received.
<a id='reading-summary-button' aria-haspopup='true' aria-controls='reading-summary'>0</a>
  • Add a listener to respond to the click event:
<script type=module>
    document.getElementById('reading-summary-button').addEventListener('click', (e) => {
        document.getElementById('reading-summary').toggleDialog(e);
    });
</script>
  • Add a listener to capture the rwt-reading-summary-data event and show the experience points on the summary button:
<script type=module>
    document.addEventListener('rwt-reading-summary-data', (e) => {
        var el = document.getElementById('reading-summary-button');
        el.innerHTML = e.detail.pointsObtained;
        el.title = `Reading Summary: ${e.detail.pagesRead} pages / ${e.detail.readingTime} / ${e.detail.pointsObtained} points / (${e.detail.shortcutKey}) for details`;
    });     
</script>

Customization

Dialog size and position

The dialog is absolutely positioned towards the bottom left of the viewport. Its size may be overridden using CSS by defining new values for the size and position variables.

rwt-reading-summary {
    --width: 70vw;
    --height: 50vh;
    --bottom: 1rem;
    --left: 1rem;
    --caption-bar-height: 1.5rem;
    --message-height: 1.5rem;
}

Dialog color scheme

The default color palette for the dialog uses a dark mode theme. You can use CSS to override the variables' defaults:

rwt-reading-summary {
    --color: var(--white);
    --accent-color1: var(--yellow);
    --accent-color2: var(--js-blue);
    --background: var(--black);
    --accent-background1: var(--medium-black);
    --accent-background2: var(--pure-black);
    --accent-background3: var(--nav-black);
    --accent-background4: var(--black);
}

Life-cycle events

The component issues life-cycle events.

Event controllers

The dialog box can be controlled with its event interface.


Reference

License

The rwt-reading-summary DOM component is licensed under the MIT License.