diff --git a/webapp/src/app/shared/ui/location-selector/location-selector.component.html b/webapp/src/app/shared/ui/location-selector/location-selector.component.html new file mode 100644 index 00000000..10c70cea --- /dev/null +++ b/webapp/src/app/shared/ui/location-selector/location-selector.component.html @@ -0,0 +1,112 @@ +
+

Länder/Kontinente vergleichen

+ +
+ @if (comparisonCountries().length > 0 || comparisonRegions().length > 0) { + + @for (c of comparisonCountries(); track c.id) { +
+ + flag {{ c.name }} + +
+ + +
+
+ } + + + @for (r of comparisonRegions(); track r.id) { +
+ + public {{ r.name }} + +
+ + +
+
+ } + } @else { +
+ Keine Länder/Kontinente ausgewählt. Suchen zum Hinzufügen. +
+ } +
+ + + +
diff --git a/webapp/src/app/shared/ui/location-selector/location-selector.component.scss b/webapp/src/app/shared/ui/location-selector/location-selector.component.scss new file mode 100644 index 00000000..acf0b1a7 --- /dev/null +++ b/webapp/src/app/shared/ui/location-selector/location-selector.component.scss @@ -0,0 +1,156 @@ +.control-card { + background: white; + border-radius: 10px; + padding: 1.25rem; + border: 1px solid #e5e7eb; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); + box-sizing: border-box; + + h3 { + font-size: 0.8rem; + font-weight: 600; + text-transform: uppercase; + color: #6b7280; + margin: 0 0 0.75rem 0; + letter-spacing: 0.05em; + } +} + +.comparison-list { + display: flex; + flex-direction: column; + gap: 0.4rem; + max-height: 200px; + overflow-y: auto; + margin-bottom: 0.75rem; + + .empty-list-info { + font-size: 0.75rem; + color: #9ca3af; + text-align: center; + padding: 8px 0; + border: 1px dashed #e5e7eb; + border-radius: 5px; + } +} + +.comparison-item { + display: flex; + justify-content: space-between; + align-items: center; + border: 1px solid #e5e7eb; + border-radius: 5px; + padding: 0.3rem 0.5rem; + transition: all 0.2s ease; + + .item-name { + display: inline-flex; + align-items: center; + gap: 6px; + font-size: 0.75rem; + font-weight: 600; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 170px; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + } + } + + .item-actions { + display: flex; + align-items: center; + gap: 4px; + } + + .action-btn { + background: none; + border: none; + cursor: pointer; + padding: 2px; + border-radius: 3px; + display: inline-flex; + align-items: center; + justify-content: center; + transition: all 0.15s ease; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + } + + &:hover { + background: rgba(0, 0, 0, 0.05); + } + + &.remove-btn:hover { + color: #ef4444 !important; + background: #fee2e2; + } + } +} + +.autocomplete-search { + position: relative; + width: 100%; + + input { + width: 100%; + padding: 0.5rem; + border-radius: 5px; + border: 1px solid #d1d5db; + font-size: 0.8125rem; + outline: none; + box-sizing: border-box; + &:focus { + border-color: #3b82f6; + } + } +} + +.autocomplete-results { + position: absolute; + top: 100%; + left: 0; + right: 0; + z-index: 50; + background: white; + border: 1px solid #e5e7eb; + border-radius: 5px; + box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); + margin-top: 3px; + padding: 0; + list-style: none; + max-height: 180px; + overflow-y: auto; + + li button { + width: 100%; + text-align: left; + background: none; + border: none; + padding: 0.5rem 0.75rem; + cursor: pointer; + display: flex; + flex-direction: column; + &:hover { + background: #f3f4f6; + } + + .name { + font-size: 0.75rem; + font-weight: 500; + color: #1f2937; + } + .hint { + font-size: 0.65rem; + color: #9ca3af; + margin-top: 1px; + } + } +} diff --git a/webapp/src/app/shared/ui/location-selector/location-selector.component.ts b/webapp/src/app/shared/ui/location-selector/location-selector.component.ts new file mode 100644 index 00000000..3d08fbce --- /dev/null +++ b/webapp/src/app/shared/ui/location-selector/location-selector.component.ts @@ -0,0 +1,50 @@ +import { Component, input, output } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { AutocompleteLocationItem } from '../../../api'; + +export interface CompareItem { + id: string; + name: string; +} + +@Component({ + selector: 'app-location-selector', + standalone: true, + imports: [CommonModule, MatIconModule], + templateUrl: './location-selector.component.html', + styleUrl: './location-selector.component.scss', +}) +export class LocationSelectorComponent { + readonly comparisonCountries = input([]); + readonly comparisonRegions = input([]); + readonly locationQuery = input(''); + readonly locationSearchResults = input([]); + readonly getEntityColor = input<(id: string) => string>(() => '#9ca3af'); + readonly isVisible = input<(id: string) => boolean>(() => true); + + readonly addLocation = output(); + readonly removeLocation = output<{ + id: string; + type: 'country' | 'continent'; + }>(); + readonly searchChange = output(); + readonly toggleVisibility = output(); + + onSearchInput(event: Event): void { + const val = (event.target as HTMLInputElement).value; + this.searchChange.emit(val); + } + + onSelectResult(loc: AutocompleteLocationItem): void { + this.addLocation.emit(loc); + } + + onRemove(id: string, type: 'country' | 'continent'): void { + this.removeLocation.emit({ id, type }); + } + + onToggleVisibility(id: string): void { + this.toggleVisibility.emit(id); + } +}