Skip to content

Commit

Permalink
docs: added token docs (#766)
Browse files Browse the repository at this point in the history
* token docs

* new docs fix

* id fix

* removed id input

* removed unused import
  • Loading branch information
MattL75 committed May 1, 2019
1 parent 49fa5c6 commit 64274e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
29 changes: 14 additions & 15 deletions library/src/lib/token/token.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, ElementRef, EventEmitter, HostListener, Input, OnInit, Output, ViewChild } from '@angular/core';
import { HashService } from '../utils/hash.service';
import { Component, ElementRef, EventEmitter, HostListener, Output, ViewChild } from '@angular/core';

/**
* A token is used to represent contextualizing information.
* They can be useful to show applied filters, selected values for form fields or object metadata.
*/
@Component({
selector: 'fd-token',
templateUrl: './token.component.html',
Expand All @@ -10,34 +13,30 @@ import { HashService } from '../utils/hash.service';
'role': 'button'
}
})
export class TokenComponent implements OnInit {
export class TokenComponent {

/** @hidden */
@ViewChild('contentContainer')
contentContainer: ElementRef;

/** Emitted when the *x* icon is clicked. Specifically, any pseudo-element. */
@Output()
onCloseClick: EventEmitter<string> = new EventEmitter<string>();
readonly onCloseClick: EventEmitter<void> = new EventEmitter<void>();

@Input()
id: string;
/** @hidden */
constructor(private elRef: ElementRef) {
}

/** @hidden */
@HostListener('click', ['$event'])
clickHandler(event): void {
if (this.contentContainer) {
if (this.elRef.nativeElement.contains(event.target) && !this.contentContainer.nativeElement.contains(event.target)) {
this.onCloseClick.emit(this.id);
this.onCloseClick.emit();
}
}
}

constructor(private elRef: ElementRef, private hash: HashService) {}

ngOnInit(): void {
if (!this.id) {
this.id = this.hash.hash();
}
}

}


3 changes: 1 addition & 2 deletions library/src/lib/token/token.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TokenComponent } from './token.component';
import { UtilsModule } from '../utils/utils.module';

@NgModule({
declarations: [TokenComponent],
imports: [CommonModule, UtilsModule],
imports: [CommonModule],
exports: [TokenComponent]
})
export class TokenModule {}

0 comments on commit 64274e2

Please sign in to comment.