49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
||
|
||
import { Icon } from '../../shared/icon/icon';
|
||
|
||
type StepState = 'done' | 'active' | 'wait';
|
||
|
||
@Component({
|
||
selector: 'app-photo-check',
|
||
imports: [Icon],
|
||
templateUrl: './photo-check.html',
|
||
styleUrl: './photo-check.scss',
|
||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||
})
|
||
export class PhotoCheck {
|
||
readonly photo = input.required<string>();
|
||
readonly title = input.required<string>();
|
||
readonly step = input(0);
|
||
|
||
protected readonly items = computed(() => {
|
||
const step = this.step();
|
||
|
||
return [
|
||
{
|
||
title: 'Фото отправлено',
|
||
text: step >= 1 ? 'Снимок получен сервисом' : 'Готовим снимок',
|
||
state: stepState(step, 0),
|
||
},
|
||
{
|
||
title: 'Сравниваем с эталонами',
|
||
text: `Ищем совпадение с ${this.title()}`,
|
||
state: stepState(step, 1),
|
||
},
|
||
{
|
||
title: 'Добавляем в коллекцию',
|
||
text: 'Объект появится в вашей коллекции',
|
||
state: stepState(step, 2),
|
||
},
|
||
];
|
||
});
|
||
}
|
||
|
||
function stepState(step: number, index: number): StepState {
|
||
if (step > index) {
|
||
return 'done';
|
||
}
|
||
|
||
return step === index ? 'active' : 'wait';
|
||
}
|