Skip to content

Commit 04bd01d

Browse files
authored
refactor: make app standalone (#136)
1 parent 5154ed7 commit 04bd01d

37 files changed

+295
-260
lines changed

src/app/app.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2-
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
2+
import { NavigationEnd, NavigationStart, Router, RouterOutlet } from '@angular/router';
33
import { merge, Observable } from 'rxjs';
44
import { filter, mapTo } from 'rxjs/operators';
5+
import { MatProgressBar } from '@angular/material/progress-bar';
6+
import { AsyncPipe, NgIf } from '@angular/common';
57

68
@Component({
9+
standalone: true,
710
selector: 'ac-root',
811
templateUrl: './app.component.html',
912
styleUrls: ['./app.component.scss'],
10-
changeDetection: ChangeDetectionStrategy.OnPush
13+
changeDetection: ChangeDetectionStrategy.OnPush,
14+
imports: [RouterOutlet, AsyncPipe, NgIf, MatProgressBar]
1115
})
1216
export class AppComponent implements OnInit {
1317
loading$: Observable<boolean>;

src/app/app.config.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ApplicationConfig } from '@angular/core';
2+
import { provideState, provideStore } from '@ngrx/store';
3+
import { provideStoreDevtools } from '@ngrx/store-devtools';
4+
import { environment } from '../environments/environment';
5+
import { ROOT_REDUCER, USER_PROVIDED_META_REDUCERS } from './state/app.state';
6+
import { PreloadAllModules, provideRouter, withPreloading } from '@angular/router';
7+
import { APP_ROUTES } from './app.routes';
8+
import { provideRouterStore } from '@ngrx/router-store';
9+
import { provideAnimations } from '@angular/platform-browser/animations';
10+
import { checklistReducer } from './checklist/state/checklist.reducer';
11+
import { projectsReducer } from './projects/state/projects.reducer';
12+
import { MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckboxDefaultOptions } from '@angular/material/checkbox';
13+
14+
export const appConfig: ApplicationConfig = {
15+
providers: [
16+
provideAnimations(),
17+
provideRouter(APP_ROUTES, withPreloading(PreloadAllModules)),
18+
provideStore(ROOT_REDUCER, {
19+
metaReducers: USER_PROVIDED_META_REDUCERS
20+
}),
21+
provideState('checklist', checklistReducer),
22+
provideState('projects', projectsReducer),
23+
provideStoreDevtools({
24+
maxAge: 25,
25+
logOnly: environment.production,
26+
connectInZone: true
27+
}),
28+
provideRouterStore(),
29+
30+
// material design
31+
{
32+
provide: MAT_CHECKBOX_DEFAULT_OPTIONS,
33+
useValue: { clickAction: 'noop' } as MatCheckboxDefaultOptions
34+
}
35+
]
36+
};

src/app/app.module.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/app/app.routes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { Routes } from '@angular/router';
22

33
export const APP_ROUTES: Routes = [
4-
{ path: '', redirectTo: '/projects', pathMatch: 'full' },
5-
{ path: '**', redirectTo: '/projects' }
4+
{ path: 'projects', loadChildren: () => import('./projects/projects.routes').then(m => m.PROJECTS_ROUTES) },
5+
{
6+
path: ':project/checklist',
7+
loadChildren: () => import('./checklist/checklist.routes').then(m => m.CHECKLIST_ROUTES)
8+
},
9+
{ path: '', redirectTo: 'projects', pathMatch: 'full' }
610
];

src/app/app.server.module.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/app/checklist/checklist-cta-bar/checklist-cta-bar.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { Component, Input, Output, EventEmitter } from '@angular/core';
22
import { ChecklistFilter } from '../models/checklist.model';
3+
import { MatIcon } from '@angular/material/icon';
4+
import { MatButton } from '@angular/material/button';
5+
import { NgIf } from '@angular/common';
36

47
@Component({
8+
standalone: true,
59
selector: 'ac-checklist-cta-bar',
610
templateUrl: './checklist-cta-bar.component.html',
7-
styleUrls: ['./checklist-cta-bar.component.scss']
11+
styleUrls: ['./checklist-cta-bar.component.scss'],
12+
imports: [NgIf, MatButton, MatIcon]
813
})
914
export class ChecklistCtaBarComponent {
1015
@Input() filter: ChecklistFilter;

src/app/checklist/checklist-detail-view/checklist-detail-view.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@ import { ToggleFavorite, ToggleItem } from '../../projects/state/projects.action
55
import { ApplicationState } from '../../state/app.state';
66
import { ChecklistItem } from '../models/checklist.model';
77
import { ChecklistSelectors } from '../state/checklist.selectors';
8+
import { BannerComponent } from '../../shared/banner/banner.component';
9+
import { ChecklistMetadataComponent } from '../checklist-item-metadata/checklist-metadata.component';
10+
import { ChecklistFavoriteButtonComponent } from '../checklist-favorite-button/checklist-favorite-button.component';
11+
import { MatCheckbox } from '@angular/material/checkbox';
12+
import { NgIf, AsyncPipe } from '@angular/common';
813

914
@Component({
15+
standalone: true,
1016
selector: 'ac-checklist-detail-view',
1117
templateUrl: './checklist-detail-view.component.html',
12-
styleUrls: ['./checklist-detail-view.component.scss']
18+
styleUrls: ['./checklist-detail-view.component.scss'],
19+
imports: [NgIf, MatCheckbox, ChecklistFavoriteButtonComponent, ChecklistMetadataComponent, BannerComponent, AsyncPipe]
1320
})
1421
export class ChecklistDetailViewComponent implements OnInit {
1522
item$: Observable<any>;

src/app/checklist/checklist-favorite-button/checklist-favorite-button.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Component, Output, EventEmitter, Input } from '@angular/core';
2+
import { MatIcon } from '@angular/material/icon';
3+
import { NgStyle } from '@angular/common';
4+
import { MatIconButton } from '@angular/material/button';
25

36
@Component({
7+
standalone: true,
48
selector: 'ac-checklist-favorite-button',
59
templateUrl: './checklist-favorite-button.component.html',
6-
styleUrls: ['./checklist-favorite-button.component.scss']
10+
styleUrls: ['./checklist-favorite-button.component.scss'],
11+
imports: [MatIconButton, NgStyle, MatIcon]
712
})
813
export class ChecklistFavoriteButtonComponent {
914
_style = {};

src/app/checklist/checklist-favorites-view/checklist-favorites-view.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import { ApplicationState } from '../../state/app.state';
66
import { ChecklistFilter, ChecklistItem, Favorite } from '../models/checklist.model';
77
import { SetFavoritesFilter } from '../state/checklist.actions';
88
import { ChecklistSelectors } from '../state/checklist.selectors';
9+
import { ChecklistListItemComponent } from '../checklist-list/checklist-list-item.component';
10+
import { ChecklistListComponent } from '../checklist-list/checklist-list.component';
11+
import { NgIf, NgFor, AsyncPipe } from '@angular/common';
12+
import { ChecklistCtaBarComponent } from '../checklist-cta-bar/checklist-cta-bar.component';
913

1014
@Component({
15+
standalone: true,
1116
selector: 'ac-checklist-favorites-view',
1217
templateUrl: './checklist-favorites-view.component.html',
13-
styleUrls: ['./checklist-favorites-view.component.scss']
18+
styleUrls: ['./checklist-favorites-view.component.scss'],
19+
imports: [ChecklistCtaBarComponent, NgIf, NgFor, ChecklistListComponent, ChecklistListItemComponent, AsyncPipe]
1420
})
1521
export class ChecklistFavoritesViewComponent implements OnInit {
1622
favorites$: Observable<Array<Favorite>>;

src/app/checklist/checklist-item-metadata/checklist-metadata.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import { Component, Input } from '@angular/core';
22
import { Author } from '../models/checklist.model';
3+
import { NgIf } from '@angular/common';
34

45
@Component({
6+
standalone: true,
57
selector: 'ac-checklist-metadata',
68
templateUrl: './checklist-metadata.component.html',
7-
styleUrls: ['./checklist-metadata.component.scss']
9+
styleUrls: ['./checklist-metadata.component.scss'],
10+
imports: [NgIf]
811
})
912
export class ChecklistMetadataComponent {
1013
@Input() author: Author;

0 commit comments

Comments
 (0)