-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathapp.component.ts
More file actions
64 lines (57 loc) · 2.05 KB
/
Copy pathapp.component.ts
File metadata and controls
64 lines (57 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Component, inject } from '@angular/core';
import { WeatherStateService } from './services/weather-state.service';
import { SearchFormComponent } from './components/search-form.component';
import { LoadingStateComponent } from './components/loading-state.component';
import { ErrorStateComponent } from './components/error-state.component';
import { WeatherContentComponent } from './components/weather-content.component';
@Component({
selector: 'app-root',
imports: [
SearchFormComponent,
LoadingStateComponent,
ErrorStateComponent,
WeatherContentComponent
],
template: `
<header class="header">
<div class="container">
<h1 class="header__title">Weather Front</h1>
</div>
</header>
<main class="main">
<div class="container">
@let currentState = weatherStateService.state();
<app-search-form
[isLoading]="currentState.isLoading"
(search)="weatherStateService.loadWeather($event)"
></app-search-form>
<div class="weather-container" data-testid="weather-container">
<app-loading-state [isVisible]="currentState.isLoading"></app-loading-state>
<app-error-state
[isVisible]="!!currentState.error && !currentState.isLoading"
[message]="currentState.error"
></app-error-state>
@defer (on immediate) {
<app-weather-content
[isVisible]="!!currentState.weatherData && !currentState.isLoading && !currentState.error"
[weatherData]="currentState.weatherData"
></app-weather-content>
}
</div>
</div>
</main>
<footer class="footer">
<div class="container">
<p class="footer__text">
Built with Angular • MIT License •
<a href="https://github.com/Lissy93" class="footer__link" target="_blank" rel="noopener">
Alicia Sykes
</a>
</p>
</div>
</footer>
`
})
export class AppComponent {
protected readonly weatherStateService = inject(WeatherStateService);
}