diff --git a/ngsw-config.json b/ngsw-config.json
index e9a5fec..c1a50ad 100644
--- a/ngsw-config.json
+++ b/ngsw-config.json
@@ -1,6 +1,9 @@
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
+
+ "navigationUrls": ["/**", "!/admin", "!/admin/**"],
+
"assetGroups": [
{
"name": "app",
@@ -22,19 +25,15 @@
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
- "files": [
- "/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
- ]
+ "files": ["/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"]
}
}
],
+
"dataGroups": [
{
"name": "fonts",
- "urls": [
- "https://fonts.googleapis.com/**",
- "https://fonts.gstatic.com/**"
- ],
+ "urls": ["https://fonts.googleapis.com/**", "https://fonts.gstatic.com/**"],
"cacheConfig": {
"maxSize": 20,
"maxAge": "30d",
diff --git a/src/app/auth/ui/auth-sheet/auth-sheet.html b/src/app/auth/ui/auth-sheet/auth-sheet.html
index d95afed..504ebb5 100644
--- a/src/app/auth/ui/auth-sheet/auth-sheet.html
+++ b/src/app/auth/ui/auth-sheet/auth-sheet.html
@@ -1,5 +1,5 @@
@if (sheetVisible()) {
-
+
-
+
+
+
}
diff --git a/src/app/auth/ui/auth-sheet/auth-sheet.scss b/src/app/auth/ui/auth-sheet/auth-sheet.scss
index a6168b6..0052558 100644
--- a/src/app/auth/ui/auth-sheet/auth-sheet.scss
+++ b/src/app/auth/ui/auth-sheet/auth-sheet.scss
@@ -1,3 +1,7 @@
+:host {
+ display: contents;
+}
+
.sheet-root {
position: fixed;
z-index: 70;
@@ -13,32 +17,57 @@
border: 0;
background: rgb(8 7 6 / 64%);
cursor: pointer;
+ opacity: calc(1 - min(var(--drag-y, 0px), 280px) / 280px);
}
-.sheet {
+.sheet-pop {
position: relative;
z-index: 1;
width: min(100%, 480px);
max-height: min(92dvh, 760px);
- overflow: auto;
+ animation: sheet-in 0.28s ease-out;
+}
+
+.sheet {
+ width: 100%;
+ max-height: min(92dvh, 760px);
+ overflow: hidden auto;
padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
border: 1px solid var(--color-border);
border-bottom: 0;
border-radius: 28px 28px 0 0;
background: #1a1815;
- animation: sheet-in 0.28s ease-out;
+ transform: translateY(var(--drag-y, 0px));
+ transition: transform 0.22s ease-out;
+ touch-action: pan-y;
+}
+
+.sheet--dragging {
+ overflow: hidden;
+ transition: none;
+ touch-action: none;
}
.sheet__handle {
+ display: block;
+ width: 100%;
+ height: 28px;
+ margin: 0 auto 4px;
+ padding: 10px 0 12px;
+ border: 0;
+ background: transparent;
+ cursor: grab;
+ touch-action: none;
+}
+
+.sheet__handle::before {
+ content: '';
display: block;
width: 42px;
height: 4px;
- margin: 6px auto 12px;
- padding: 0;
- border: 0;
+ margin: 0 auto;
border-radius: 4px;
background: #4a453c;
- cursor: pointer;
}
.sheet__lock {
@@ -129,14 +158,19 @@
.sheet__resend {
display: block;
width: 100%;
+ min-height: 20px;
margin-top: 14px;
padding: 0;
+ overflow: hidden;
border: 0;
background: none;
color: var(--color-muted);
font: inherit;
font-size: 14px;
+ font-variant-numeric: tabular-nums;
text-align: center;
+ white-space: nowrap;
+ text-overflow: ellipsis;
cursor: pointer;
}
@@ -153,22 +187,7 @@
}
.sheet__submit {
- width: 100%;
- min-height: 52px;
margin-top: 16px;
- border: 0;
- border-radius: 16px;
- background: var(--color-accent);
- color: var(--color-on-accent);
- font: inherit;
- font-size: 16px;
- font-weight: 600;
- cursor: pointer;
-}
-
-.sheet__submit:disabled {
- opacity: 0.45;
- cursor: default;
}
.sheet__ghost {
@@ -196,7 +215,11 @@
}
@media (prefers-reduced-motion: reduce) {
- .sheet {
+ .sheet-pop {
animation: none;
}
+
+ .sheet {
+ transition: none;
+ }
}
diff --git a/src/app/auth/ui/auth-sheet/auth-sheet.ts b/src/app/auth/ui/auth-sheet/auth-sheet.ts
index 3a0f4a6..39b4da4 100644
--- a/src/app/auth/ui/auth-sheet/auth-sheet.ts
+++ b/src/app/auth/ui/auth-sheet/auth-sheet.ts
@@ -1,6 +1,7 @@
import {
ChangeDetectionStrategy,
Component,
+ DestroyRef,
ElementRef,
HostListener,
computed,
@@ -13,6 +14,7 @@ import {
import { Store } from '@ngrx/store';
import { Icon } from '../../../shared/icon/icon';
+import { RESEND_SECONDS } from '../../../state/gorodar.models';
import {
GorodarActions,
selectAuthCodeRequestId,
@@ -20,12 +22,13 @@ import {
selectAuthError,
selectAuthIntent,
selectAuthPending,
- selectAuthResendSeconds,
selectAuthSheetVisible,
selectAuthStep,
} from '../../../state';
const CODE_LENGTH = 6;
+const DISMISS_DISTANCE = 120;
+const DISMISS_VELOCITY = 0.55;
function emptyDigits(): string[] {
return Array.from({ length: CODE_LENGTH }, () => '');
@@ -40,17 +43,31 @@ function emptyDigits(): string[] {
})
export class AuthSheet {
private readonly store = inject(Store);
+ private readonly destroyRef = inject(DestroyRef);
private readonly digitFields = viewChildren
>('digit');
+ private pointerId: number | null = null;
+ private dragOriginY = 0;
+ private dragOriginX = 0;
+ private dragScrollTop = 0;
+ private dragFromHandle = false;
+ private dragTracking = false;
+ private dragMoved = false;
+ private dragLastY = 0;
+ private dragLastTime = 0;
+ private dragVelocity = 0;
+ private closeTimer = 0;
protected readonly emailDraft = signal('');
protected readonly digits = signal(emptyDigits());
+ protected readonly secondsLeft = signal(0);
+ protected readonly dragY = signal(0);
+ protected readonly dragging = signal(false);
protected readonly sheetVisible = this.store.selectSignal(selectAuthSheetVisible);
protected readonly step = this.store.selectSignal(selectAuthStep);
protected readonly email = this.store.selectSignal(selectAuthEmail);
protected readonly error = this.store.selectSignal(selectAuthError);
protected readonly pending = this.store.selectSignal(selectAuthPending);
- protected readonly resendSeconds = this.store.selectSignal(selectAuthResendSeconds);
protected readonly intent = this.store.selectSignal(selectAuthIntent);
private readonly codeRequestId = this.store.selectSignal(selectAuthCodeRequestId);
@@ -71,7 +88,7 @@ export class AuthSheet {
});
protected readonly resendLabel = computed(() => {
- const seconds = this.resendSeconds();
+ const seconds = this.secondsLeft();
if (seconds <= 0) {
return 'Отправить код ещё раз';
@@ -106,8 +123,35 @@ export class AuthSheet {
return;
}
- requestAnimationFrame(() => this.digitFields()[0]?.nativeElement.focus());
+ requestAnimationFrame(() =>
+ this.digitFields()[0]?.nativeElement.focus({ preventScroll: true }),
+ );
});
+
+ effect((onCleanup) => {
+ const requestId = this.codeRequestId();
+
+ if (requestId === 0) {
+ return;
+ }
+
+ let left = RESEND_SECONDS;
+ untracked(() => this.secondsLeft.set(left));
+
+ const timerId = window.setInterval(() => {
+ left -= 1;
+ const next = Math.max(left, 0);
+ this.secondsLeft.set(next);
+
+ if (next === 0) {
+ window.clearInterval(timerId);
+ }
+ }, 1000);
+
+ onCleanup(() => window.clearInterval(timerId));
+ });
+
+ this.destroyRef.onDestroy(() => window.clearTimeout(this.closeTimer));
}
protected onEmail(event: Event): void {
@@ -125,7 +169,7 @@ export class AuthSheet {
}
protected resend(): void {
- if (this.resendSeconds() > 0 || this.pending()) {
+ if (this.secondsLeft() > 0 || this.pending()) {
return;
}
@@ -137,9 +181,121 @@ export class AuthSheet {
}
protected dismiss(): void {
+ window.clearTimeout(this.closeTimer);
+ this.closeTimer = 0;
+ this.dragY.set(0);
+ this.dragging.set(false);
this.store.dispatch(GorodarActions.authSheetDismissed());
}
+ protected onDragStart(event: PointerEvent): void {
+ if (!event.isPrimary || event.button !== 0 || !this.canDragFrom(event.target)) {
+ return;
+ }
+
+ const sheet = event.currentTarget as HTMLElement;
+ this.pointerId = event.pointerId;
+ this.dragOriginY = event.clientY;
+ this.dragOriginX = event.clientX;
+ this.dragScrollTop = sheet.scrollTop;
+ this.dragFromHandle = this.isHandle(event.target);
+ this.dragTracking = false;
+ this.dragMoved = false;
+ this.dragLastY = event.clientY;
+ this.dragLastTime = event.timeStamp;
+ this.dragVelocity = 0;
+ }
+
+ protected onDragMove(event: PointerEvent): void {
+ if (event.pointerId !== this.pointerId) {
+ return;
+ }
+
+ const dy = event.clientY - this.dragOriginY;
+ const dx = event.clientX - this.dragOriginX;
+ const sheet = event.currentTarget as HTMLElement;
+
+ if (!this.dragTracking) {
+ if (Math.abs(dy) < 8 && Math.abs(dx) < 8) {
+ return;
+ }
+
+ const pullingDown = dy > 0 && Math.abs(dy) > Math.abs(dx);
+ const atTop = this.dragScrollTop <= 0;
+
+ if (!pullingDown || (!atTop && !this.dragFromHandle)) {
+ this.pointerId = null;
+ return;
+ }
+
+ this.dragTracking = true;
+ this.dragMoved = true;
+ this.dragging.set(true);
+ sheet.setPointerCapture(event.pointerId);
+ }
+
+ const elapsed = event.timeStamp - this.dragLastTime;
+
+ if (elapsed > 0) {
+ this.dragVelocity = (event.clientY - this.dragLastY) / elapsed;
+ }
+
+ this.dragLastY = event.clientY;
+ this.dragLastTime = event.timeStamp;
+ this.dragY.set(Math.max(0, dy));
+ }
+
+ protected onDragEnd(event: PointerEvent): void {
+ if (event.pointerId !== this.pointerId) {
+ return;
+ }
+
+ const sheet = event.currentTarget as HTMLElement;
+ const offset = this.dragY();
+ const close =
+ event.type !== 'pointercancel' &&
+ this.dragTracking &&
+ (offset > DISMISS_DISTANCE || (offset > 48 && this.dragVelocity > DISMISS_VELOCITY));
+
+ this.pointerId = null;
+ this.dragTracking = false;
+ this.dragging.set(false);
+
+ if (this.dragMoved) {
+ const stopClick = (clickEvent: Event): void => {
+ clickEvent.preventDefault();
+ clickEvent.stopPropagation();
+ };
+ sheet.addEventListener('click', stopClick, { capture: true, once: true });
+ this.dragMoved = false;
+ }
+
+ if (!close) {
+ this.dragY.set(0);
+ return;
+ }
+
+ this.dragY.set(sheet.getBoundingClientRect().height);
+ window.clearTimeout(this.closeTimer);
+ this.closeTimer = window.setTimeout(() => this.dismiss(), 200);
+ }
+
+ private canDragFrom(target: EventTarget | null): boolean {
+ if (!(target instanceof Element)) {
+ return true;
+ }
+
+ if (this.isHandle(target)) {
+ return true;
+ }
+
+ return target.closest('input, textarea, button, a, label') == null;
+ }
+
+ private isHandle(target: EventTarget | null): boolean {
+ return target instanceof Element && target.closest('.sheet__handle') != null;
+ }
+
protected onDigit(index: number, event: Event): void {
const input = event.target as HTMLInputElement;
const value = input.value.replace(/\D/g, '').slice(-1);
diff --git a/src/app/claim/collect-success/collect-success.html b/src/app/claim/collect-success/collect-success.html
index 10c2c09..08f3b84 100644
--- a/src/app/claim/collect-success/collect-success.html
+++ b/src/app/claim/collect-success/collect-success.html
@@ -11,14 +11,6 @@
@if (model()) {
-
- 3D
-
Картинка
+
+ 3D
+
}
@@ -111,7 +111,7 @@