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

aurelia-tabbed

v0.1.3

Published

An Aurelia plugin for Tabs

Downloads

5

Readme

Aurelia Tabbed

A free tabs component for your Aurelia applications. Allows you to toggle between sections of content, with supports for dynamically composing views with optional data. This project is based off of the aurelia-tabs project so it relies pretty heavily on its basic structure.

Installation

  1. In your console type: npm install aurelia-tabbed --save
  2. During the bootstrapping phase, register the plugin:
export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .plugin('aurelia-tabbed')
    .developmentLogging();

  aurelia.start().then(a => a.setRoot());
}

Usage

This plugin is comprised of multiple components to be used together.

Tab-Header

The tab-headers component is where your clickable tabs are generated. It has one bindable value which is required tabs.bind

Valid data

To pass through tabs to your object, they need to be defined in a standardised way. The plugin expects an array of one or more objects which contain at least an id property, a label property and a viewModel property. The id property is used to identify which tab-content this tab will open as defined in the tabs-wrapper element. The label property is the value displayed to the user. The viewModel property is the path to the view-model you wish to load in that tab. A fourth optional property icon allows you to set the class names associated with an icon you want displayed next to the Label. A fifth optional property defaultTab, allows us to specify if this tab is the default selected tab.

In your ViewModel:

export class ViewModel {
    constructor() {
        this.tabSchema = [
            {id: 'tab-one', label: 'My First Section', viewModel: '', icon: 'fa fa-gear' defaultTab: true},
            {id: 'tab-two', label: 'Users', viewModel: './tab-two-view-model', icon: '' },
            {id: 'tab-three', label: 'Browse Items' viewModel: './tab-three-view-model', icon: '' }}
        ];
    }
}

In your View: <tab-headers tabs.bind="tabSchema"></tab-headers>

One optional item you can set here is an overall dark or light skin for the tabs by adding a class to the tab-headers element. For the dark skin, set the class to tabs-dark and for the light colored skin, set it to tabs-light. For example: <tab-headers tabs.bind="tabSchema" class="tabs-dark"></tab-headers>

Tab Wrapper

Once you have your tabs setup, you will want to create tab wrappers which wrap tab-content items. We will use the example above and add in the wrapper related to each defined tab.

In your ViewModel:

export class ViewModel {
    constructor() {
        this.tabSchema = [
            {id: 'tab-one', label: 'My First Section', viewModel: '', icon: 'fa fa-gear' defaultTab: true},
            {id: 'tab-two', label: 'Users', viewModel: './tab-two-view-model', icon: '' },
            {id: 'tab-three', label: 'Browse Items' viewModel: './tab-three-view-model', model: this.modelData, icon: '' }}
        ];

		this.modelData = { first: 'first', second: 'second' }
    }
}

In your View:

<tabs tabs.bind="tabSchema" class="tabs-dark"></tabs>

<tabs-wrapper>

</tab-wrapper>

We have a basic skeleton tab application, but no tabs to switch between. Lets add some individual tab content areas now.

In your View:

<tabs tabs.bind="tabSchema" class="tabs-dark"></tabs>

<tab-wrapper>
    <tab-content tab.bind="tabSchema[0]" default-tab="true">
        <h1>Hello</h1>
        <p>This is some basic HTML content within a tab content area.</p>
    </tab-content>
    <tab-content tab.bind="tabSchema[1]"></tab-content>
    <tab-content tab.bind="tabSchema[2]"></tab-content>
</tab-sections>

The <tab-content> element is used in three different ways based on how the tabSchema object is setup. First, we just specified some content right between the opening and closing brackets and because we didn't specify a path in the tabSchema object, it will display the HTML. For the second, we populated the path property in the tabSchema object, which allows us to dynamically render a ViewModel using the <compose> element and finally, we do the same thing but pass through an object of data from the model property in the tabSchema object.

Finally, there is one more way to use this plugin that almost completely dynamic in nature:

In your View:

<tabs tabs.bind="tabSchema" class="tabs-dark"></tabs>

<tab-wrapper repeat.for="tab of tabSchema">
	<tab-content tab.bind="tab"></tab-content>
</tab-sections>

This allows you to let the tabSchema object do all the heavy lifting for you. The one caveat is that with this method, you won't be able to manually define HTML in a tab, but have to allow the tabSchema object be used to load the appropirate view-model.