openaire-library/utils/dropdown-filter/dropdown-filter.component.ts

34 lines
883 B
TypeScript

import {Component, Input, ViewChild} from "@angular/core";
declare var UIkit;
@Component({
selector: 'dropdown-filter',
template: `
<button class="uk-button uk-button-default uk-flex uk-flex-middle">
<span>{{name}}<span *ngIf="count > 0">({{count}})</span></span>
<icon [flex]="true" class="uk-margin-xsmall-left" [name]="'expand_' + (isOpen(dropdown)?'less':'more')"></icon>
</button>
<div #dropdown class="uk-dropdown" [ngClass]="dropdownClass" uk-dropdown="mode: click; delay-hide: 0;">
<ng-content></ng-content>
</div>
`
})
export class DropdownFilterComponent {
@Input()
public name;
@Input()
public count: number = 0;
@Input()
public dropdownClass: string;
@ViewChild("dropdown") dropdown;
isOpen(element) {
return UIkit.dropdown(element).isActive();
}
closeDropdown() {
UIkit.dropdown(this.dropdown).hide();
}
}