diff --git a/src/app/build/items/item.component.ts b/src/app/build/items/item.component.ts new file mode 100644 index 0000000..d51f630 --- /dev/null +++ b/src/app/build/items/item.component.ts @@ -0,0 +1,23 @@ +import {Component, Input} from 'angular2/core'; +import {NgIf} from 'angular2/common'; + +import {DDragonDirective} from '../../misc/ddragon.directive'; + +@Component({ + selector: 'item', + directives: [NgIf, DDragonDirective], + template: ` + +
+

{{name}}

+
+ +

{{item.gold.total}}

+
+
` +}) + +export class ItemComponent { + @Input() item; + @Input() name; +} diff --git a/src/app/build/items/items.component.ts b/src/app/build/items/items.component.ts new file mode 100644 index 0000000..263bb64 --- /dev/null +++ b/src/app/build/items/items.component.ts @@ -0,0 +1,24 @@ +import {Component, Input, OnChanges} from 'angular2/core'; +import {NgFor, NgClass} from 'angular2/common'; + +import {ItemComponent} from './item.component.ts'; + +import {ToIterablePipe} from '../../misc/to-iterable.pipe'; + +@Component({ + selector: 'items', + directives: [NgFor, NgClass, ItemComponent], + pipes: [ToIterablePipe], + template: ` + ` +}) + +export class ItemsComponent implements OnChanges { + @Input() items; + + ngOnChanges() { + // TODO: implement + } +} diff --git a/src/app/build/shop/shop.component.spec.ts b/src/app/build/shop/shop.component.spec.ts index 99c0178..ec9ad31 100644 --- a/src/app/build/shop/shop.component.spec.ts +++ b/src/app/build/shop/shop.component.spec.ts @@ -50,7 +50,7 @@ describe('ShopComponent', () => { expect(component.items).not.toBeDefined(); component.getData(); return service.getItems().toPromise().then(() => { - expect(component.items).toBeDefined(); + expect(component.data).toBeDefined(); }); })); diff --git a/src/app/build/shop/shop.component.ts b/src/app/build/shop/shop.component.ts index 878490e..db30498 100644 --- a/src/app/build/shop/shop.component.ts +++ b/src/app/build/shop/shop.component.ts @@ -1,6 +1,8 @@ -import {Component, Output, EventEmitter, Inject} from 'angular2/core'; +import {Component, Input, Output, EventEmitter} from 'angular2/core'; import {NgFor, NgIf, NgClass} from 'angular2/common'; +import {ItemComponent} from '../items/item.component.ts'; + import {DDragonDirective} from '../../misc/ddragon.directive'; import {LoadingComponent} from '../../misc/loading.component'; import {ErrorComponent} from '../../misc/error.component'; @@ -20,12 +22,12 @@ import {LolApiService} from '../../misc/lolapi.service'; @Component({ selector: 'shop', providers: [LolApiService], - directives: [NgFor, NgIf, NgClass, DDragonDirective, LoadingComponent, ErrorComponent], - pipes: [TranslatePipe, CapitalizePipe, ToIterablePipe, MapPipe, ChampionPipe, HidePipe, TagsPipe, NamePipe, SortPipe], + directives: [NgFor, NgIf, NgClass, ItemComponent, DDragonDirective, LoadingComponent, ErrorComponent], + pipes: [ToIterablePipe, TranslatePipe, CapitalizePipe, MapPipe, ChampionPipe, HidePipe, TagsPipe, NamePipe, SortPipe], template: `
-
+

{{category.header | translate | capitalize}}


-
- -
-

{{item.name}}

-
- -

{{item.gold.total}}

-
-
-
+
@@ -63,9 +58,10 @@ import {LolApiService} from '../../misc/lolapi.service'; }) export class ShopComponent { - @Output() itemPicked: EventEmitter = new EventEmitter(); + @Input() items: Object; + @Output() itemsChanged: EventEmitter = new EventEmitter(); - private items: Object; + private data: Object; private loading: boolean = true; private error: boolean = false; @@ -81,7 +77,7 @@ export class ShopComponent { this.lolApi.getItems() .subscribe( - res => { this.items = res; }, + res => { this.data = res; }, error => { this.error = true; this.loading = false; }, () => this.loading = false ); @@ -101,4 +97,12 @@ export class ShopComponent { } } } + + private itemPicked(event: Event) { + if (!event || !event.target) { + return; + } + // TODO: implement + this.itemsChanged.next(null); + } } diff --git a/src/app/routes/build.component.ts b/src/app/routes/build.component.ts index 9b52e35..d6e4dff 100644 --- a/src/app/routes/build.component.ts +++ b/src/app/routes/build.component.ts @@ -3,6 +3,7 @@ import {NgIf} from 'angular2/common'; import {RouteParams} from 'angular2/router'; import {GraphComponent} from '../build/graph.component'; +import {ItemsComponent} from '../build/items/items.component'; import {MasteriesComponent} from '../build/masteries/masteries.component'; import {ShopComponent} from '../build/shop/shop.component'; @@ -15,7 +16,7 @@ import {LolApiService} from '../misc/lolapi.service'; import {Config} from '../build/config'; @Component({ - directives: [GraphComponent, MasteriesComponent, ShopComponent, DDragonDirective, LoadingComponent, ErrorComponent], + directives: [GraphComponent, ItemsComponent, MasteriesComponent, ShopComponent, DDragonDirective, LoadingComponent, ErrorComponent], providers: [LolApiService], styleUrls: [ './assets/css/build.css' @@ -31,7 +32,8 @@ import {Config} from '../build/config';
- + + ` }) @@ -43,6 +45,7 @@ export class BuildRoute { private error: boolean = false; private config: Config = new Config(); + private items: Object; constructor(params: RouteParams, private lolApi: LolApiService) { this.championKey = params.get('champion'); diff --git a/src/assets/css/build.css b/src/assets/css/build.css index 07dbea8..d42c88c 100644 --- a/src/assets/css/build.css +++ b/src/assets/css/build.css @@ -304,7 +304,10 @@ shop .items { min-height: 1000px; } -shop .item { + +/* item */ + +item { -webkit-user-select: none;/* Chrome/Safari */ -moz-user-select: none;/* Firefox */ -ms-user-select: none;/* IE10+ */ @@ -319,47 +322,47 @@ shop .item { cursor: pointer; } -shop .item > img { +item > img { height: 39px; border-radius: 5px; display: inline-block; border: 3px solid #026561; } -shop .item > div { +item > div { margin: 4px 10px; display: inline-block; width: 100%; } -shop .item > div > p { +item > div > p { margin: 0px; font-size: 1em; display: inline; font-family: sans-serif; } -shop .item .name { +item .name { width: 100%; } -shop .item .gold { +item .gold { min-width: 70px; display: flex; font-size: 0.8em; } -shop .item .gold img { +item .gold img { height: 32px; display: inline-block; padding-right: 4px; } -shop .item .gold p { +item .gold p { margin: 2px -8px; } -shop .item:hover { +item:hover { background-color: #CCC; } @@ -367,13 +370,13 @@ shop .item:hover { /* media */ @media (max-width: 1700px) { - shop .item { + item { width: 32%; } } @media (max-width: 1350px) { - shop .item { + item { width: 48%; } } @@ -385,10 +388,10 @@ shop .item:hover { } @media (max-width: 600px) { - shop .item { + item { width: 100%; } - shop .item .gold { + item .gold { display: inline-block; text-align: right; }