Skip to content

Commit

Permalink
feat: add chapter new control flow (#65)
Browse files Browse the repository at this point in the history
feat: begin defer chapter
  • Loading branch information
Nicoss54 authored Oct 11, 2024
1 parent c5dba73 commit d01aef7
Show file tree
Hide file tree
Showing 188 changed files with 6,620 additions and 32 deletions.
3 changes: 2 additions & 1 deletion apps/04-binding/src/app/material-design.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { NgModule } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';

@NgModule({
exports: [MatCardModule, MatToolbarModule, MatIconModule],
exports: [MatCardModule, MatToolbarModule, MatIconModule, MatButtonModule],
})
export class MaterialDesignModule {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section>
@for (person of people$|async;track person.id) {
<sfeir-card *ngFor="let person of people$ | async" [person]="person" />
<sfeir-card [person]="person" />
}
</section>
4 changes: 2 additions & 2 deletions apps/16-template-driven-form/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ La composant de la modale est également créé, dans le fichier **add-person-di

Dans le dossier shared/components, et à l'aide du CLI, créez un composant FormComponent en pensant bien à l'exporter dans la propriété exports de votre module SharedModule

Dans le ficher **form.component.html**, copiez le contenue du fichier \_static/form.component.html
Dans le ficher **form.component.html**, copiez le contenue du fichier assets/static/form.component.html

Dans le fichier **form.component.scss**, copiez le contenue du fichier \_static/form.component.css
Dans le fichier **form.component.scss**, copiez le contenue du fichier assets/static/form.component.css
<br><br>

## Etape 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mat-card appearance="outlined" class="mat-whiteframe-2dp">
<mat-card-title-group>
<img mat-card-image [ngSrc]="person.photo" alt="person-photo" height="128" height="128" />
<img mat-card-image [ngSrc]="person.photo" alt="person-photo" width="128" height="128" />
<mat-card-title>
<a href="/people/1"> <span>{{ person.firstname + ' ' + person.lastname}}</span> </a>
</mat-card-title>
Expand Down Expand Up @@ -31,4 +31,4 @@
</a>
</div>
</mat-card-content>
</mat-card>
</mat-card>
6 changes: 4 additions & 2 deletions apps/30-ngxs-store-solution/src/app/core/store/app.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export interface AppState {

export class SetPeople {
static readonly type = '[App] SetPeople';
constructor(public payload) {}

constructor(public payload: People[]) {}
}

export class SetSearch {
static readonly type = '[App] SetSearch';
constructor(public payload) {}

constructor(public payload: string) {}
}

@State<AppState>({
Expand Down
37 changes: 37 additions & 0 deletions apps/34-signal/src/app/core/store/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { computed, inject, InjectionToken, makeEnvironmentProviders, signal } from '@angular/core';
import { PeopleService } from '../providers/people.service';
import { People, PeopleForm } from '../../shared/models/people.model';
import { switchMap, tap } from 'rxjs';

const filterPeople = (search: string) => (people: People) =>
people.lastname.toLowerCase().includes(search.toLowerCase()) || people.firstname.toLowerCase().includes(search.toLowerCase());

function appStore(peopleService = inject(PeopleService)) {
const people = signal<People[]>([]);
const search = signal<string>('');

return {
people: computed(() => people().filter(filterPeople(search()))),
search: search.asReadonly(),
setSearch(value: string) {
search.set(value);
},
getPeople() {
return peopleService.getPeople().pipe(tap(data => people.set(data)));
},
deletePeople(id: string) {
return peopleService.deletePeople(id).pipe(tap(data => people.set(data)));
},
addNewPerson(person: PeopleForm) {
return peopleService.addNewPerson(person).pipe(switchMap(() => this.getPeople()));
},
};
}

export const PEOPLE_STORE = new InjectionToken<Store>('StoreToken');

export type Store = ReturnType<typeof appStore>;

export const provideAppStore = () => {
return makeEnvironmentProviders([{ provide: PEOPLE_STORE, useFactory: appStore }]);
};
47 changes: 47 additions & 0 deletions apps/35-deferred-views-solution/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"extends": [
"../../.eslintrc.json"
],
"ignorePatterns": [
"!**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"extends": [
"plugin:@nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "sfeir",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "sfeir",
"style": "kebab-case"
}
],
"@angular-eslint/no-input-rename": "off"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@nx/angular-template"
],
"rules": {}
}
]
}
23 changes: 23 additions & 0 deletions apps/35-deferred-views-solution/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
export default {
displayName: 'ngrx-store-solution',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {},
coverageDirectory: '../../coverage/apps/ngrx-store-solution',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
'jest-preset-angular',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
95 changes: 95 additions & 0 deletions apps/35-deferred-views-solution/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"name": "35-deferred-views-solution",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "apps/35-deferred-views-solution/src",
"prefix": "sfeir",
"tags": [],
"targets": {
"build": {
"executor": "@angular-devkit/build-angular:application",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/apps/35-deferred-views-solution",
"index": "apps/35-deferred-views-solution/src/index.html",
"browser": "apps/35-deferred-views-solution/src/main.ts",
"polyfills": [
"apps/35-deferred-views-solution/src/polyfills.ts"
],
"tsConfig": "apps/35-deferred-views-solution/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"apps/35-deferred-views-solution/src/favicon.ico",
"apps/35-deferred-views-solution/src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"apps/35-deferred-views-solution/src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "apps/35-deferred-views-solution/src/environments/environment.ts",
"with": "apps/35-deferred-views-solution/src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"executor": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "35-deferred-views-solution:build:production"
},
"development": {
"buildTarget": "35-deferred-views-solution:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"executor": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "35-deferred-views-solution:build"
}
},
"lint": {
"executor": "@nx/eslint:lint"
},
"test": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/apps/35-deferred-views-solution"
],
"options": {
"jestConfig": "apps/35-deferred-views-solution/jest.config.ts"
}
}
}
}
16 changes: 16 additions & 0 deletions apps/35-deferred-views-solution/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- This component is an Angular Material Component, this is not important for the formation, to have more details on this component, please take take a look: https://material.angular.io/ -->
<ng-template #headerTemplate>
<mat-toolbar class="extend-toolbar">
<span>
<a [routerLink]="['home']"> <img src="assets/images/logo-sfeir.svg" aria-label="sfeir" alt="Sfeir" /> </a>
</span>

