Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(daffio): add packages overview page #2721

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class DaffioDocsHeaderContainer {
faBars = faBars;

links: any[] = [
{ path: '/guides', title: 'Packages' },
{ path: '/api', title: 'API Index' },
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
})
export class DaffioDocsSidebarContentComponent {
links: any[] = [
{ path: '/guides', title: 'Packages' },
{ path: '/api', title: 'API Index' },
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<a daff-card color="theme" *ngFor="let package of packagesList" [routerLink]="package.path">
<div daffCardTitle>{{ package.title }}</div>
<div daffCardContent *ngIf="package.description">{{ package.description }}</div>
</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@use 'utilities' as daff;

:host {
display: grid;
align-items: flex-start;
grid-template-columns: 1fr;
gap: 8px;

@include daff.breakpoint(tablet) {
grid-template-columns: repeat(2, 1fr);
gap: 16px;
}

@include daff.breakpoint(big-tablet) {
grid-template-columns: repeat(3, 1fr);
}

@include daff.breakpoint(small-laptop) {
grid-template-columns: repeat(4, 1fr);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
waitForAsync,
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffioDocsPackageCardsComponent } from './package-cards.component';

describe('DaffioDocsPackageCardsComponent', () => {
let component: DaffioDocsPackageCardsComponent;
let fixture: ComponentFixture<DaffioDocsPackageCardsComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffioDocsPackageCardsComponent,
],
imports: [
RouterTestingModule,
NoopAnimationsModule,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioDocsPackageCardsComponent);
component = fixture.componentInstance;

fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {
ChangeDetectionStrategy,
Component,
Input,
} from '@angular/core';

export interface DaffioPackage {
title: string;
path: string;
description: string;
}

@Component({
selector: 'daffio-docs-package-cards',
templateUrl: './package-cards.component.html',
styleUrls: ['./package-cards.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DaffioDocsPackageCardsComponent {

@Input() packagesList: DaffioPackage[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design/card';

import { DaffioDocsPackageCardsComponent } from './package-cards.component';

@NgModule({
declarations: [
DaffioDocsPackageCardsComponent,
],
exports: [
DaffioDocsPackageCardsComponent,
],
imports: [
CommonModule,
RouterModule,
DaffCardModule,
],
})
export class DaffioDocsPackageCardsComponentModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<daffio-docs-package-cards [packagesList]="packagesList$ | async"></daffio-docs-package-cards>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

import { HttpClientTestingModule } from '@angular/common/http/testing';
import {
waitForAsync,
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffioDocsPackageCardsContainer } from './package-cards.component';

describe('DaffioDocsPackageCardsContainer', () => {
let component: DaffioDocsPackageCardsContainer;
let fixture: ComponentFixture<DaffioDocsPackageCardsContainer>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffioDocsPackageCardsContainer,
],
imports: [
RouterTestingModule,
NoopAnimationsModule,
HttpClientTestingModule,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioDocsPackageCardsContainer);
component = fixture.componentInstance;

fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {
ChangeDetectionStrategy,
Component,
OnInit,
} from '@angular/core';
import {
map,
Observable,
tap,
} from 'rxjs';

import { DaffioDoc } from '../../../docs/models/doc';
import { DaffioGuideList } from '../../../docs/models/guide-list';
import { DaffioDocsService } from '../../../docs/services/docs.service';
import { DaffioPackage } from '../../components/package-cards/package-cards.component';

@Component({
selector: 'daffio-docs-package-cards-container',
templateUrl: './package-cards.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DaffioDocsPackageCardsContainer implements OnInit {

packagesList$: Observable<DaffioPackage[]>;

constructor(
private docService: DaffioDocsService<DaffioDoc, DaffioGuideList>,
) {}

ngOnInit() {
this.packagesList$ = this.docService.getGuideList().pipe(
map((guidesTree) => guidesTree.children.map((p) => ({
title: p.title,
path: `/${p.path || p.children?.[0].path}`,
description: '',
}))),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design/card';

import { DaffioDocsPackageCardsContainer } from './package-cards.component';
import { DaffioDocsPackageCardsComponentModule } from '../../components/package-cards/package-cards.module';


@NgModule({
declarations: [
DaffioDocsPackageCardsContainer,
],
exports: [
DaffioDocsPackageCardsContainer,
],
imports: [
CommonModule,
RouterModule,
DaffCardModule,
DaffioDocsPackageCardsComponentModule,
],
})
export class DaffioDocsPackageCardsContainerModule { }
6 changes: 6 additions & 0 deletions apps/daffio/src/app/guides/guides-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ import {
} from '@angular/router';

import { DaffioGuidesPageComponent } from './pages/guides-page.component';
import { DaffioPackagesOverviewPageComponent } from './pages/packages-overview/packages-overview.component';
import { DocsResolver } from '../docs/resolvers/docs-resolver.service';

export const docsRoutes: Routes = [
{
path: '',
pathMatch: 'full',
component: DaffioPackagesOverviewPageComponent,
},
{
path: '**',
component: DaffioGuidesPageComponent,
Expand Down
13 changes: 13 additions & 0 deletions apps/daffio/src/app/guides/guides.module.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffContainerModule } from '@daffodil/design/container';
import { DaffHeroModule } from '@daffodil/design/hero';

import { DaffioDocsPackageCardsContainerModule } from './containers/package-cards/package-cards.module';
import { DaffioGuidesRoutingModule } from './guides-routing.module';
import { DaffioGuidesPageComponent } from './pages/guides-page.component';
import { DaffioPackagesOverviewPageComponent } from './pages/packages-overview/packages-overview.component';
import { DaffioDocViewerModule } from '../docs/components/doc-viewer/doc-viewer.module';

@NgModule({
imports: [
CommonModule,
RouterModule,

DaffioDocViewerModule,
DaffioGuidesRoutingModule,
DaffContainerModule,
DaffHeroModule,
DaffioDocsPackageCardsContainerModule,
],
declarations: [
DaffioGuidesPageComponent,
DaffioPackagesOverviewPageComponent,
],
exports: [
DaffioGuidesPageComponent,
DaffioPackagesOverviewPageComponent,
],
})
export class DaffioGuidesModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<daff-hero>
<daff-container size="md">
<h1 daffHeroTitle>Packages</h1>
<p daffHeroSubtitle>Learn how to build and optimize an ecommerce store with our packages.</p>
</daff-container>
</daff-hero>

<daff-container size="md">
<daffio-docs-package-cards-container class="daffio-packages-overview__card-grid"></daffio-docs-package-cards-container>
</daff-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@use 'utilities' as daff;

.daffio-packages-overview {
&__card-grid {
display: block;
padding: 0 24px;

@include daff.breakpoint(tablet) {
padding: 48px;
}

@include daff.breakpoint(small-laptop) {
padding: 48px 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {
ComponentFixture,
TestBed,
waitForAsync,
} from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffioPackagesOverviewPageComponent } from './packages-overview.component';

describe('DaffioPackagesOverviewPageComponent', () => {
let component: DaffioPackagesOverviewPageComponent;
let fixture: ComponentFixture<DaffioPackagesOverviewPageComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffioPackagesOverviewPageComponent,
],
imports: [
RouterTestingModule,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DaffioPackagesOverviewPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {
ChangeDetectionStrategy,
Component,
} from '@angular/core';

@Component({
selector: 'daffio-packages-overview',
templateUrl: './packages-overview.component.html',
styleUrls: ['./packages-overview.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DaffioPackagesOverviewPageComponent {}
Loading