@fleetbase/ember-ui
Version:
Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.
45 lines (36 loc) • 1.21 kB
JavaScript
import Component from '@glimmer/component';
import { action, computed } from '@ember/object';
import { later } from '@ember/runloop';
import { dasherize } from '@ember/string';
export default class TabsTabComponent extends Component {
get isActive() {
return this.args.activeTab === this.tabName;
}
get activeTabClass() {
return this.isActive ? `active ${this.args.activeTabClass}` : '';
}
get activePaneClass() {
return this.isActive ? `active ${this.args.activePaneClass}` : '';
}
get tabName() {
return dasherize(this.args.title);
}
constructor() {
super(...arguments);
later(
this,
() => {
if (typeof this.args.onCreated === 'function') {
this.args.onCreated(this.tabName);
}
},
100
);
}
onClick() {
const { onClick } = this.args;
if (typeof onClick === 'function') {
onClick(this.tabName);
}
}
}