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

@xaro/tabs2

v0.0.6

Published

Tabs with events and additional features

Downloads

8

Readme

@xaro/tabs2

description

Install

npm install @xaro/tabs2

Usage

Common usage

import xtabs from "@xaro/tabs";

// This creates instance for each element with 'x-tabs' class and returns array of Tabs instances or one instance
const tabs = xtabs({
  el: '.x-tabs'
});

With types

import xtabs from "@xaro/tabs";

### Creating your own entry function with your classes for tabs & navs
```ts
import _ from "@xaro/micro-dom";  // Extended array with additional function for iterate dom elements. You can use common Array<Element>
import {
  Tabs,
  TabsDefaults
  TabsExtendedConstructorConfig
} from "@xaro/tabs/src/types/Tabs";
import TabsClass  from "@xaro/tabs/src/Tabs";
import entry      from "@xaro/tabs/src/entry";
import TabClass   from "./Tab";    // Here your classes
import NavClass   from "./Nav";    // Here your classes

/**
 * The default classes that are used for each 
 * Classes must implement the TabConstructor/NavConstructor and
 * Tab/Nav interfaces
 * See "@xaro/tabs/src/types/Tab.d.ts" and
 * "@xaro/tabs/src/types/Nav.d.ts" respectively
 */
const defaults: TabsDefaults = {
  classes: {
    Tab: TabClass,
    Nav: NavClass
  }
}

export default (
  config: TabsExtendedConstructorConfig,
): Tabs | Tabs[] => entry(config, defaults, TabsClass);

Create your class

// File #1
import {
  TabsDefaults,
  TabsConstructorConfig
} from "@xaro/tabs/src/types/Tabs";
import Tabs from "@xaro/tabs/src/Tabs.ts"
import TabClass   from "./Tab";    // Here your classes
import NavClass   from "./Nav";    // Here your classes

// Default settings for each instance
const defaults: TabsDefaults = {
  classes: {
    Tab: TabClass,
    Nav: NavClass
  }
}

export default class MyTabs extends Tabs {
  constructor(config: TabsConstructorConfig) {
    super(config, defaults);
  }
}

// File #2
import MyTabs from "File #1";
const tabs = new MyTabs({
  ...
})

Note that the Tabs constructor takes an element of type Element

Not Array or String !!!

See the "@xaro/tabs/src/types/Tabs.d.ts" file for details

export interface TabsConstructorConfig extends TabsBaseConstructorConfig {
  el: Element;
}

To accept a different type of element, see the implementation of the entry function in the "@xaro/tabs/src/index.ts" file.

License

MIT