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

simple-tabs-vue

v0.1.16

Published

Just a very simple Tab Plugin for Vue. Basically no styling. Just pure component and pure utility.

Downloads

39

Readme

SimpleTabsVue

Just a very simple Tab Plugin for Vue. Basically no styling. Just pure utility.

Table of Contents

Usage

First you have to install the package:

npm install simple-tabs-vue

You can define the components globaly as follows:

import { SimpleTabsPlugin } from 'simple-tabs-vue';
// import "simple-tabs-vue/styles.css"; // for testing

const app = createApp(App);
app.use(SimpleTabsPlugin);
app.mount('#app');

There is styling but it is really just meant for testing purposes. Just implement your own cool styling.

Usage Example

<SimpleTabSwitch groupName="TabGroup" defaultTab="Tab2" />
<SimpleTab tabGroup="TabGroup" tabName="Tab1">Tab1</SimpleTab>
<SimpleTab tabGroup="TabGroup" tabName="Tab2">Tab2</SimpleTab>

It is up to you where to place those components. There is no defined order you have to follow.

SimpleTabSwitch displays the buttons to switch between tabs. Optionaly defaultTab can be provided with the tab to open as default. Each SimpleTab element needs a tabGroup to which it is grouped. The tabName is the identifier of the tab.

SimpleTabSwitch can emit the events beforeSwitchTab and afterSwitchTab which return the previous and subsequent tab. There is also the possibility to provide the callback onBeforeSwitch that is called before the switch actually happening. When returning false the switch event will abort.

Switching Programmatically

You can also call to switch the tab in code. Just use the tab store and call the switchTab method.

...
import { useSimpleTabsStore } from './composable/tabStore';
const tabsStore = useSimpleTabsStore();

function switchToTab2(){
    tabsStore.switchTab('TabGroup', 'Tab2');
}
...

Filter

The tab Store also provides a filter:

// opens all tabs where the tab Name starts with 'Book'
tabsStore.filterTabs('TabGroup', 'Book', FilterOption.StartsWith);

List of available filter options

  • FilterOption.StartsWith - Start with provided string.
  • FilterOption.EndWith - Ends with provided string.
  • FilterOption.Contains - Contains provided string.
  • FilterOption.Regex - Filter with provided regex string.

Multiple Tab Names

You can also provide multiple tab names to a tab:

<SimpleTab tab-group="TabGroup" :tab-name="['Tab1', 'Tab2']">
    Open On 'Tab1' and 'Tab2' but not on any other Tab.
</SimpleTab>

This is very usefull when you want a tab to be shown when 'Tab1' or 'Tab2' are open but not for example 'Tab3'.

Customizing

Styling Classes

  • simpleT-tabSwitcher -> container for tab selection
  • simpleT-tabSwitchBtn -> Tab Selection Button
  • simpleT-tabOpened -> added class to tab Button when tab is open
  • simpleT-tabClosed -> added class to tab Button when tab is closed
  • simpleT-tab -> tab class

Adding Custom Classes

You can provide custom css classes for specific elements:

...
<!-- This Elements have custom css classes added  -->
<SimpleTabSwitch :customBtnOpenClasses="['myBtnOpen']" :customBtnClasses="['myBtn']" :containerClasses="['mySwitchContainer']" groupName="TabGroup" defaultTab="Tab2" />
<SimpleTab tab-group="TabGroup" :tab-name="['Tab1']" :classes=['myTab']">
    Tab1
</SimpleTab>
...