refactor(app): make a bit more neat structure

This commit is contained in:
Dmitry Nehaychik 2017-04-28 14:59:24 +03:00
parent 91c780c256
commit 44f2f562a9
20 changed files with 24 additions and 17 deletions

View file

@ -0,0 +1,7 @@
@mixin search-input-theme() {
/deep/ search-input {
input {
background: transparent;
}
}
}

View file

@ -0,0 +1,27 @@
:host {
display: flex;
align-items: center;
i.control-icon {
&:before {
font-size: 2.3rem;
}
&:hover {
cursor: pointer;
}
}
input {
border: none;
outline: none;
margin-left: 1rem;
width: 15rem;
transition: width 0.2s ease;
&.hidden {
width: 0;
margin: 0;
}
}
}

View file

@ -0,0 +1,35 @@
import { Component, ElementRef, EventEmitter, Output, ViewChild } from '@angular/core';
@Component({
selector: 'search-input',
styleUrls: ['./search-input.component.scss'],
template: `
<i class="control-icon ion ion-ios-search"
(click)="showInput()"></i>
<input placeholder="Type your search request here..."
#input
[class.hidden]="!isInputShown"
(blur)="hideInput()"
(input)="onInput($event)">
`,
})
export class SearchInputComponent {
@ViewChild('input') input: ElementRef;
@Output() search: EventEmitter<string> = new EventEmitter<string>();
isInputShown: boolean = false;
showInput() {
this.isInputShown = true;
this.input.nativeElement.focus();
}
hideInput() {
this.isInputShown = false;
}
onInput(val: string) {
this.search.emit(val);
}
}