1.2.13 • Published 2 years ago

akili-tabs v1.2.13

Weekly downloads
5
License
MIT
Repository
github
Last release
2 years ago

akili-tabs npm version

Tabs component for Akili framework.

Example

import Akili from 'akili';
import Component from 'akili/src/component';
import Tabs from 'akili-tabs';

class App extends Component {
  static define() {
    Akili.component('app', this);
  }
  
  created() {
    this.scope.data = [
      {
        title: 'first title',
        pane: 'first pane'
      },
      {
        title: 'second title',
        pane: 'second pane'
      }
    ];
  }
}

Tabs.define();
App.define();

document.addEventListener('DOMContentLoaded', () => {
  Akili.init().catch((err) => console.error(err));
});
<app>
  <tabs>
    <tab-menu>
      <tab-title>${ this.data[0].title }</tab-title>
      <tab-title>${ this.data[1].title }</tab-title>
    </tab-menu>
    <tab-content>
      <tab-pane>${ this.data[0].pane }</tab-pane>
      <tab-pane>${ this.data[1].pane }</tab-pane>
    </tab-content>
  </tabs>
<app>

You can add items to the loop.

<app>
  <tabs>
    <tab-menu in="${ this.data }">
      <tab-title>
        ${ this.loopValue.title }
      </tab-title>
    </tab-menu>
    <tab-content in="${ this.data }">
      <tab-pane>
        ${ this.loopValue.pane }
      </tab-pane>
    </tab-content>
  </tabs>
<app>

To change the active item, use active attribute.

<tabs active="${ this.activeTab }">
  ...
</tabs>

To get change, use on-tab event.

<tabs on-tab="${ this.activeTab = event.detail }">
  ...
</tabs>

Each tab-title and tab-pane component has scope value isActiveTab indicating whether this item is active or not.

<app>
  <tabs>
    <tab-menu in="${ this.data }">
      <tab-title class="${ utils.class({active: this.isActiveTab}) }">
        ${ this.loopValue.title }
      </tab-title>
    </tab-menu>
    <tab-content in="${ this.data }">
      <tab-pane class="${ utils.class({active: this.isActiveTab}) }">
        ${ this.loopValue.pane }
      </tab-pane>
    </tab-content>
  </tabs>
<app>

You can add recreate attribute to tab-pane like if component feature.

If you load the component as a script, you will have Akili.components.Tabs to get it.

1.2.13

2 years ago

1.2.11

2 years ago

1.2.10

2 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.4

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.7.0

6 years ago

0.6.9

6 years ago

0.6.8

6 years ago

0.6.7

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.8

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago