Skip to content

Commit 3a60fd7

Browse files
feat(client): wip roadmap bottomsheet in progress
1 parent 4bb6a10 commit 3a60fd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+763
-27
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"extends": ["../../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": [
8+
"plugin:@nx/angular",
9+
"plugin:@angular-eslint/template/process-inline-templates"
10+
],
11+
"rules": {
12+
"@angular-eslint/directive-selector": [
13+
"error",
14+
{
15+
"type": "attribute",
16+
"prefix": "al",
17+
"style": "camelCase"
18+
}
19+
],
20+
"@angular-eslint/component-selector": [
21+
"error",
22+
{
23+
"type": "element",
24+
"prefix": "al",
25+
"style": "kebab-case"
26+
}
27+
]
28+
}
29+
},
30+
{
31+
"files": ["*.html"],
32+
"extends": ["plugin:@nx/angular-template"],
33+
"rules": {}
34+
}
35+
]
36+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# roadmap-data-access
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test roadmap-data-access` to execute the unit tests.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export default {
2+
displayName: 'roadmap-data-access',
3+
preset: '../../../../jest.preset.js',
4+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
5+
coverageDirectory: '../../../../coverage/libs/blog/roadmap/data-access',
6+
transform: {
7+
'^.+\\.(ts|mjs|js|html)$': [
8+
'jest-preset-angular',
9+
{
10+
tsconfig: '<rootDir>/tsconfig.spec.json',
11+
stringifyContentPathRegex: '\\.(html|svg)$',
12+
},
13+
],
14+
},
15+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
16+
snapshotSerializers: [
17+
'jest-preset-angular/build/serializers/no-ng-attributes',
18+
'jest-preset-angular/build/serializers/ng-snapshot',
19+
'jest-preset-angular/build/serializers/html-comment',
20+
],
21+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "roadmap-data-access",
3+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/blog/roadmap/data-access/src",
5+
"prefix": "al",
6+
"projectType": "library",
7+
"tags": ["scope:client", "type:data-access"],
8+
"targets": {
9+
"test": {
10+
"executor": "@nx/jest:jest",
11+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
12+
"options": {
13+
"jestConfig": "libs/blog/roadmap/data-access/jest.config.ts"
14+
}
15+
},
16+
"lint": {
17+
"executor": "@nx/eslint:lint"
18+
}
19+
}
20+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './lib/infractructure/index';
2+
export * from './lib/state/index';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './roadmap.service';
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { HttpClient } from '@angular/common/http';
2+
import { inject, Injectable } from '@angular/core';
3+
import { Observable, of } from 'rxjs';
4+
5+
import {
6+
AngularLoveNode,
7+
NodeDetails,
8+
RegularNode,
9+
} from '@angular-love/roadmap-utils';
10+
import { ConfigService } from '@angular-love/shared/config';
11+
12+
const angularLoveNodeMock: AngularLoveNode = {
13+
id: 'angular-love',
14+
title: 'Angular.Love Roadmap Introduction',
15+
nodeType: 'angular-love',
16+
description:
17+
'The Angular Roadmap on Angular.Love is your go-to guide for learning Angular the right way. It breaks down key concepts, best practices, and useful resources in a clear, structured way. Plus, it’s packed with valuable materials and constantly updated to keep up with the latest trends.',
18+
additionalDescription: `Before diving into Angular, it's essential to have a solid understanding of the following concepts: HTML & CSS – Structure and styling of web pages, including Flexbox, Grid, and responsiveness; JavaScript (ES6+) – Core concepts like variables, functions, promises, and async/await; TypeScript – A typed version of JavaScript with interfaces, generics, and decorators; Node.js & npm – Running JavaScript outside the browser and managing packages; Git – Handling code versions, branches, and teamwork; APIs & HTTP – Making requests and working with JSON data`,
19+
creators: [
20+
{ name: 'Miłosz Rutkowski', slug: 'milosz-rutkowski' },
21+
{ name: 'Łukasz Myszkowski', slug: 'lukasz-myszkowski' },
22+
{ name: 'Damian Brzeziński', slug: 'damian-brzezinski' },
23+
{ name: 'Dominik Kalinowski', slug: 'dominik-kalinowski' },
24+
],
25+
};
26+
const regularNodeMock: RegularNode = {
27+
id: 'change-detection',
28+
title: 'change detection',
29+
nodeType: 'regular',
30+
description:
31+
'Change detection in Angular synchronizes the component state with the DOM by tracking and updating data changes. It uses a tree-based approach, where updates propagate from the root component down to child components. The framework provides two strategies: Default, which checks all components, and OnPush, which optimizes performance by only checking components when their inputs change.',
32+
movies: [
33+
{
34+
url: 'https://www.youtube.com/watch?v=KSFPOIauEPU',
35+
title: 'Angular RxJS and Signals: Better Together',
36+
},
37+
],
38+
articles: [
39+
{
40+
title: 'Signals in Angular: deep dive for busy developers',
41+
url: 'https://angular.love/signals-in-angular-deep-dive-for-busy-developers',
42+
},
43+
{
44+
title: 'Angular Signals: A New Feature in Angular 16',
45+
url: 'https://angular.love/angular-signals-a-new-feature-in-angular-16',
46+
},
47+
{
48+
title: 'Why Angular signals won’t replace',
49+
url: 'https://angular.love/why-angular-signals-wont-replace-rxjs',
50+
},
51+
],
52+
};
53+
54+
@Injectable({ providedIn: 'root' })
55+
export class RoadmapService {
56+
private readonly _http = inject(HttpClient);
57+
private readonly _apiBaseUrl = inject(ConfigService).get('apiBaseUrl');
58+
59+
getNodeDetails(id: string): Observable<NodeDetails> {
60+
if (id === 'angular-love') {
61+
return of(angularLoveNodeMock);
62+
} else {
63+
return of(regularNodeMock);
64+
}
65+
}
66+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './roadmap-store';
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { inject } from '@angular/core';
2+
import { tapResponse } from '@ngrx/operators';
3+
import { patchState, signalStore, withMethods, withState } from '@ngrx/signals';
4+
import { rxMethod } from '@ngrx/signals/rxjs-interop';
5+
import { pipe, switchMap, tap } from 'rxjs';
6+
7+
import { RoadmapBottomsheetService } from '@angular-love/roadmap-utils';
8+
9+
import { RoadmapService } from '../infractructure/roadmap.service';
10+
11+
type RoadmapState = {
12+
loading: 'success' | 'error' | 'init' | 'loading';
13+
};
14+
15+
const initialState: RoadmapState = {
16+
loading: 'init',
17+
};
18+
19+
export const RoadmapStore = signalStore(
20+
withState(initialState),
21+
withMethods(
22+
(
23+
store,
24+
roadmapService = inject(RoadmapService),
25+
bottomsheetService = inject(RoadmapBottomsheetService),
26+
) => ({
27+
resetToInit: () => {
28+
patchState(store, { loading: 'init' });
29+
},
30+
getNodeDetails: rxMethod<string>(
31+
pipe(
32+
tap(() => {
33+
console.log('Store, getNodeDetails');
34+
patchState(store, {
35+
loading: 'loading',
36+
});
37+
bottomsheetService.close();
38+
}),
39+
switchMap((id) =>
40+
roadmapService.getNodeDetails(id).pipe(
41+
tapResponse({
42+
next: (nodeDetails) => {
43+
console.log('Success data:', nodeDetails);
44+
patchState(store, { loading: 'success' });
45+
bottomsheetService.open(nodeDetails);
46+
},
47+
error: () => {
48+
patchState(store, { loading: 'error' });
49+
bottomsheetService.close();
50+
},
51+
}),
52+
),
53+
),
54+
),
55+
),
56+
}),
57+
),
58+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
2+
3+
setupZoneTestEnv({
4+
errorOnUnknownElements: true,
5+
errorOnUnknownProperties: true,
6+
});

0 commit comments

Comments
 (0)