<span class="flex"></span>

<span> <a href="/locator">Maps</a> <a [routerLink]="['people']">List</a> </span>
</mat-toolbar>
</ng-template>

<sfeir-header [headerTemplate]="headerTemplate"></sfeir-header>

<router-outlet></router-outlet>
43 changes: 43 additions & 0 deletions apps/35-deferred-views-solution/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
mat-toolbar {
&.extend-toolbar {
background-color: #0168ab;
background-image: url('/assets/images/bg_right.png');
background-repeat: no-repeat;
background-position: right;
top: 0px;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.26);
width: 100%;
z-index: 1;
color: white;
margin-bottom: 10px;
}

.flex {
flex: 1 1 auto;
}

a {
color: inherit;
text-decoration: none;
height: 100%;
margin: 0px 10px 0px 10px;
border-bottom: 2px solid transparent;
font-size: 1.1em;
font-weight: normal;
font-family: 'Open Sans', sans-serif;

&:not(.active):hover {
border-bottom: 2px solid white;
}

img {
height: 100%;
margin-left: -60px;
}
}
}

/* TODO(mdc-migration): The following rule targets internal classes of card that may no longer apply for the MDC version. */
mat-card {
text-align: center;
}
15 changes: 15 additions & 0 deletions apps/35-deferred-views-solution/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component } from '@angular/core';
import { MatToolbarModule } from '@angular/material/toolbar';
import { RouterLink, RouterOutlet } from '@angular/router';
import { HeaderComponent } from './core/components/header/header.component';

@Component({
selector: 'sfeir-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
standalone: true,
imports: [HeaderComponent, RouterLink, RouterOutlet, MatToolbarModule],
})
export class AppComponent {
name = 'SFEIR - LUXEMBOURG';
}
27 changes: 27 additions & 0 deletions apps/35-deferred-views-solution/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { MatDialogModule } from '@angular/material/dialog';
import { provideAnimations } from '@angular/platform-browser/animations';
import { Routes, provideRouter, withComponentInputBinding } from '@angular/router';
import { AuthorizationInterceptor } from './core/interceptors/authorization.interceptor';
import { providePeopleStore } from './core/store/signal.store';

const APP_ROUTES: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadComponent: async () => (await import('./feature/home/home.component')).HomeComponent },
{ path: 'people', loadComponent: async () => (await import('./feature/people/people.component')).PeopleComponent },
{
path: 'people/:id',
loadChildren: async () => await import('./feature/update-person/update-person.route'),
},
];

export const appConfig: ApplicationConfig = {
providers: [
provideRouter(APP_ROUTES, withComponentInputBinding()),
provideAnimations(),
provideHttpClient(withInterceptors([AuthorizationInterceptor])),
providePeopleStore(),
importProvidersFrom(MatDialogModule),
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<section>
<ng-container *ngTemplateOutlet="headerTemplate()"></ng-container>
</section>
Empty file.
Loading

0 comments on commit d01aef7

Please sign in to comment.