0.1.16 • Published 6 months ago

simple-tabs-vue v0.1.16

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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>
...
0.1.15

6 months ago

0.1.16

6 months ago

0.1.10

12 months ago

0.1.11

12 months ago

0.1.12

11 months ago

0.1.13

10 months ago

0.1.14

10 months ago

0.1.8

12 months ago

0.1.9

12 months ago

0.1.7

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

12 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.12

12 months ago

0.0.11

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago