-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(group results): Group results by source in a collapsible compone…
…nt (#98) * feat(group results): Group results by source in a collapsible component
- Loading branch information
Showing
22 changed files
with
193 additions
and
43 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
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
2 changes: 1 addition & 1 deletion
2
src/app/search/search-result-details/search-result-details.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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<md-list-item> | ||
<md-icon md-list-avatar>{{result.icon}}</md-icon> | ||
<h4 md-line>{{result.source}} - {{result.title}}</h4> | ||
<h4 md-line>{{result.title}}</h4> | ||
</md-list-item> |
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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
<igo-list [navigation]="true"> | ||
<template ngFor let-result [ngForOf]="results" let-i="index"> | ||
<igo-search-result | ||
igoListItem | ||
tabindex="{{i}}" | ||
[focused]="focusedResult && focusedResult.id === result.id" | ||
[result]="result" | ||
(focusItem)="focusResult(result)" | ||
(selectItem)="selectResult(result)"> | ||
</igo-search-result> | ||
<template ngFor let-sourceResult [ngForOf]="sourceResults"> | ||
<igo-collapsible | ||
title="{{sourceResult[0]}} ({{sourceResult[1].length}})"> | ||
|
||
<template ngFor let-result [ngForOf]="sourceResult[1]" let-i="index"> | ||
<igo-search-result | ||
igoListItem | ||
tabindex="{{i}}" | ||
[focused]="focusedResult && focusedResult.id === result.id | ||
&& focusedResult.source === sourceResults[0]" | ||
[result]="result" | ||
(focusItem)="focusResult(result)" | ||
(selectItem)="selectResult(result)"> | ||
</igo-search-result> | ||
</template> | ||
|
||
</igo-collapsible> | ||
</template> | ||
</igo-list> |
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,24 @@ | ||
<div class="igo-collapsible-header"> | ||
<h4> | ||
<md-icon | ||
(click)="handleClick()"> | ||
<ng-container *ngIf="state === 'collapsed'"> | ||
expand_more | ||
</ng-container> | ||
<ng-container *ngIf="state !== 'collapsed'"> | ||
expand_less | ||
</ng-container> | ||
</md-icon> | ||
<div class="igo-collapsible-title">{{title}}</div> | ||
</h4> | ||
</div> | ||
<ng-content></ng-content> | ||
<igo-flex | ||
#content | ||
direction="column" | ||
initial="auto" | ||
collapsed="0" | ||
expanded="auto" | ||
[state]="state"> | ||
<ng-content></ng-content> | ||
</igo-flex> |
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,36 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DebugElement } from '@angular/core'; | ||
import { MaterialModule } from '@angular/material'; | ||
|
||
import { FlexComponent } from '../flex/flex.component'; | ||
import { CollapsibleComponent } from './collapsible.component'; | ||
|
||
describe('CollapsibleComponent', () => { | ||
let component: CollapsibleComponent; | ||
let fixture: ComponentFixture<CollapsibleComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
MaterialModule.forRoot() | ||
], | ||
declarations: [ | ||
FlexComponent, | ||
CollapsibleComponent | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CollapsibleComponent); | ||
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,38 @@ | ||
@require '../../../css/theme.styl'; | ||
|
||
$igo-collapsible-header-height = 40px; | ||
|
||
.igo-collapsible-header { | ||
color: $igo-primary-font-color; | ||
height: $igo-collapsible-header-height; | ||
padding: 8px; | ||
text-align: center; | ||
} | ||
|
||
.igo-collapsible-header h4 { | ||
margin-top: 0px; | ||
margin-bottom: 0px; | ||
} | ||
|
||
.igo-collapsible-header md-icon { | ||
float: left; | ||
} | ||
|
||
.igo-collapsible-header >>> md-icon { | ||
cursor: pointer; | ||
} | ||
|
||
.igo-collapsible-content { | ||
padding-left: $igo-padding; | ||
} | ||
|
||
.igo-collapsible-title { | ||
display: inline-block; | ||
max-width: "calc(100% - 30px - %s)" % $igo-margin; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
margin-left: $igo-margin; | ||
float: left; | ||
padding: 4px 0; | ||
} |
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 { Component, Input, ViewChild } from '@angular/core'; | ||
|
||
import { FlexState, FlexComponent } from '../flex/flex.component'; | ||
|
||
@Component({ | ||
selector: 'igo-collapsible', | ||
templateUrl: './collapsible.component.html', | ||
styleUrls: ['./collapsible.component.styl'] | ||
}) | ||
export class CollapsibleComponent { | ||
|
||
@ViewChild('content') content: FlexComponent; | ||
|
||
@Input() state: FlexState = 'expanded'; | ||
@Input() title: string; | ||
|
||
constructor() { } | ||
|
||
handleClick() { | ||
if (this.state !== 'collapsed') { | ||
this.state = 'collapsed'; | ||
} else { | ||
this.state = 'expanded'; | ||
} | ||
} | ||
|
||
} |
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
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
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