KAN-5-feat-video-full-size #1

Merged
Makusu merged 4 commits from KAN-5-feat-video-full-size into main 2026-04-09 11:56:48 +02:00
4 changed files with 0 additions and 135 deletions
Showing only changes of commit 5c174ed7f3 - Show all commits

View File

@ -1,14 +0,0 @@
.searchcontainer {
width:80vw;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.inputSearch {
margin-bottom: 1rem;
display: flex;
flex-direction: row;
}

View File

@ -1,58 +0,0 @@
<div class="searchcontainer">
<form class="inputSearch" (ngSubmit)="onSubmit()">
<label class="input">
<svg
class="h-[1em] opacity-50"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
>
<g
stroke-linejoin="round"
stroke-linecap="round"
stroke-width="2.5"
fill="none"
stroke="currentColor"
>
<circle cx="11" cy="11" r="8"></circle>
<path d="m21 21-4.3-4.3"></path>
</g>
</svg>
<input type="search" [value]="searchString()" (input)="updateSearch($event)" class="grow" placeholder="Search" />
<kbd class="kbd kbd-sm"></kbd>
<kbd class="kbd kbd-sm">K</kbd>
</label>
<button class="btn">Submit</button>
</form>
@if(searchResults()!==null && searchResults()!.collection.items.length==0){
<div class="resultsContainer">
<p>No results for this search</p>
</div>
}
@if(searchResults()!==null && searchResults()!.collection.items.length!==0){
<div class="resultsContainer">
<ul class="list bg-base-100 rounded-box shadow-md">
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">Results</li>
@for(el of searchResults()!.collection.items; track el.data[0].nasa_id){
<li class="list-row">
<!-- 2 for small image -->
<div><a><img class="size-25 rounded-box" src="{{el.links[1].href}}"/></a></div>
<div>
<div>{{el.data[0].title}}</div>
<div class="text-xs uppercase font-semibold opacity-60">Photographer: {{el.data[0].photographer}}</div>
<p class="list-col-wrap text-xs">
{{el.data[0].description}}
</p>
</div>
<button class="btn btn-square btn-ghost" (click)="onClick(el.data[0].nasa_id)">
<svg class="size-[1.2em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><g stroke-linejoin="round" stroke-linecap="round" stroke-width="2" fill="none" stroke="currentColor"><path d="M6 3L20 12 6 21 6 3z"></path></g></svg>
</button>
</li>
}
</ul>
</div>
}
</div>

View File

@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Search } from './search';
describe('Search', () => {
let component: Search;
let fixture: ComponentFixture<Search>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Search]
})
.compileComponents();
fixture = TestBed.createComponent(Search);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,40 +0,0 @@
import { Component, inject, signal } from '@angular/core';
import { NAPOD } from '../../services/napod';
import { NasaApi } from '../../interfaces/nasa-api';
import { FormsModule, NgModel } from '@angular/forms';
import { Router } from '@angular/router';
@Component({
selector: 'app-search',
imports: [FormsModule],
templateUrl: './search.html',
styleUrl: './search.css'
})
export class Search {
private readonly nasaApi = inject(NAPOD);
private readonly router = inject(Router)
searchResults = signal<NasaApi | null>(null)
searchString=signal('');
onSubmit() {
this.nasaApi.searchForVideos(this.searchString()).subscribe({
next: (data)=>{this.searchResults.set(data);
console.log(data.collection);
},
error: error =>{console.log(error);
}
})
}
onClick(nasaId: string){
this.router.navigate(['/video/'+nasaId])
}
updateSearch(event: Event){
console.log(this.searchString());
const target = event.target as HTMLInputElement;
this.searchString.set(target.value)
}
}