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-file-tabs

v1.0.22

Published

Switch between active views using a file-tab interface, a standards-based DOM Component

Downloads

47

Readme

Premium DOM Component

File Tabs

For multitasking UI/UX

Motivation

The rwt-file-tabs DOM component can be used in scenarios with multiple views or multiple work tasks.

This component can be configured with a fixed set of tabs which are slotted into the component when designing the document. Alternatively, its programming API allows tabs to be created and removed as needed, when working with a dynamic set of tabs.

Tabs can be configured using CSS to adjust their size and typography.

The tab bar occupies a fixed width. When the size of all tabs exceeds that width, scroll buttons are automatically enabled.

Dynamic tabs can be closable or not, based on an attribute set on the DOM component by the developer.

In the wild

To see an example of this component in use, visit the BLUEFIDDLE website. It uses two components: one vertical and one horizontal. 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-file-tabs DOM component works in any browser that supports modern W3C standards. Templates are written using BLUE PHRASE 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 a few things to your HTML page to make use of it.

  • Add a script tag to load the component's rwt-file-tabs.js file:
<script src='/node_modules/rwt-file-tabs/rwt-file-tabs.js' type=module></script>
  • Add the component tag somewhere on the page, configuring it with these optional attributes:

    • closable This optional attribute instructs the component to add an 'x' button to each dynamically added tab, allowing the user to remove the tab.
    • scroll-side={left|right} When the space occupied by the tabs is too large, scroll buttons are enabled. They can be positioned to the left or the right of the tabs.
    • anchor-side={left|right} When the space occupied by the tabs is less than the width of the component, the unoccupied space can be anchored to the left or to the right of the tabs.
    • role=navigation This web accessible ARIA attribute tells readers that the component is used for navigation.

Slotted usage

If the component is to be used with a predetermined set of tabs, they can be slotted in. Here's an example:

<rwt-file-tabs role=contentinfo>
    <button slot=tabitem id=tab1 title='Read only view'>READ</button>
    <button slot=tabitem id=tab2 title='Text editing view'>WRITE</button>
    <button slot=tabitem id=tab3 title='Web browser preview'>PREVIEW</button>
</rwt-file-tabs>

Programmatic API

If the component is to be used with a dynamic set of tabs, they can be added and removed using these methods.

Life-cycle events

The component issues life-cycle events.

Styling

Tab styling

The component can be styled with these CSS variables:

rwt-file-tabs {
    --width: 100%;
    --height: 2rem;
    --nav-button-size: 1.6rem;
}

The tabs can be styled with these CSS variables:

rwt-file-tabs {
    --font-weight: normal;
    --letter-spacing: 0px;
    --text-align: left;
    --min-width: 2rem;
    --max-width: 6rem;    
}

Dialog color scheme

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

rwt-file-tabs {
    --color: var(--white);
    --accent-color1: var(--pure-white);
    --background: var(--black);
    --accent-background1: var(--pure-black);
    --accent-background2: var(--nav-black);
    --accent-background3: var(--medium-black);
    --accent-background4: var(--gray);
}

Vertically oriented tabs

The component can be oriented vertically by wrapping it in a positioned element and using a CSS transform. Here's an example of how to do it:

HTML

<div id=viewtabs-area>         
    <rwt-file-tabs id=viewtabs scroll-side=left anchor-side=right>
        <button id=id4 slot=tabitem title='Delta view'>Delta</button>
        <button id=id3 slot=tabitem title='Gamma view'>Gamma</button>
        <button id=id2 slot=tabitem title='Beta view'>Beta</button>
        <button id=id1 slot=tabitem title='Alpha view'>Alpha</button>
    </rwt-file-tabs>
</div>

CSS

div#viewtabs-area {
    position: absolute;
    top: 2.3rem;
    left: 0;
    bottom: 0;
    width: 2.0rem;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
}
#viewtabs {
    position: absolute;
    transform: rotate(-90deg);
    transform-origin: left top;
    width: 34rem; /* JavaScript will override */
    top: 34rem;   /* JavaScript will override */
}

JavaScript

function onResize() {
    var viewTabsArea = document.getElementById('viewtabs-area');
    var viewTabs = document.getElementById('viewtabs');
    var height = viewTabsArea.offsetHeight;
    viewTabs.style.width = `${height}px`;
    viewTabs.style.top = `${height}px`;
}

window.addEventListener('resize', onResize);

Reference

License

The rwt-file-tabs DOM component is not freeware. After evaluating it and before using it in a public-facing website, eBook, mobile app, or desktop application, you must obtain a license from Read Write Tools .

Activation

To activate your license, copy the rwt-registration-keys.js file to the root directory of your website, providing the customer-number and access-key sent to your email address, and replacing example.com with your website's hostname. Follow this example: