This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(toolbar-search): add toolbar-search component
- Loading branch information
1 parent
a515a55
commit 342fdd9
Showing
13 changed files
with
240 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
projects/core/src/lib/toolbar-search/toolbar-search.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<ion-toolbar [color]="color"> | ||
<ion-buttons slot="start"> | ||
<ng-content select="[start]"></ng-content> | ||
|
||
</ion-buttons> | ||
<ion-title [@titleAnim] *ngIf="titleVisible">{{title}}</ion-title> | ||
<ion-input (ionChange)="inputChange.emit($event)" [placeholder]="!titleVisible ? placeholder : ''" autofocus #input class="toolbar-searchbar" | ||
[@searchbarAnim] (@searchbarAnim.done)="seachbarAnimDone($event,input)" *ngIf="searching"> | ||
</ion-input> | ||
|
||
<ion-buttons slot="end"> | ||
<ion-button [@rotateAnim] (@rotateAnim.done)="searchAnimDone($event)" *ngIf="!searching" (click)="openSearchbar()"> | ||
<ion-icon name="md-search"></ion-icon> | ||
</ion-button> | ||
<ion-button [@rotateAnim] (@rotateAnim.done)="closeAnimDone($event)" *ngIf="closeButtonVisible" (click)="closeSearchbar()"> | ||
<ion-icon name="md-close"></ion-icon> | ||
</ion-button> | ||
<ng-content select="[end]"></ng-content> | ||
|
||
</ion-buttons> | ||
</ion-toolbar> |
3 changes: 3 additions & 0 deletions
3
projects/core/src/lib/toolbar-search/toolbar-search.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.toolbar-searchbar{ | ||
float: right; | ||
} |
25 changes: 25 additions & 0 deletions
25
projects/core/src/lib/toolbar-search/toolbar-search.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ToolbarSearchComponent } from './toolbar-search.component'; | ||
|
||
describe('ToolbarSearchComponent', () => { | ||
let component: ToolbarSearchComponent; | ||
let fixture: ComponentFixture<ToolbarSearchComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ToolbarSearchComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ToolbarSearchComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
87 changes: 87 additions & 0 deletions
87
projects/core/src/lib/toolbar-search/toolbar-search.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { Component, OnInit, Input, EventEmitter, Output, Renderer2 } from '@angular/core'; | ||
import { trigger, transition, style, animate, state } from '@angular/animations'; | ||
|
||
@Component({ | ||
selector: 'fiv-toolbar-search', | ||
templateUrl: './toolbar-search.component.html', | ||
styleUrls: ['./toolbar-search.component.scss'], | ||
animations: [ | ||
trigger('searchbarAnim', [ | ||
transition('void => *', [ | ||
style({ width: '0px' }), | ||
animate('175ms ease-out', style({ width: '100%' })) | ||
]), | ||
transition('* => void', [ | ||
style({ width: '100%' }), | ||
animate('125ms ease-in', style({ width: '0px', opacity: 0 })) | ||
]) | ||
]), | ||
trigger('rotateAnim', [ | ||
transition('void => *', [ | ||
style({ opacity: '0' }), | ||
animate('175ms ease-out', style({ opacity: '1', transform: 'rotateZ(0deg)' })) | ||
]), | ||
transition('* => void', [ | ||
animate('175ms ease-in', style({ opacity: '0', transform: 'rotateZ(45deg)' })) | ||
]), | ||
]), | ||
trigger('titleAnim', [ | ||
transition('void => *', [ | ||
style({ opacity: '0', transform: 'translateY(-20%)' }), | ||
animate('175ms ease-out', style({ opacity: '1', transform: 'translateY(0)' })) | ||
]), | ||
]), | ||
] | ||
}) | ||
export class ToolbarSearchComponent implements OnInit { | ||
|
||
searching = false; | ||
titleVisible = true; | ||
closeButtonVisible = false; | ||
@Input() title: string; | ||
@Input() placeholder: string; | ||
@Input() color: string; | ||
@Output() inputChange: EventEmitter<any> = new EventEmitter(); | ||
@Output() close: EventEmitter<any> = new EventEmitter(); | ||
|
||
constructor(public renderer: Renderer2) { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
openSearchbar() { | ||
this.searching = true; | ||
this.titleVisible = false; | ||
} | ||
|
||
closeSearchbar() { | ||
this.closeButtonVisible = false; | ||
this.close.emit(); | ||
|
||
} | ||
|
||
searchAnimDone(event) { | ||
console.log('###', event); | ||
if (event.fromState !== 'void') { | ||
this.closeButtonVisible = true; | ||
} | ||
} | ||
|
||
closeAnimDone(event) { | ||
console.log('###', event); | ||
if (event.fromState !== 'void') { | ||
this.searching = false; | ||
} | ||
} | ||
|
||
seachbarAnimDone(event, input) { | ||
console.log('!!!', event); | ||
if (event.fromState !== 'void') { | ||
this.titleVisible = true; | ||
} else { | ||
input.focus(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FivethreeCoreModule } from './../../../projects/core/src/lib/fivethree.core.module'; | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { ToolbarSearchPage } from './toolbar-search.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: ToolbarSearchPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
FivethreeCoreModule, | ||
RouterModule.forChild(routes) | ||
], | ||
declarations: [ToolbarSearchPage] | ||
}) | ||
export class ToolbarSearchPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<ion-header> | ||
<fiv-toolbar-search title="Toolbar Search" placeholder="Search ...." (inputChange)="onSearchInputChanged($event)" (close)="closeSearch()"></fiv-toolbar-search> | ||
</ion-header> | ||
|
||
<ion-content padding> | ||
|
||
<ion-item-divider>Search Input</ion-item-divider> | ||
<ion-label>{{searchInput}}</ion-label> | ||
|
||
</ion-content> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ToolbarSearchPage } from './toolbar-search.page'; | ||
|
||
describe('ToolbarSearchPage', () => { | ||
let component: ToolbarSearchPage; | ||
let fixture: ComponentFixture<ToolbarSearchPage>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ ToolbarSearchPage ], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ToolbarSearchPage); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-toolbar-search', | ||
templateUrl: './toolbar-search.page.html', | ||
styleUrls: ['./toolbar-search.page.scss'], | ||
}) | ||
export class ToolbarSearchPage implements OnInit { | ||
|
||
searchInput: string; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
onSearchInputChanged(event) { | ||
this.searchInput = event.detail.value; | ||
console.log(event.detail.value); | ||
} | ||
|
||
closeSearch() { | ||
this.searchInput = ''; | ||
} | ||
|
||
} |