Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.
Merged
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
16 changes: 14 additions & 2 deletions packages/oui-header-tabs/src/header-tabs-dropdown.component.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import template from "./header-tabs-dropdown.html";

const itemClass = "oui-header-tabs__item";
const dropDownClass = `${itemClass}_dropdown`;

export default {
bindings: {
text: "@"
},
controller: class {
constructor ($element, $timeout) {
constructor ($element, $scope, $timeout) {
"ngInject";

this.$element = $element;
this.$scope = $scope;
this.$timeout = $timeout;
}

$postLink () {
this.$timeout(() => {
this.$element
.addClass("oui-header-tabs__item oui-header-tabs__item_dropdown")
.addClass(`${itemClass} ${dropDownClass}`)
.attr("role", "listitem");

this.$scope.$watch(() => !!this.$element[0].querySelector(`.${itemClass}_active`), hasActive => {
if (hasActive) {
this.$element.addClass(`${dropDownClass}_active`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${dropDownClass}_active could have been a constant then 😄

} else {
this.$element.removeClass(`${dropDownClass}_active`);
}
});
});
}
},
Expand Down