Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import '@travelopia/web-components/dist/tabs';
import '@travelopia/web-components/dist/tabs/style.css';

// TypeScript usage:
import { TPTabs } from '@travelopia/web-components';
import { TPTabsElement } from '@travelopia/web-components';

...

const tabs: TPTabs = document.querySelector( 'tp-tabs' );
const tabs: TPTabsElement = document.querySelector( 'tp-tabs' );
tabs.setCurrentTab( 'overview' );
```

Expand Down
12 changes: 11 additions & 1 deletion src/tabs/tp-tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class TPTabsElement extends HTMLElement {
*/
update(): void {
// Get current tab.
const currentTab: string = this.getAttribute( 'current-tab' ) ?? '';
const currentTab: string = this.currentTab;

// Check if current tab exists.
if ( ! this.querySelector( `tp-tabs-tab[id="${ currentTab }"]` ) ) {
Expand Down Expand Up @@ -116,6 +116,16 @@ export class TPTabsElement extends HTMLElement {
this.setCurrentTab();
}

/**
* Get current tab.
*
* @return {string} Current tab ID.
*/
get currentTab(): string {
// Return the current tab ID.
return this.getAttribute( 'current-tab' ) ?? '';
}

/**
* Set current tab.
*
Expand Down
Loading