mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-23 08:24:07 +01:00
refactor(app): make a bit more neat structure
This commit is contained in:
parent
91c780c256
commit
44f2f562a9
20 changed files with 24 additions and 17 deletions
|
|
@ -0,0 +1,7 @@
|
|||
@mixin search-input-theme() {
|
||||
/deep/ search-input {
|
||||
input {
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue