Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ modules.xml
.angular

.eslintcache

.references
7 changes: 6 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,10 @@
"builtin": true
},
"globals": {},
"ignorePatterns": ["test/**", "machine-translation.ts", "extract-translations.ts"]
"ignorePatterns": [
"test/**",
"machine-translation.ts",
"extract-translations.ts",
".references/**"
]
}
870 changes: 374 additions & 496 deletions bun.lock

Large diffs are not rendered by default.

43 changes: 27 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"build": "ng build",
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"format": "oxfmt",
"format:check": "oxfmt --check",
"format": "bun fmt",
"format:check": "bun fmt --check",
"check": "bun check",
"update:kompakkt:common": "bun run update-git-dependency.ts -d @kompakkt/common -o Kompakkt -r Common -b main",
"update:kompakkt:komponents": "bun run update-git-dependency.ts -d @kompakkt/komponents -o Kompakkt -r Komponents -b main",
"update:kompakkt:plugins": "bun run update-git-dependency.ts -d @kompakkt/plugins -o Kompakkt -r Plugins -b main",
Expand Down Expand Up @@ -45,17 +46,18 @@
"@angular/platform-browser": "21.2.6",
"@angular/platform-browser-dynamic": "21.2.6",
"@angular/router": "21.2.6",
"@babylonjs/core": "9.0.0",
"@babylonjs/gui": "9.0.0",
"@babylonjs/gui-editor": "9.0.0",
"@babylonjs/inspector": "9.0.0",
"@babylonjs/loaders": "9.0.0",
"@babylonjs/materials": "9.0.0",
"@babylonjs/serializers": "9.0.0",
"@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#6797ea53a6f976ebc3310db5d434ee20848793bd",
"@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents.git#e2493ee87a9263e11c948a6c5ac2a31441940534",
"@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#5e5274042bee8730dc8789de610a09a741e77c60",
"@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#b6b5bfcccd4247285eafc77652f0a4b7a43f37ca",
"@babylonjs/core": "9.31.0",
"@babylonjs/gui": "9.31.0",
"@babylonjs/gui-editor": "9.31.0",
"@babylonjs/inspector": "9.31.0",
"@babylonjs/loaders": "9.31.0",
"@babylonjs/materials": "9.31.0",
"@babylonjs/serializers": "9.31.0",
"@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#044af84217ffafddad839841cc35a9e9027f5e3c",
"@kompakkt/fragments": "git+https://github.com/Kompakkt/engine_fragment#a58a35a1cc530c4d0589df197e99da82eae6d1fa",
"@kompakkt/komponents": "git+https://github.com/Kompakkt/Komponents.git#e90a436110cc635aa57953174140ee731ac40048",
"@kompakkt/plugins": "git+https://github.com/Kompakkt/Plugins.git#3ce5c36c4a82683c984fed0ca259217c49878e91",
"@kompakkt/server-openapi": "git+https://github.com/Kompakkt/Server.git#9728b208cecb7b7193448324025a94b9c35ac1f2",
"bson-objectid": "^2.0.4",
"copc": "^0.0.8",
"fast-deep-equal": "^3.1.3",
Expand All @@ -74,7 +76,7 @@
"zone.js": "0.16.1"
},
"devDependencies": {
"@angular/build": "^21.2.5",
"@angular/build": "^21.2.6",
"@angular/cli": "21.2.5",
"@angular/compiler-cli": "21.2.6",
"@angular/language-service": "21.2.6",
Expand All @@ -84,13 +86,22 @@
"@types/fscreen": "^1.0.4",
"@types/localforage": "^0.0.34",
"@types/node": "^25.5.0",
"oxfmt": "^0.42.0",
"oxlint": "^1.57.0",
"oxlint-tsgolint": "^0.18.1",
"ts-node": "~10.9.2",
"typescript": "~6.0.2"
"typescript": "~5.9.3"
},
"overrides": {
"@kompakkt/komponents": {
"@angular/core": "21.2.6"
},
"@kompakkt/plugins": {
"@angular/core": "21.2.6",
"@kompakkt/common": "git+https://github.com/Kompakkt/Common.git#1ec9e452e73a999d2b5ff725febd95dc0774a19f"
}
},
"trustedDependencies": [
"@kompakkt/common",
"@kompakkt/plugins"
]
}
19 changes: 10 additions & 9 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterContentChecked, ChangeDetectorRef, Component } from '@angular/core';
import { AfterContentChecked, ChangeDetectorRef, Component, effect, inject } from '@angular/core';
import { LoadingscreenComponent } from './components/loadingscreen/loadingscreen.component';
import { SceneComponent } from './components/scene/scene.component';
import { EntitySettingsService } from './services/entitysettings/entitysettings.service';
Expand All @@ -11,18 +11,19 @@ import { UserdataService } from './services/userdata/userdata.service';
imports: [LoadingscreenComponent, SceneComponent],
})
export class AppComponent implements AfterContentChecked {
constructor(
private changeDetector: ChangeDetectorRef,
private userdata: UserdataService,
public entitySettings: EntitySettingsService,
) {
this.userdata.isAuthenticated$.subscribe(isAuthenticated => {
console.log('Authentication status changed:', isAuthenticated);
#changeDetector = inject(ChangeDetectorRef);
#userdata = inject(UserdataService);
entitySettings = inject(EntitySettingsService);

constructor() {
effect(() => {
const userdata = this.#userdata.userdata();
console.log('Userdata changed:', userdata);
});
}

ngAfterContentChecked(): void {
this.changeDetector.detectChanges();
this.#changeDetector.detectChanges();

const queryParams = new URLSearchParams(location.search);
if (queryParams.get('transparent')) {
Expand Down
20 changes: 19 additions & 1 deletion src/app/components/bottom-sheet/bottom-sheet.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<div id="bottom-sheet">
<div id="bottom-sheet" [style.height]="heightCss()">
<app-sequence-editor [hidden]="sidenavMode() !== 'animations'" />
</div>

@if (isOpen()) {
<div
class="resize-handle"
role="separator"
aria-orientation="horizontal"
[attr.aria-label]="'Resize bottom sheet' | translate"
[attr.aria-valuemin]="minHeight()"
[attr.aria-valuemax]="maxHeight()"
[attr.aria-valuenow]="currentHeight()"
tabindex="0"
(pointerdown)="onHandlePointerDown($event)"
(pointermove)="onHandlePointerMove($event)"
(pointerup)="onHandlePointerUp($event)"
(pointercancel)="onHandlePointerUp($event)"
(keydown)="onHandleKeydown($event)"
></div>
}
28 changes: 25 additions & 3 deletions src/app/components/bottom-sheet/bottom-sheet.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
position: absolute;
bottom: 0;
left: var(--sidebar-width);
width: calc(100vw - var(--sidebar-width));
right: 0;
width: auto;
transition:
transform 200ms ease-out,
filter 200ms ease-out;
transform var(--panel-transition),
filter var(--panel-transition);
z-index: 99;
transform: translateY(100%);
filter: opacity(0);
Expand All @@ -14,6 +15,10 @@
transform: translateY(0);
filter: opacity(1);
}

&.is-resizing {
user-select: none;
}
}

#bottom-sheet {
Expand All @@ -31,3 +36,20 @@
display: none !important;
}
}

.resize-handle {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 8px;
z-index: 1;
cursor: row-resize;
touch-action: none;
user-select: none;

&:hover,
&:focus-visible {
background-color: var(--color-primary);
}
}
108 changes: 102 additions & 6 deletions src/app/components/bottom-sheet/bottom-sheet.component.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
import { Component, computed, ElementRef, inject } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { Component, computed, DestroyRef, ElementRef, inject, signal } from '@angular/core';
import { OverlayService } from '../../services/overlay/overlay.service';
import { TranslatePipe } from '../../pipes/translate.pipe';
import { SequenceEditorComponent } from '../entity-feature-animations/sequence-editor/sequence-editor.component';
import { ProcessingService } from 'src/app/services/processing/processing.service';

const BOTTOM_SHEET_HEIGHT_STORAGE_KEY = 'bottomSheetHeight';
const BOTTOM_SHEET_MIN_RATIO = 0.2;
const BOTTOM_SHEET_MAX_RATIO = 0.5;
const BOTTOM_SHEET_KEYBOARD_STEP = 10;
const BOTTOM_SHEET_KEYBOARD_STEP_LARGE = 50;

function readStoredHeight(): number | null {
const stored = Number(localStorage.getItem(BOTTOM_SHEET_HEIGHT_STORAGE_KEY));
return Number.isFinite(stored) && stored > 0 ? stored : null;
}

@Component({
selector: 'app-bottom-sheet',
templateUrl: './bottom-sheet.component.html',
styleUrls: ['./bottom-sheet.component.scss'],
imports: [SequenceEditorComponent],
imports: [SequenceEditorComponent, TranslatePipe],
host: {
'[class.is-visible]': 'isOpen()',
'[class.is-resizing]': 'isResizing()',
'(window:resize)': 'onWindowResize()',
},
})
export class BottomSheetComponent {
#overlay = inject(OverlayService);
#processing = inject(ProcessingService);
#sidenav = toSignal(this.#overlay.sidenav$);

isOpen = computed(() => {
const state = this.#sidenav();
const state = this.#overlay.sidenav();
if (!state?.open) return false;
switch (state.mode) {
case 'animations': {
Expand All @@ -34,5 +46,89 @@ export class BottomSheetComponent {

nativeElement = inject<ElementRef<HTMLDivElement>>(ElementRef).nativeElement;

sidenavMode = computed(() => (this.#sidenav()?.mode === 'animations' ? 'animations' : ''));
sidenavMode = computed(() =>
this.#overlay.sidenav()?.mode === 'animations' ? 'animations' : '',
);

public isResizing = this.#overlay.panelResizing;

#viewportHeight = signal(window.innerHeight);
#customHeight = signal<number | null>(readStoredHeight());
#renderedHeight = signal(0);
#pointerId: number | null = null;
#dragStart = { pointerY: 0, height: 0 };

public height = computed(() => {
const customHeight = this.#customHeight();
return customHeight === null ? null : this.#clampToViewport(customHeight);
});
public heightCss = computed(() => {
const height = this.height();
return height === null ? null : `${height}px`;
});
public minHeight = computed(() => Math.floor(this.#viewportHeight() * BOTTOM_SHEET_MIN_RATIO));
public maxHeight = computed(() => Math.floor(this.#viewportHeight() * BOTTOM_SHEET_MAX_RATIO));
public currentHeight = computed(() => this.height() ?? Math.round(this.#renderedHeight()));

constructor() {
const observer = new ResizeObserver(entries => {
const size = entries[0]?.borderBoxSize[0];
if (size) this.#renderedHeight.set(size.blockSize);
});
observer.observe(this.nativeElement);
inject(DestroyRef).onDestroy(() => observer.disconnect());
}

public onWindowResize(): void {
this.#viewportHeight.set(window.innerHeight);
if (this.#customHeight() !== null) this.#persist();
}

public onHandlePointerDown(event: PointerEvent): void {
if (event.button !== 0 || !event.isPrimary) return;
event.preventDefault();
this.#pointerId = event.pointerId;
this.#dragStart = { pointerY: event.clientY, height: this.currentHeight() };
this.isResizing.set(true);
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
}

public onHandlePointerMove(event: PointerEvent): void {
if (event.pointerId !== this.#pointerId) return;
event.preventDefault();
const delta = this.#dragStart.pointerY - event.clientY;
this.#customHeight.set(this.#clampToViewport(this.#dragStart.height + delta));
}

public onHandlePointerUp(event: PointerEvent): void {
if (event.pointerId !== this.#pointerId) return;
this.#pointerId = null;
this.isResizing.set(false);
this.#persist();
}

public onHandleKeydown(event: KeyboardEvent): void {
const step = event.shiftKey ? BOTTOM_SHEET_KEYBOARD_STEP_LARGE : BOTTOM_SHEET_KEYBOARD_STEP;
const targets: Record<string, number> = {
ArrowUp: this.currentHeight() + step,
ArrowDown: this.currentHeight() - step,
Home: this.minHeight(),
End: this.maxHeight(),
};
const target = targets[event.key];
if (target === undefined) return;
event.preventDefault();
this.#customHeight.set(this.#clampToViewport(target));
this.#persist();
}

#clampToViewport(value: number): number {
const min = this.#viewportHeight() * BOTTOM_SHEET_MIN_RATIO;
const max = this.#viewportHeight() * BOTTOM_SHEET_MAX_RATIO;
return Math.floor(Math.min(Math.max(value, min), max));
}

#persist(): void {
localStorage.setItem(BOTTOM_SHEET_HEIGHT_STORAGE_KEY, `${this.currentHeight()}`);
}
}
37 changes: 37 additions & 0 deletions src/app/components/color-field/color-field.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<span
class="color-field"
[tooltip]="'Click to open color picker' | translate"
cdkOverlayOrigin
#origin="cdkOverlayOrigin"
>
<button
type="button"
class="color-field-swatch"
[style.background]="swatchColor()"
[attr.aria-label]="label()"
[attr.aria-expanded]="popoverOpen()"
></button>
@if (label()) {
<span class="color-field-label">{{ label() }}</span>
}
</span>

<ng-template
cdkConnectedOverlay
[cdkConnectedOverlayOrigin]="origin"
[cdkConnectedOverlayOpen]="popoverOpen()"
[cdkConnectedOverlayPositions]="positions"
cdkConnectedOverlayHasBackdrop
cdkConnectedOverlayBackdropClass="cdk-overlay-transparent-backdrop"
(attach)="onAttach()"
(detach)="onDetach()"
(backdropClick)="close()"
>
<div class="color-field-popover">
<color-chrome
[color]="color()"
[disableAlpha]="disableAlpha()"
(onChange)="onPickerChange($event)"
/>
</div>
</ng-template>
Loading
Loading