Skip to content

Commit 9b892fc

Browse files
authored
refactor: remove category libs to use common one (#361)
1 parent 2230fb8 commit 9b892fc

Some content is hidden

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

48 files changed

+81
-651
lines changed

libs/blog/articles/feature-angular-in-depth/README.md

-7
This file was deleted.

libs/blog/articles/feature-angular-in-depth/jest.config.ts

-23
This file was deleted.

libs/blog/articles/feature-angular-in-depth/project.json

-20
This file was deleted.

libs/blog/articles/feature-angular-in-depth/src/index.ts

-1
This file was deleted.

libs/blog/articles/feature-angular-in-depth/src/lib/feature-angular-in-depth/feature-angular-in-depth.component.html

-30
This file was deleted.

libs/blog/articles/feature-angular-in-depth/src/lib/feature-angular-in-depth/feature-angular-in-depth.component.ts

-53
This file was deleted.

libs/blog/articles/feature-angular-in-depth/src/test-setup.ts

-9
This file was deleted.

libs/blog/articles/feature-angular-in-depth/.eslintrc.json renamed to libs/blog/articles/feature-category/.eslintrc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
"prefix": "al",
2525
"style": "kebab-case"
2626
}
27-
],
28-
"@angular-eslint/prefer-standalone": "off"
27+
]
2928
}
3029
},
3130
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# blog-articles-feature-category
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test blog-articles-feature-category` to execute the unit tests.

libs/blog/articles/feature-news/jest.config.ts renamed to libs/blog/articles/feature-category/jest.config.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
/* eslint-disable */
21
export default {
3-
displayName: 'feature-news',
2+
displayName: 'blog-articles-feature-category',
43
preset: '../../../../jest.preset.js',
54
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6-
coverageDirectory: '../../../../coverage/libs/blog/articles/feature-news',
5+
coverageDirectory: '../../../../coverage/libs/blog/articles/feature-category',
76
transform: {
87
'^.+\\.(ts|mjs|js|html)$': [
98
'jest-preset-angular',

libs/blog/articles/feature-guides/project.json renamed to libs/blog/articles/feature-category/project.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "blog-articles-feature-guides",
2+
"name": "blog-articles-feature-category",
33
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4-
"sourceRoot": "libs/blog/articles/feature-guides/src",
4+
"sourceRoot": "libs/blog/articles/feature-category/src",
55
"prefix": "al",
66
"projectType": "library",
77
"tags": ["scope:client", "type:feature"],
@@ -10,7 +10,7 @@
1010
"executor": "@nx/jest:jest",
1111
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
1212
"options": {
13-
"jestConfig": "libs/blog/articles/feature-guides/jest.config.ts"
13+
"jestConfig": "libs/blog/articles/feature-category/jest.config.ts"
1414
}
1515
},
1616
"lint": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib/category-articles.component';
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
<h2 id="latest-articles" class="mb-8 text-4xl font-bold">Latest articles</h2>
1+
<h2 class="mb-8 text-4xl font-bold" [id]="id()">
2+
{{ title() }}
3+
</h2>
24

35
<section
4-
aria-labelledby="latest-articles"
56
aria-live="polite"
67
class="grid gap-8 md:grid-cols-2 lg:grid-cols-3"
8+
[attr.aria-labelledby]="id()"
79
>
810
@if (!articleStore.isFetchArticleListLoading()) {
911
@for (article of articleStore.articles(); track article.slug) {

libs/blog/articles/feature-guides/src/lib/feature-guides/feature-guides.component.spec.ts renamed to libs/blog/articles/feature-category/src/lib/category-articles.component.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
22

3-
import { FeatureGuidesComponent } from './feature-guides.component';
3+
import { CategoryArticlesComponent } from './category-articles.component';
44

55
describe('FeatureGuidesComponent', () => {
6-
let component: FeatureGuidesComponent;
7-
let fixture: ComponentFixture<FeatureGuidesComponent>;
6+
let component: CategoryArticlesComponent;
7+
let fixture: ComponentFixture<CategoryArticlesComponent>;
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
11-
imports: [FeatureGuidesComponent],
11+
imports: [CategoryArticlesComponent],
1212
}).compileComponents();
1313

14-
fixture = TestBed.createComponent(FeatureGuidesComponent);
14+
fixture = TestBed.createComponent(CategoryArticlesComponent);
1515
component = fixture.componentInstance;
1616
fixture.detectChanges();
1717
});
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { isPlatformBrowser } from '@angular/common';
12
import {
23
ChangeDetectionStrategy,
34
Component,
45
computed,
56
inject,
7+
input,
8+
PLATFORM_ID,
69
signal,
710
} from '@angular/core';
811

@@ -16,40 +19,51 @@ import {
1619
PaginationComponent,
1720
QueryPaginationDirective,
1821
} from '@angular-love/blog/shared/ui-pagination';
22+
import { ArticleCategory } from '@angular-love/contracts/articles';
1923
import { RepeatDirective } from '@angular-love/utils';
2024

2125
@Component({
22-
selector: 'al-news',
26+
selector: 'al-category-articles',
2327
imports: [
24-
UiArticleCardComponent,
2528
PaginationComponent,
2629
QueryPaginationDirective,
30+
UiArticleCardComponent,
2731
ArticleRegularCardSkeletonComponent,
2832
RepeatDirective,
2933
],
30-
templateUrl: './feature-news.component.html',
31-
styleUrl: './feature-news.component.scss',
34+
templateUrl: './category-articles.component.html',
35+
styleUrl: './category-articles.component.scss',
3236
changeDetection: ChangeDetectionStrategy.OnPush,
3337
host: {
3438
class: 'flex flex-col h-full w-full',
3539
},
3640
})
37-
export class FeatureNewsComponent {
38-
pagination = signal({ take: 12, skip: 0 });
41+
export class CategoryArticlesComponent {
42+
readonly category = input<ArticleCategory>();
43+
readonly excludeCategory = input<string>();
44+
readonly title = input.required<string>();
45+
readonly id = input.required<string>();
46+
47+
readonly pagination = signal({ take: 12, skip: 0 });
3948

4049
protected readonly articleStore = inject(ArticleListStore);
4150

51+
private readonly _platform = inject(PLATFORM_ID);
52+
4253
constructor() {
4354
const query = computed(() => ({
4455
...this.pagination(),
45-
category: 'news' as const,
56+
...(this.category() && { category: this.category() }),
57+
...(this.excludeCategory() && {
58+
excludeCategory: this.excludeCategory(),
59+
}),
4660
}));
4761

4862
this.articleStore.fetchArticleList(query);
4963
}
5064

5165
protected pageChange(event: PageChangeEvent) {
52-
window.scrollTo(0, 0);
66+
isPlatformBrowser(this._platform) && window.scrollTo(0, 0);
5367
this.pagination.set(event);
5468
}
5569
}
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+
});

libs/blog/articles/feature-guides/.eslintrc.json

-37
This file was deleted.

libs/blog/articles/feature-guides/README.md

-7
This file was deleted.

libs/blog/articles/feature-guides/jest.config.ts

-22
This file was deleted.

libs/blog/articles/feature-guides/src/index.ts

-1
This file was deleted.

0 commit comments

Comments
 (0)