-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03a43e3
commit cc160ef
Showing
16 changed files
with
204 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
13 changes: 13 additions & 0 deletions
13
...ponents/character-switcher/character-switcher-item/character-switcher-item.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<section class="flex items-center space-x-2"> | ||
<div class="relative inline-flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600"> | ||
<span class="font-medium text-gray-600 dark:text-gray-300">{{ initials() }}</span> | ||
</div> | ||
<div class="flex min-w-0 flex-col justify-center text-left"> | ||
<div class="truncate font-semibold"> | ||
{{ characterName() }} | ||
</div> | ||
@if (group) { | ||
<div class="truncate text-sm text-gray-500 dark:text-gray-400">{{ group }}</div> | ||
} | ||
</div> | ||
</section> |
27 changes: 27 additions & 0 deletions
27
...omponents/character-switcher/character-switcher-item/character-switcher-item.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ChangeDetectionStrategy, Component, computed, input, Input } from '@angular/core'; | ||
|
||
const createInitials = (name: string) => { | ||
const regExp = new RegExp(/(\p{L}{1})\p{L}+/, 'gu'); | ||
|
||
const initials = [...name.matchAll(regExp)] || []; | ||
|
||
return ((initials.shift()?.[1] || '') + (initials.pop()?.[1] || '')).toUpperCase(); | ||
}; | ||
|
||
@Component({ | ||
selector: 'pap-character-switcher-item', | ||
standalone: true, | ||
imports: [], | ||
templateUrl: './character-switcher-item.component.html', | ||
styleUrl: './character-switcher-item.component.css', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class CharacterSwitcherItemComponent { | ||
@Input() group = ''; | ||
characterName = input.required<string>(); | ||
|
||
initials = computed(() => { | ||
const characterName = this.characterName(); | ||
return createInitials(characterName); | ||
}); | ||
} |
Empty file.
30 changes: 30 additions & 0 deletions
30
src/app/components/character-switcher/character-switcher.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<div class="flex items-center space-x-2"> | ||
<pap-character-switcher-item | ||
#dropdownTrigger | ||
[characterName]="currentCharacter().name" | ||
[group]="currentCharacter().group" | ||
class="min-w-0 flex-1 cursor-pointer" /> | ||
<fa-icon [icon]="faRepeat" class="text-gray-500 dark:text-gray-400" /> | ||
</div> | ||
|
||
<div class="z-10 hidden" #dropdownTarget id="character-menu-dropdown"> | ||
<div class="ml-1 rounded-lg bg-gray-50 shadow dark:bg-gray-800"> | ||
@if (charactersWithoutCurrent().length) { | ||
<div class="max-h-48 space-y-2 overflow-y-auto px-2 py-2"> | ||
@for (character of charactersWithoutCurrent(); track character.id) { | ||
<pap-character-switcher-item | ||
(click)="selectCharacter(character)" | ||
class="block" | ||
[characterName]="character.name" | ||
[group]="character.group"></pap-character-switcher-item> | ||
} | ||
</div> | ||
<hr class="h-px border-0 bg-gray-200 dark:bg-gray-700" /> | ||
} | ||
|
||
<a [routerLink]="['/characters/create']" class="block px-2 py-3"> | ||
<fa-icon [icon]="faUser" class="mr-1" /> | ||
Neuen Charakter erstellen</a | ||
> | ||
</div> | ||
</div> |
46 changes: 46 additions & 0 deletions
46
src/app/components/character-switcher/character-switcher.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AfterViewInit, ChangeDetectionStrategy, Component, computed, ElementRef, EventEmitter, input, Output, ViewChild } from '@angular/core'; | ||
import { CharacterSwitcherItemComponent } from './character-switcher-item/character-switcher-item.component'; | ||
import { FaIconComponent } from '@fortawesome/angular-fontawesome'; | ||
import { faRepeat, faUser } from '@fortawesome/free-solid-svg-icons'; | ||
import { RouterLink } from '@angular/router'; | ||
import { CharacterEntity } from '../../models/character/character.entity'; | ||
import { Dropdown } from 'flowbite'; | ||
|
||
@Component({ | ||
selector: 'pap-character-switcher', | ||
standalone: true, | ||
imports: [CharacterSwitcherItemComponent, FaIconComponent, RouterLink], | ||
templateUrl: './character-switcher.component.html', | ||
styleUrl: './character-switcher.component.css', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class CharacterSwitcherComponent implements AfterViewInit { | ||
characters = input.required<CharacterEntity[]>(); | ||
currentCharacter = input.required<CharacterEntity>(); | ||
|
||
@Output() characterSelected = new EventEmitter<CharacterEntity>(); | ||
protected readonly charactersWithoutCurrent = computed(() => { | ||
const characters = this.characters(); | ||
const currentCharacter = this.currentCharacter(); | ||
|
||
return characters.filter(character => character.id !== currentCharacter.id); | ||
}); | ||
protected readonly faRepeat = faRepeat; | ||
protected readonly faUser = faUser; | ||
@ViewChild('dropdownTrigger', { read: ElementRef, static: true }) | ||
private readonly dropdownTrigger!: ElementRef<HTMLElement>; | ||
@ViewChild('dropdownTarget', { static: true }) | ||
private readonly dropdownTarget!: ElementRef<HTMLElement>; | ||
private dropdown!: Dropdown; | ||
|
||
ngAfterViewInit() { | ||
this.dropdown = new Dropdown(this.dropdownTarget.nativeElement, this.dropdownTrigger.nativeElement, { | ||
placement: 'top', | ||
}); | ||
} | ||
|
||
protected selectCharacter(character: CharacterEntity) { | ||
this.dropdown.hide(); | ||
this.characterSelected.emit(character); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 10 additions & 18 deletions
28
src/app/components/characters/create-character/create-character.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
@if (charactersStore.count() > 0) { | ||
<pap-h1>Keine Charaktererstellung möglich</pap-h1> | ||
<pap-h1>Neuen Charakter erstellen</pap-h1> | ||
|
||
<p> | ||
Du hast bereits einen Charakter erstellt, gehe daher bitte zu seinem | ||
<a class="underline" [routerLink]="['/characters', charactersStore.entities()[0].id, 'dashboard']">Dashboard</a>. | ||
</p> | ||
} @else { | ||
<pap-h1>Neuen Charakter erstellen</pap-h1> | ||
<form (ngSubmit)="submit()" [formGroup]="formGroup" class="space-y-4"> | ||
<pap-text-input [autofocus]="true" [control]="formGroup.controls['name']" autoComplete="nickname" class="block" label="Name" /> | ||
<pap-text-input [control]="formGroup.controls['age']" [min]="0" class="block" label="Alter" valueType="number" /> | ||
<pap-text-input [control]="formGroup.controls['gender']" class="block" label="Geschlecht" /> | ||
<pap-text-input [control]="formGroup.controls['nation']" class="block" label="Volk" /> | ||
<pap-text-input [control]="formGroup.controls['religion']" class="block" label="Religion" /> | ||
<pap-text-input [control]="formGroup.controls['group']" class="block" label="Spielrunde" /> | ||
|
||
<form [formGroup]="formGroup" (ngSubmit)="submit()" class="space-y-4"> | ||
<pap-text-input class="block" [control]="formGroup.controls['name']" label="Name" [autofocus]="true" autoComplete="nickname" /> | ||
<pap-text-input class="block" [control]="formGroup.controls['age']" label="Alter" valueType="number" [min]="0" /> | ||
<pap-text-input class="block" [control]="formGroup.controls['gender']" label="Geschlecht" /> | ||
<pap-text-input class="block" [control]="formGroup.controls['nation']" label="Volk" /> | ||
<pap-text-input class="block" [control]="formGroup.controls['religion']" label="Religion" /> | ||
|
||
<pap-submit-button class="mt-4" [disabled]="formGroup.invalid">Charakter erstellen</pap-submit-button> | ||
</form> | ||
} | ||
<pap-submit-button [disabled]="formGroup.invalid" class="mt-4">Charakter erstellen</pap-submit-button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters