add pages

This commit is contained in:
Artem
2026-09-29 01:55:20 +03:00
parent cd0543907b
commit 7e8cb26ddd
110 changed files with 7948 additions and 367 deletions
@@ -0,0 +1,120 @@
@if (landmark(); as item) {
@if (claiming()) {
<app-claim-flow [landmark]="item" />
} @else {
<article class="object" [class.object--owned]="collected()">
<header class="object__hero">
<img class="object__hero-img" src="/assets/illustrations/object-hero.svg" alt="" />
<button class="object__back" type="button" aria-label="Назад" (click)="goBack()">
<app-icon name="chevron-left" [size]="22" />
</button>
<span class="object__city">{{ city.name }}</span>
</header>
<div class="object__intro">
<h1>{{ item.title }}</h1>
<div class="object__chips">
<span class="chip" [class.chip--open]="collected()">
<app-icon [name]="collected() ? 'check' : 'lock'" [size]="15" />
{{ collectedLabel() }}
</span>
</div>
<div class="object__address">
<app-icon name="pin" [size]="18" />
<div>
<p>{{ item.address }}</p>
<span>{{ item.addressHint }}</span>
</div>
</div>
</div>
<div class="object__body">
<section>
<h2>О месте</h2>
<p>{{ item.description }}</p>
</section>
<section>
<h2>Интересные факты</h2>
<ol class="facts">
@for (fact of item.facts; track fact; let index = $index) {
<li>
<span>{{ index + 1 }}</span>
{{ fact }}
</li>
}
</ol>
</section>
@if (collected()) {
<section>
<h2>Ваше фото</h2>
<button class="owned-photo" type="button" (click)="openPhoto()">
<img [src]="userPhoto() ?? '/assets/illustrations/photo-day.svg'" alt="Ваше фото объекта" />
<span class="owned-photo__badge">
<app-icon name="check" [size]="14" />
Подтверждено
</span>
</button>
<p class="object__hint">Этот объект уже в вашей коллекции. Повторно его получить нельзя.</p>
</section>
<a class="object__map" routerLink="/map">
<app-icon name="pin" [size]="20" />
Показать на карте
</a>
} @else {
<section>
<h2>Примеры фото</h2>
<div class="photos">
@for (photo of photoExamples; track photo.label) {
<figure>
<img [src]="photo.src" [alt]="photo.label" />
<span>{{ photo.label }}</span>
</figure>
}
</div>
<p class="object__hint">{{ item.photoHint }}</p>
</section>
<section>
<h2>Как забрать</h2>
<ol class="steps">
<li>Приезжайте на место и найдите объект</li>
<li>Нажмите «Забрать» и сфотографируйте объект</li>
<li>Получите объект в свою коллекцию</li>
</ol>
</section>
}
</div>
@if (!collected()) {
<footer class="object__bar">
<button class="object__claim" matButton="filled" type="button" (click)="claimItem()">
<app-icon name="camera" [size]="22" />
Забрать
</button>
<p>Понадобится доступ к камере</p>
</footer>
}
</article>
}
@if (photoOpen()) {
@if (userPhoto(); as image) {
<div class="photo-viewer" (click)="closePhoto()">
<button class="photo-viewer__close" type="button" aria-label="Закрыть" (click)="closePhoto()">
<app-icon name="chevron-left" [size]="22" />
</button>
<img [src]="image" alt="Ваше фото объекта" (click)="$event.stopPropagation()" />
</div>
}
}
} @else {
<section class="object object--empty">
<p>Объект не найден.</p>
<button matButton="outlined" type="button" (click)="goBack()">Назад</button>
</section>
}
@@ -0,0 +1,286 @@
:host {
display: block;
width: 100%;
min-height: 100%;
background: var(--color-bg);
}
.object {
display: flex;
flex-direction: column;
width: 100%;
max-width: var(--page-max-width);
min-height: 100%;
margin-inline: auto;
overflow-x: hidden;
}
@media (min-width: 720px) {
:host {
padding: 24px 16px 32px;
}
.object {
min-height: auto;
overflow: hidden;
border: 1px solid var(--color-border);
border-radius: 24px;
background: var(--color-bg);
}
.object__bar {
border-radius: 0 0 24px 24px;
}
}
.object__back,
.object__city {
position: absolute;
z-index: 1;
top: 16px;
min-height: 44px;
border: 1px solid var(--color-border);
background: rgb(28 26 23 / 86%);
color: var(--color-text);
}
.object__back {
left: 16px;
display: flex;
align-items: center;
justify-content: center;
width: 44px;
padding: 0;
border-radius: 14px;
cursor: pointer;
}
.object__city {
right: 16px;
display: flex;
align-items: center;
max-width: min(58%, 220px);
padding: 0 14px;
overflow: hidden;
border-radius: 20px;
font-size: 14px;
font-weight: 500;
text-overflow: ellipsis;
white-space: nowrap;
}
.object__intro {
position: relative;
z-index: 1;
margin-top: -44px;
padding: 0 16px;
}
.object__intro h1,
.object__body h2,
.facts span {
margin: 0;
font-family: var(--font-display);
font-weight: 700;
}
.object__intro h1 {
font-size: clamp(26px, 6.5vw, 32px);
line-height: 1.12;
letter-spacing: -0.03em;
overflow-wrap: break-word;
}
.object__chips,
.object__address,
.facts li,
.steps li {
display: flex;
gap: 8px;
}
.object__chips {
flex-wrap: wrap;
margin-top: 12px;
}
.chip,
.facts li {
border: 1px solid var(--color-border);
border-radius: 16px;
background: var(--color-surface-2);
}
.chip {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
overflow: visible;
color: var(--color-muted);
font-size: 14px;
font-weight: 500;
line-height: 1;
}
.chip--open {
background: rgb(224 184 79 / 14%);
border-color: var(--color-accent-strong);
color: var(--color-accent-soft);
font-weight: 600;
}
.object__address {
align-items: center;
margin-top: 16px;
color: var(--color-accent);
font-size: 14px;
}
.object__address p {
margin: 0;
color: var(--color-text);
}
.object__address span,
.object__hint,
.object__bar p {
color: var(--color-muted);
}
.object__body {
display: flex;
flex: 1;
flex-direction: column;
gap: 28px;
padding: 28px 16px 120px;
}
.object--owned .object__body {
padding-bottom: 40px;
}
.object__body h2 {
margin-bottom: 12px;
font-size: 22px;
}
.object__body p {
margin: 0;
color: var(--color-text-soft);
font-size: 16px;
line-height: 1.6;
}
.steps,
.facts {
display: flex;
flex-direction: column;
gap: 12px;
margin: 0;
padding: 0;
list-style: none;
}
.steps {
counter-reset: step;
}
.steps li {
align-items: center;
gap: 12px;
font-size: 15px;
}
.steps li::before {
counter-increment: step;
content: counter(step);
display: flex;
flex: none;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 1px solid var(--color-accent-strong);
border-radius: 16px;
color: var(--color-accent);
font-weight: 600;
}
.facts {
gap: 10px;
}
.facts li {
align-items: flex-start;
gap: 14px;
padding: 14px 16px;
background: var(--color-surface);
font-size: 15px;
line-height: 1.5;
}
.facts span {
min-width: 18px;
color: var(--color-accent);
font-size: 24px;
line-height: 1;
}
.object__hint {
margin: 10px 0 0;
font-size: 14px;
}
.object__body .object__hint {
color: var(--color-muted);
font-size: 14px;
}
.object__map {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
width: 100%;
min-height: 52px;
overflow: visible;
border: 1px solid var(--color-border);
border-radius: 16px;
background: var(--color-surface-2);
color: var(--color-text);
font-size: 16px;
font-weight: 500;
text-decoration: none;
}
.object__map app-icon {
color: var(--color-accent);
}
.object__bar {
position: sticky;
bottom: 0;
padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
background: linear-gradient(to bottom, transparent, rgb(18 17 15 / 96%) 30%);
}
.object__claim {
width: 100%;
min-height: 56px;
overflow: visible;
--mat-button-filled-container-shape: 16px;
}
.object__bar p {
margin: 8px 0 0;
font-size: 13px;
text-align: center;
}
.object--empty {
gap: 16px;
align-items: center;
justify-content: center;
padding: 48px 16px;
}
@@ -0,0 +1,109 @@
import { Location } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, HostListener, inject, input, signal } from '@angular/core';
import { Router, RouterLink } from '@angular/router';
import { MatButton } from '@angular/material/button';
import { Store } from '@ngrx/store';
import { ClaimFlow } from '../../claim/claim-flow/claim-flow';
import { CityCatalogService } from '../../root/services/city-catalog.service';
import { Icon } from '../../shared/icon/icon';
import {
GorodarActions,
selectClaim,
selectCollectedAt,
selectCollectedIdSet,
selectPhotos,
} from '../../state';
@Component({
selector: 'app-map-item-page',
imports: [MatButton, Icon, ClaimFlow, RouterLink],
templateUrl: './map-item-page.html',
styleUrl: './map-item-page.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MapItemPage {
private readonly catalog = inject(CityCatalogService);
private readonly store = inject(Store);
private readonly location = inject(Location);
private readonly router = inject(Router);
readonly id = input.required<string>();
protected readonly city = this.catalog.city;
protected readonly landmark = computed(() => this.catalog.landmarkById(this.id()));
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
protected readonly photos = this.store.selectSignal(selectPhotos);
protected readonly collectedAtMap = this.store.selectSignal(selectCollectedAt);
protected readonly claim = this.store.selectSignal(selectClaim);
protected readonly collected = computed(() => {
const item = this.landmark();
return item ? this.collectedIds().has(item.id) || item.collected : false;
});
protected readonly userPhoto = computed(() => {
const item = this.landmark();
return item ? (this.photos()[item.id] ?? null) : null;
});
protected readonly collectedLabel = computed(() => {
if (!this.collected()) {
return 'Не получен';
}
const item = this.landmark();
const at = item ? this.collectedAtMap()[item.id] : undefined;
if (!at) {
return 'Получен';
}
const formatted = new Intl.DateTimeFormat('ru-RU', {
day: 'numeric',
month: 'long',
}).format(new Date(at));
return `Получено · ${formatted}`;
});
protected readonly claiming = computed(() => {
const claim = this.claim();
return claim.landmarkId === this.id() && claim.stage !== 'idle';
});
protected readonly photoExamples = [
{ label: 'Днём', src: '/assets/illustrations/photo-day.svg' },
{ label: 'Вечером', src: '/assets/illustrations/photo-evening.svg' },
{ label: 'Зимой', src: '/assets/illustrations/photo-winter.svg' },
];
protected readonly photoOpen = signal(false);
protected goBack(): void {
if (window.history.length > 1) {
this.location.back();
return;
}
void this.router.navigateByUrl('/map');
}
protected claimItem(): void {
this.store.dispatch(GorodarActions.takePhoto({ landmarkId: this.id() }));
}
protected openPhoto(): void {
if (this.userPhoto()) {
this.photoOpen.set(true);
}
}
protected closePhoto(): void {
this.photoOpen.set(false);
}
@HostListener('document:keydown.escape')
protected onEscape(): void {
this.closePhoto();
}
}