add sorting for gallery

This commit is contained in:
2019-11-17 09:36:37 +01:00
parent 73ea635ac1
commit 70fb84d634
14 changed files with 310 additions and 13 deletions

View File

@@ -0,0 +1 @@
<img src="{{imageUrl()}}" (click)="toggle($event)" class="icon-small" title="{{title()}}" />

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ImageToggleComponent } from './image-toggle.component';
describe('ImageToggleComponent', () => {
let component: ImageToggleComponent;
let fixture: ComponentFixture<ImageToggleComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ImageToggleComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ImageToggleComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,38 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'pdb-image-toggle',
templateUrl: './image-toggle.component.html',
styleUrls: ['./image-toggle.component.scss']
})
export class ImageToggleComponent implements OnInit {
@Input()
images : string = "";
value: number = 0;
@Output()
valueChanged : EventEmitter<number> = new EventEmitter<number>();
_states : Array<any>;
constructor() { }
ngOnInit() {
this._states = JSON.parse(this.images);
}
imageUrl() : string {
return this._states[this.value].imageUrl;
}
title() : string {
return this._states[this.value].title;
}
toggle(event){
this.value = (this.value+1) % this._states.length;
this.valueChanged.emit(this.value);
}
}