-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d56674f
commit 5cda09e
Showing
7 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { DetailsComponent } from './details.component'; | ||
|
||
export const routes: Routes = [ | ||
{ path: '', redirectTo: ':name', pathMatch: 'full' }, | ||
{ path: ':name', component: DetailsComponent } | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)] | ||
}) | ||
export class DetailsRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
:host { | ||
display: block; | ||
padding: 100px 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<app-card [package]="pkg()"></app-card> | ||
<mat-card class="package-details-readme" *ngIf="pkg()?.readme"> | ||
<mat-card-content [innerHTML]="readme()"></mat-card-content> | ||
</mat-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DetailsComponent } from './details.component'; | ||
|
||
describe('DetailsComponent', () => { | ||
let component: DetailsComponent; | ||
let fixture: ComponentFixture<DetailsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ DetailsComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(DetailsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Component, OnInit, signal } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
import * as showdown from 'showdown'; | ||
import { PackageType } from 'src/typings'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-details', | ||
templateUrl: './details.component.html', | ||
styleUrls: ['./details.component.css'], | ||
host: { | ||
class: 'package-details-wide' | ||
} | ||
}) | ||
export class DetailsComponent implements OnInit { | ||
|
||
pkg = signal<PackageType | null>(null); | ||
query = signal(''); | ||
|
||
constructor(private router: Router) { | ||
window.scrollTo(0, 0); | ||
} | ||
|
||
ngOnInit(): void { | ||
|
||
const { pkg, query } = window.history.state; | ||
|
||
if (!pkg) { | ||
this.router.navigate(['/']); | ||
return; | ||
} | ||
|
||
this.query.set(query); | ||
this.pkg.set(pkg as PackageType); | ||
|
||
} | ||
|
||
readme() { | ||
const converter = new showdown.Converter(); | ||
return converter.makeHtml(this.pkg()?.readme || ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { DetailsRoutingModule } from './details-routing.module'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, DetailsRoutingModule], | ||
declarations: [], | ||
providers: [], | ||
}) | ||
export class DetailsModule {} |